1*a466cc55SCy Schubert /* 2*a466cc55SCy Schubert * Copyright (C) 2004-2007, 2009, 2010 Internet Systems Consortium, Inc. ("ISC") 3*a466cc55SCy Schubert * Copyright (C) 2000, 2001 Internet Software Consortium. 4*a466cc55SCy Schubert * 5*a466cc55SCy Schubert * Permission to use, copy, modify, and/or distribute this software for any 6*a466cc55SCy Schubert * purpose with or without fee is hereby granted, provided that the above 7*a466cc55SCy Schubert * copyright notice and this permission notice appear in all copies. 8*a466cc55SCy Schubert * 9*a466cc55SCy Schubert * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10*a466cc55SCy Schubert * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11*a466cc55SCy Schubert * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12*a466cc55SCy Schubert * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13*a466cc55SCy Schubert * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14*a466cc55SCy Schubert * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15*a466cc55SCy Schubert * PERFORMANCE OF THIS SOFTWARE. 16*a466cc55SCy Schubert */ 17*a466cc55SCy Schubert 18*a466cc55SCy Schubert /* $Id: md5.h,v 1.20 2010/01/07 23:48:54 tbox Exp $ */ 19*a466cc55SCy Schubert 20*a466cc55SCy Schubert /*! \file isc/md5.h 21*a466cc55SCy Schubert * \brief This is the header file for the MD5 message-digest algorithm. 22*a466cc55SCy Schubert * 23*a466cc55SCy Schubert * The algorithm is due to Ron Rivest. This code was 24*a466cc55SCy Schubert * written by Colin Plumb in 1993, no copyright is claimed. 25*a466cc55SCy Schubert * This code is in the public domain; do with it what you wish. 26*a466cc55SCy Schubert * 27*a466cc55SCy Schubert * Equivalent code is available from RSA Data Security, Inc. 28*a466cc55SCy Schubert * This code has been tested against that, and is equivalent, 29*a466cc55SCy Schubert * except that you don't need to include two pages of legalese 30*a466cc55SCy Schubert * with every copy. 31*a466cc55SCy Schubert * 32*a466cc55SCy Schubert * To compute the message digest of a chunk of bytes, declare an 33*a466cc55SCy Schubert * MD5Context structure, pass it to MD5Init, call MD5Update as 34*a466cc55SCy Schubert * needed on buffers full of bytes, and then call MD5Final, which 35*a466cc55SCy Schubert * will fill a supplied 16-byte array with the digest. 36*a466cc55SCy Schubert * 37*a466cc55SCy Schubert * Changed so as no longer to depend on Colin Plumb's `usual.h' 38*a466cc55SCy Schubert * header definitions; now uses stuff from dpkg's config.h 39*a466cc55SCy Schubert * - Ian Jackson <ijackson@nyx.cs.du.edu>. 40*a466cc55SCy Schubert * Still in the public domain. 41*a466cc55SCy Schubert */ 42*a466cc55SCy Schubert 43*a466cc55SCy Schubert #ifndef ISC_MD5_H 44*a466cc55SCy Schubert #define ISC_MD5_H 1 45*a466cc55SCy Schubert 46*a466cc55SCy Schubert #include <isc/lang.h> 47*a466cc55SCy Schubert #include <isc/platform.h> 48*a466cc55SCy Schubert #include <isc/types.h> 49*a466cc55SCy Schubert 50*a466cc55SCy Schubert #define ISC_MD5_DIGESTLENGTH 16U 51*a466cc55SCy Schubert #define ISC_MD5_BLOCK_LENGTH 64U 52*a466cc55SCy Schubert 53*a466cc55SCy Schubert #ifdef ISC_PLATFORM_OPENSSLHASH 54*a466cc55SCy Schubert #include <openssl/evp.h> 55*a466cc55SCy Schubert 56*a466cc55SCy Schubert typedef EVP_MD_CTX isc_md5_t; 57*a466cc55SCy Schubert 58*a466cc55SCy Schubert #else 59*a466cc55SCy Schubert 60*a466cc55SCy Schubert typedef struct { 61*a466cc55SCy Schubert isc_uint32_t buf[4]; 62*a466cc55SCy Schubert isc_uint32_t bytes[2]; 63*a466cc55SCy Schubert isc_uint32_t in[16]; 64*a466cc55SCy Schubert } isc_md5_t; 65*a466cc55SCy Schubert #endif 66*a466cc55SCy Schubert 67*a466cc55SCy Schubert ISC_LANG_BEGINDECLS 68*a466cc55SCy Schubert 69*a466cc55SCy Schubert void 70*a466cc55SCy Schubert isc_md5_init(isc_md5_t *ctx); 71*a466cc55SCy Schubert 72*a466cc55SCy Schubert void 73*a466cc55SCy Schubert isc_md5_invalidate(isc_md5_t *ctx); 74*a466cc55SCy Schubert 75*a466cc55SCy Schubert void 76*a466cc55SCy Schubert isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len); 77*a466cc55SCy Schubert 78*a466cc55SCy Schubert void 79*a466cc55SCy Schubert isc_md5_final(isc_md5_t *ctx, unsigned char *digest); 80*a466cc55SCy Schubert 81*a466cc55SCy Schubert ISC_LANG_ENDDECLS 82*a466cc55SCy Schubert 83*a466cc55SCy Schubert #endif /* ISC_MD5_H */ 84