4 /* Optionally MD5 support can depend on external implementation when linking
5 * against a SSL library that supports it. */
6 #if defined(CONFIG_OWN_LIBC)
8 #elif defined(CONFIG_OPENSSL)
9 #include <openssl/md5.h>
10 #elif defined(CONFIG_GNUTLS_OPENSSL_COMPAT)
11 #include <gnutls/openssl.h>
16 /* GNU TLS doesn't define this */
17 #ifndef MD5_DIGEST_LENGTH
18 #define MD5_DIGEST_LENGTH 16
21 #define MD5_HEX_DIGEST_LENGTH (MD5_DIGEST_LENGTH * 2)
23 typedef unsigned char md5_digest_bin_T
[MD5_DIGEST_LENGTH
];
24 typedef unsigned char md5_digest_hex_T
[MD5_HEX_DIGEST_LENGTH
];
32 /* The interface for digesting several chunks of data. To compute the message
33 * digest of a chunk of bytes, declare an md5_context structure, pass it to
34 * init_md5(), call update_md5() as needed on buffers full of bytes, and then
35 * call done_md5(), which will fill a supplied 16-byte array with the digest. */
36 void init_md5(struct md5_context
*context
);
37 void update_md5(struct md5_context
*context
, const unsigned char *data
, unsigned long length
);
38 void done_md5(struct md5_context
*context
, md5_digest_bin_T digest
);
40 /** Digest the passed @a data with the given length and stores the MD5
41 * digest in the @a digest parameter. */
43 digest_md5(const unsigned char *data
, unsigned long length
, md5_digest_bin_T digest
);
46 /** @name Provide compatibility with the OpenSSL interface:
49 typedef struct md5_context MD5_CTX
;
50 #define MD5_Init(context) init_md5(context)
51 #define MD5_Update(context, data, len) update_md5(context, data, len)
52 #define MD5_Final(md5, context) done_md5(context, md5)
53 #define MD5(data, len, md5) digest_md5(data, len, md5)
56 #endif /* CONFIG_MD5 */