3 * This implementation of MD5 comes from the XYSSL project.
9 * \brief MD5 context structure
13 unsigned long total
[2]; /*!< number of bytes processed */
14 unsigned long state
[4]; /*!< intermediate digest state */
15 unsigned char buffer
[64]; /*!< data block being processed */
17 unsigned char ipad
[64]; /*!< HMAC: inner padding */
18 unsigned char opad
[64]; /*!< HMAC: outer padding */
27 * \brief MD5 context setup
29 * \param ctx context to be initialized
31 void md5_starts( md5_context
*ctx
);
34 * \brief MD5 process buffer
36 * \param ctx MD5 context
37 * \param input buffer holding the data
38 * \param ilen length of the input data
40 void md5_update( md5_context
*ctx
, unsigned char *input
, int ilen
);
43 * \brief MD5 final digest
45 * \param ctx MD5 context
46 * \param output MD5 checksum result
48 void md5_finish( md5_context
*ctx
, unsigned char output
[16] );
51 * \brief Output = MD5( input buffer )
53 * \param input buffer holding the data
54 * \param ilen length of the input data
55 * \param output MD5 checksum result
57 void md5( unsigned char *input
, int ilen
, unsigned char output
[16] );
60 * \brief Output = MD5( file contents )
62 * \param path input file name
63 * \param output MD5 checksum result
65 * \return 0 if successful, 1 if fopen failed,
66 * or 2 if fread failed
68 int md5_file( char *path
, unsigned char output
[16] );
71 * \brief MD5 HMAC context setup
73 * \param ctx HMAC context to be initialized
74 * \param key HMAC secret key
75 * \param keylen length of the HMAC key
77 void md5_hmac_starts( md5_context
*ctx
, unsigned char *key
, int keylen
);
80 * \brief MD5 HMAC process buffer
82 * \param ctx HMAC context
83 * \param input buffer holding the data
84 * \param ilen length of the input data
86 void md5_hmac_update( md5_context
*ctx
, unsigned char *input
, int ilen
);
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
);