2222 * $FreeBSD: src/contrib/cvs/lib/md5.h,v 1.2 1999/12/11 15:10:02 peter Exp $
2323 */
2424
25+ #if defined(HAVE_YASSL ) || defined(HAVE_OPENSSL )
26+ /*
27+ Use MD5 implementation provided by the SSL libraries.
28+ */
29+
30+ #if defined(HAVE_YASSL )
31+
32+ C_MODE_START
33+
34+ void my_md5_hash (char * digest , const char * buf , int len );
35+
36+ C_MODE_END
37+
38+ #else /* HAVE_YASSL */
39+
40+ #include <openssl/md5.h>
41+
42+ #define MY_MD5_HASH (digest , buf , len ) \
43+ do { \
44+ MD5_CTX ctx; \
45+ MD5_Init (&ctx); \
46+ MD5_Update (&ctx, buf, len); \
47+ MD5_Final (digest, &ctx); \
48+ } while (0)
49+
50+ #endif /* HAVE_YASSL */
51+
52+ #else /* HAVE_YASSL || HAVE_OPENSSL */
53+ /* Fallback to the MySQL's implementation. */
54+
2555/* Unlike previous versions of this code, uint32 need not be exactly
2656 32 bits, merely 32 bits or more. Choosing a data type which is 32
2757 bits instead of 64 is not important; speed is considerably more
@@ -35,18 +65,15 @@ typedef struct {
3565 unsigned char in [64 ];
3666} my_MD5Context ;
3767
38- #ifdef __cplusplus
39- extern "C" {
40- #endif
68+ C_MODE_START
69+
4170void my_MD5Init (my_MD5Context * context );
4271void my_MD5Update (my_MD5Context * context ,
4372 unsigned char const * buf , unsigned len );
4473void my_MD5Final (unsigned char digest [16 ],
4574 my_MD5Context * context );
4675
47- #ifdef __cplusplus
48- }
49- #endif
76+ C_MODE_END
5077
5178#define MY_MD5_HASH (digest ,buf ,len ) \
5279do { \
@@ -56,4 +83,12 @@ do { \
5683 my_MD5Final (digest, &ctx); \
5784} while (0)
5885
59- #endif /* MY_MD__INCLUDED */
86+ #endif /* defined(HAVE_YASSL) || defined(HAVE_OPENSSL) */
87+
88+ C_MODE_START
89+
90+ void compute_md5_hash (char * digest , const char * buf , int len );
91+
92+ C_MODE_END
93+
94+ #endif /* MY_MD5_INCLUDED */
0 commit comments