Retry only for https protocol
[elinks.git] / src / util / md5.h
blobf23caf8b7e9450e663f76cbc5f32da4e2797ca25
1 #ifndef EL__UTIL_MD5_H
2 #define EL__UTIL_MD5_H
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)
7 #define CONFIG_MD5 1
8 #elif defined(CONFIG_OPENSSL)
9 #include <openssl/md5.h>
10 #elif defined(CONFIG_GNUTLS_OPENSSL_COMPAT)
11 #include <gnutls/openssl.h>
12 #else
13 #define CONFIG_MD5 1
14 #endif
16 /* GNU TLS doesn't define this */
17 #ifndef MD5_DIGEST_LENGTH
18 #define MD5_DIGEST_LENGTH 16
19 #endif
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];
26 struct md5_context {
27 uint32_t buf[4];
28 uint32_t bits[2];
29 unsigned char in[64];
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. */
42 unsigned char *
43 digest_md5(const unsigned char *data, unsigned long length, md5_digest_bin_T digest);
45 #ifdef CONFIG_MD5
46 /** @name Provide compatibility with the OpenSSL interface:
47 * @{ */
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)
55 /** @} */
56 #endif /* CONFIG_MD5 */
58 #endif