xref: /titanic_41/usr/src/lib/libsasl/include/hmac-md5.h (revision 7c2fbfb345896881c631598ee3852ce9ce33fb07)
1 /*
2  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 /* hmac-md5.h -- HMAC_MD5 functions
9  */
10 
11 #ifndef HMAC_MD5_H
12 #define HMAC_MD5_H 1
13 
14 #define HMAC_MD5_SIZE 16
15 
16 #ifdef _SUN_SDK_
17 #ifndef SASLPLUG_H
18 #include <sasl/saslplug.h>
19 #endif
20 #else
21 /* intermediate MD5 context */
22 typedef struct HMAC_MD5_CTX_s {
23     MD5_CTX ictx, octx;
24 } HMAC_MD5_CTX;
25 
26 /* intermediate HMAC state
27  *  values stored in network byte order (Big Endian)
28  */
29 typedef struct HMAC_MD5_STATE_s {
30     UINT4 istate[4];
31     UINT4 ostate[4];
32 } HMAC_MD5_STATE;
33 #endif /* _SUN_SDK */
34 
35 /* One step hmac computation
36  *
37  * digest may be same as text or key
38  */
39 void _sasl_hmac_md5(const unsigned char *text, int text_len,
40 		    const unsigned char *key, int key_len,
41 		    unsigned char digest[HMAC_MD5_SIZE]);
42 
43 /* create context from key
44  */
45 void _sasl_hmac_md5_init(HMAC_MD5_CTX *hmac,
46 			 const unsigned char *key, int key_len);
47 
48 /* precalculate intermediate state from key
49  */
50 void _sasl_hmac_md5_precalc(HMAC_MD5_STATE *hmac,
51 			    const unsigned char *key, int key_len);
52 
53 /* initialize context from intermediate state
54  */
55 void _sasl_hmac_md5_import(HMAC_MD5_CTX *hmac, HMAC_MD5_STATE *state);
56 
57 #define _sasl_hmac_md5_update(hmac, text, text_len) _sasl_MD5Update(&(hmac)->ictx, (text), (text_len))
58 
59 /* finish hmac from intermediate result.  Intermediate result is zeroed.
60  */
61 void _sasl_hmac_md5_final(unsigned char digest[HMAC_MD5_SIZE],
62 			  HMAC_MD5_CTX *hmac);
63 
64 #endif /* HMAC_MD5_H */
65