1/* hmac-md5.h -- HMAC_MD5 functions
2 */
3
4#ifndef HMAC_MD5_H
5#define HMAC_MD5_H 1
6
7#define HMAC_MD5_SIZE 16
8
9/* intermediate MD5 context */
10typedef struct HMAC_MD5_CTX_s {
11    MD5_CTX ictx, octx;
12} HMAC_MD5_CTX;
13
14/* intermediate HMAC state
15 *  values stored in network byte order (Big Endian)
16 */
17typedef struct HMAC_MD5_STATE_s {
18    UINT4 istate[4];
19    UINT4 ostate[4];
20} HMAC_MD5_STATE;
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/* One step hmac computation
27 *
28 * digest may be same as text or key
29 */
30void _sasl_hmac_md5(const unsigned char *text, int text_len,
31		    const unsigned char *key, int key_len,
32		    unsigned char digest[HMAC_MD5_SIZE]);
33
34/* create context from key
35 */
36void _sasl_hmac_md5_init(HMAC_MD5_CTX *hmac,
37			 const unsigned char *key, int key_len);
38
39/* precalculate intermediate state from key
40 */
41void _sasl_hmac_md5_precalc(HMAC_MD5_STATE *hmac,
42			    const unsigned char *key, int key_len);
43
44/* initialize context from intermediate state
45 */
46void _sasl_hmac_md5_import(HMAC_MD5_CTX *hmac, HMAC_MD5_STATE *state);
47
48#define _sasl_hmac_md5_update(hmac, text, text_len) _sasl_MD5Update(&(hmac)->ictx, (text), (text_len))
49
50/* finish hmac from intermediate result.  Intermediate result is zeroed.
51 */
52void _sasl_hmac_md5_final(unsigned char digest[HMAC_MD5_SIZE],
53			  HMAC_MD5_CTX *hmac);
54
55#ifdef __cplusplus
56}
57#endif
58
59#endif /* HMAC_MD5_H */
60