00001 /* 00002 * Copyright (C) 2004-2007, 2009, 2010, 2014 Internet Systems Consortium, Inc. ("ISC") 00003 * Copyright (C) 2000, 2001 Internet Software Consortium. 00004 * 00005 * Permission to use, copy, modify, and/or distribute this software for any 00006 * purpose with or without fee is hereby granted, provided that the above 00007 * copyright notice and this permission notice appear in all copies. 00008 * 00009 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 00010 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00011 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 00012 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00013 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 00014 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00015 * PERFORMANCE OF THIS SOFTWARE. 00016 */ 00017 00018 /* $Id: md5.h,v 1.20 2010/01/07 23:48:54 tbox Exp $ */ 00019 00020 /*! \file isc/md5.h 00021 * \brief This is the header file for the MD5 message-digest algorithm. 00022 * 00023 * The algorithm is due to Ron Rivest. This code was 00024 * written by Colin Plumb in 1993, no copyright is claimed. 00025 * This code is in the public domain; do with it what you wish. 00026 * 00027 * Equivalent code is available from RSA Data Security, Inc. 00028 * This code has been tested against that, and is equivalent, 00029 * except that you don't need to include two pages of legalese 00030 * with every copy. 00031 * 00032 * To compute the message digest of a chunk of bytes, declare an 00033 * MD5Context structure, pass it to MD5Init, call MD5Update as 00034 * needed on buffers full of bytes, and then call MD5Final, which 00035 * will fill a supplied 16-byte array with the digest. 00036 * 00037 * Changed so as no longer to depend on Colin Plumb's `usual.h' 00038 * header definitions; now uses stuff from dpkg's config.h 00039 * - Ian Jackson <ijackson@nyx.cs.du.edu>. 00040 * Still in the public domain. 00041 */ 00042 00043 #ifndef ISC_MD5_H 00044 #define ISC_MD5_H 1 00045 00046 #include <isc/lang.h> 00047 #include <isc/platform.h> 00048 #include <isc/types.h> 00049 00050 #define ISC_MD5_DIGESTLENGTH 16U 00051 #define ISC_MD5_BLOCK_LENGTH 64U 00052 00053 #ifdef ISC_PLATFORM_OPENSSLHASH 00054 #include <openssl/evp.h> 00055 00056 typedef EVP_MD_CTX isc_md5_t; 00057 00058 #elif PKCS11CRYPTO 00059 #include <pk11/pk11.h> 00060 00061 typedef pk11_context_t isc_md5_t; 00062 00063 #else 00064 00065 typedef struct { 00066 isc_uint32_t buf[4]; 00067 isc_uint32_t bytes[2]; 00068 isc_uint32_t in[16]; 00069 } isc_md5_t; 00070 #endif 00071 00072 ISC_LANG_BEGINDECLS 00073 00074 void 00075 isc_md5_init(isc_md5_t *ctx); 00076 00077 void 00078 isc_md5_invalidate(isc_md5_t *ctx); 00079 00080 void 00081 isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len); 00082 00083 void 00084 isc_md5_final(isc_md5_t *ctx, unsigned char *digest); 00085 00086 ISC_LANG_ENDDECLS 00087 00088 #endif /* ISC_MD5_H */