3 * This implementation of MD5 comes from the XYSSL project.
9 * \brief MD5 context structure
12 unsigned long total
[2]; /*!< number of bytes processed */
13 unsigned long state
[4]; /*!< intermediate digest state */
14 unsigned char buffer
[64]; /*!< data block being processed */
16 unsigned char ipad
[64]; /*!< HMAC: inner padding */
17 unsigned char opad
[64]; /*!< HMAC: outer padding */
25 * \brief MD5 context setup
27 * \param ctx context to be initialized
29 void md5_starts(md5_context
* ctx
);
32 * \brief MD5 process buffer
34 * \param ctx MD5 context
35 * \param input buffer holding the data
36 * \param ilen length of the input data
38 void md5_update(md5_context
* ctx
, unsigned char *input
, int ilen
);
41 * \brief MD5 final digest
43 * \param ctx MD5 context
44 * \param output MD5 checksum result
46 void md5_finish(md5_context
* ctx
, unsigned char output
[16]);
49 * \brief Output = MD5( input buffer )
51 * \param input buffer holding the data
52 * \param ilen length of the input data
53 * \param output MD5 checksum result
55 void md5(unsigned char *input
, int ilen
, unsigned char output
[16]);
58 * \brief Output = MD5( file contents )
60 * \param path input file name
61 * \param output MD5 checksum result
63 * \return 0 if successful, 1 if fopen failed,
64 * or 2 if fread failed
66 int md5_file(char *path
, unsigned char output
[16]);
69 * \brief MD5 HMAC context setup
71 * \param ctx HMAC context to be initialized
72 * \param key HMAC secret key
73 * \param keylen length of the HMAC key
75 void md5_hmac_starts(md5_context
* ctx
, unsigned char *key
,
79 * \brief MD5 HMAC process buffer
81 * \param ctx HMAC context
82 * \param input buffer holding the data
83 * \param ilen length of the input data
85 void md5_hmac_update(md5_context
* ctx
, unsigned char *input
,
89 * \brief MD5 HMAC final digest
91 * \param ctx HMAC context
92 * \param output MD5 HMAC checksum result
94 void md5_hmac_finish(md5_context
* ctx
, unsigned char output
[16]);
97 * \brief Output = HMAC-MD5( hmac key, input buffer )
99 * \param key HMAC secret key
100 * \param keylen length of the HMAC key
101 * \param input buffer holding the data
102 * \param ilen length of the input data
103 * \param output HMAC-MD5 result
105 void md5_hmac(unsigned char *key
, int keylen
,
106 unsigned char *input
, int ilen
,
107 unsigned char output
[16]);
110 * \brief Checkup routine
112 * \return 0 if successful, or 1 if the test failed
114 int md5_self_test(int verbose
);