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