2003-08-13 05:53:07 +04:00
# ifndef MD5_H
# define MD5_H
2012-02-06 20:47:25 +04:00
2003-08-13 05:53:07 +04:00
# ifndef HEADER_MD5_H
/* Try to avoid clashes with OpenSSL */
# define HEADER_MD5_H
# endif
2013-05-21 18:14:19 +04:00
# if defined(HAVE_BSD_MD5_H)
/* Try to avoid clashes with BSD MD5 implementation (on linux) */
2012-02-06 20:47:25 +04:00
# include <bsd/md5.h>
2013-05-21 18:14:19 +04:00
# elif defined(HAVE_SYS_MD5_H)
/* Try to avoid clashes with BSD MD5 implementation (on BSD) */
# include <sys/md5.h>
2012-03-13 03:21:28 +04:00
/* Try to use CommonCrypto on Mac as otherwise we can get MD5Final twice */
2013-05-21 18:14:19 +04:00
# elif defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H)
2012-03-13 03:21:28 +04:00
# include <CommonCrypto/CommonDigest.h>
2014-01-07 18:55:57 +04:00
# define MD5_CTX CC_MD5_CTX
2012-03-13 03:21:28 +04:00
# define MD5Init(c) CC_MD5_Init(c)
# define MD5Update(c,d,l) CC_MD5_Update(c,d,l)
# define MD5Final(m, c) CC_MD5_Final((unsigned char *)m,c)
# define MD5Context CC_MD5state_st
2012-02-06 20:47:25 +04:00
# else
2012-02-06 19:53:52 +04:00
typedef struct MD5Context {
2004-05-25 20:24:13 +04:00
uint32_t buf [ 4 ] ;
uint32_t bits [ 2 ] ;
2004-05-29 12:11:46 +04:00
uint8_t in [ 64 ] ;
2012-02-06 19:53:52 +04:00
} MD5_CTX ;
2003-08-13 05:53:07 +04:00
2012-02-06 19:53:52 +04:00
# define MD5_DIGEST_LENGTH 16
void MD5Init ( MD5_CTX * context ) ;
void MD5Update ( MD5_CTX * context , const uint8_t * buf ,
2006-04-24 18:53:03 +04:00
size_t len ) ;
2012-02-06 19:53:52 +04:00
void MD5Final ( uint8_t digest [ MD5_DIGEST_LENGTH ] , MD5_CTX * context ) ;
2013-05-21 18:14:19 +04:00
# endif /* HAVE_*MD5_H */
2003-08-13 05:53:07 +04:00
# endif /* !MD5_H */