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 #ifdef OPENSSL 10 # include "openssl/evp.h" 11 # include "libssl_compat.h" 12 #else /* !OPENSSL follows */ 13 /* 14 * Provide OpenSSL-alike MD5 API if we're not using OpenSSL 15 */ 16 # if defined HAVE_MD5_H && defined HAVE_MD5INIT 17 # include <md5.h> 18 # else 19 # include "isc/md5.h" 20 typedef isc_md5_t MD5_CTX; 21 # define MD5Init(c) isc_md5_init(c) 22 # define MD5Update(c, p, s) isc_md5_update(c, p, s) 23 # define MD5Final(d, c) isc_md5_final((c), (d)) /* swapped */ 24 # endif 25 26 typedef MD5_CTX EVP_MD_CTX; 27 28 # define EVP_MD_CTX_free(c) free(c) 29 # define EVP_MD_CTX_new() calloc(1, sizeof(MD5_CTX)) 30 # define EVP_get_digestbynid(t) NULL 31 # define EVP_md5() NULL 32 # define EVP_MD_CTX_init(c) 33 # define EVP_MD_CTX_set_flags(c, f) 34 # define EVP_DigestInit(c, dt) (MD5Init(c), 1) 35 # define EVP_DigestInit_ex(c, dt, i) (MD5Init(c), 1) 36 # define EVP_DigestUpdate(c, p, s) MD5Update(c, (const void *)(p), \ 37 s) 38 # define EVP_DigestFinal(c, d, pdl) \ 39 do { \ 40 MD5Final((d), (c)); \ 41 *(pdl) = 16; \ 42 } while (0) 43 # endif /* !OPENSSL */ 44 #endif /* NTP_MD5_H */ 45