1 /* 2 * ntp_md5.h: deal with md5.h headers 3 * 4 * Use the system MD5 if available, otherwise libisc's. 5 */ 6 #ifndef NTP_MD5_H 7 #define NTP_MD5_H 8 9 /* Use the system MD5 or fall back on libisc's */ 10 # if defined HAVE_MD5_H && defined HAVE_MD5INIT 11 # include <md5.h> 12 # else 13 # include "isc/md5.h" 14 typedef isc_md5_t MD5_CTX; 15 # define MD5_DIGEST_LENGTH ISC_MD5_DIGESTLENGTH 16 # define MD5Init(c) isc_md5_init(c) 17 # define MD5Update(c, p, s) isc_md5_update(c, (const void *)p, s) 18 # define MD5Final(d, c) isc_md5_final((c), (d)) /* swapped */ 19 # endif 20 21 # define KEY_TYPE_MD5 NID_md5 22 23 #ifdef OPENSSL 24 # include <openssl/evp.h> 25 # include "libssl_compat.h" 26 # ifdef HAVE_OPENSSL_CMAC_H 27 # include <openssl/cmac.h> 28 # define CMAC "AES128CMAC" 29 # define AES_128_KEY_SIZE 16 30 # endif /*HAVE_OPENSSL_CMAC_H*/ 31 #else /* !OPENSSL follows */ 32 /* 33 * Provide OpenSSL-alike MD5 API if we're not using OpenSSL 34 */ 35 36 typedef MD5_CTX EVP_MD_CTX; 37 38 # define NID_md5 4 /* from openssl/objects.h */ 39 # define EVP_MAX_MD_SIZE MD5_DIGEST_LENGTH 40 # define EVP_MD_CTX_free(c) free(c) 41 # define EVP_MD_CTX_new() calloc(1, sizeof(MD5_CTX)) 42 # define EVP_get_digestbynid(t) NULL 43 # define EVP_md5() NULL 44 # define EVP_MD_CTX_init(c) 45 # define EVP_MD_CTX_set_flags(c, f) 46 # define EVP_DigestInit(c, dt) (MD5Init(c), 1) 47 # define EVP_DigestInit_ex(c, dt, i) (MD5Init(c), 1) 48 # define EVP_DigestUpdate(c, p, s) MD5Update(c, (const void *)(p), \ 49 s) 50 # define EVP_DigestFinal(c, d, pdl) \ 51 do { \ 52 MD5Final((d), (c)); \ 53 *(pdl) = MD5_LENGTH; \ 54 } while (0) 55 # endif /* !OPENSSL */ 56 #endif /* NTP_MD5_H */ 57