1hmac(3)                             OpenSSL                            hmac(3)
2
3
4

NAME

6       HMAC, HMAC_Init, HMAC_Update, HMAC_Final, HMAC_cleanup - HMAC message
7       authentication code
8

SYNOPSIS

10        #include <openssl/hmac.h>
11
12        unsigned char *HMAC(const EVP_MD *evp_md, const void *key,
13                      int key_len, const unsigned char *d, int n,
14                      unsigned char *md, unsigned int *md_len);
15
16        void HMAC_CTX_init(HMAC_CTX *ctx);
17
18        void HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len,
19                      const EVP_MD *md);
20        void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len,
21                          const EVP_MD *md, ENGINE *impl);
22        void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
23        void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
24
25        void HMAC_CTX_cleanup(HMAC_CTX *ctx);
26        void HMAC_cleanup(HMAC_CTX *ctx);
27

DESCRIPTION

29       HMAC is a MAC (message authentication code), i.e. a keyed hash function
30       used for message authentication, which is based on a hash function.
31
32       HMAC() computes the message authentication code of the n bytes at d
33       using the hash function evp_md and the key key which is key_len bytes
34       long.
35
36       It places the result in md (which must have space for the output of the
37       hash function, which is no more than EVP_MAX_MD_SIZE bytes).  If md is
38       NULL, the digest is placed in a static array.  The size of the output
39       is placed in md_len, unless it is NULL.
40
41       evp_md can be EVP_sha1(), EVP_ripemd160() etc.  key and evp_md may be
42       NULL if a key and hash function have been set in a previous call to
43       HMAC_Init() for that HMAC_CTX.
44
45       HMAC_CTX_init() initialises a HMAC_CTX before first use. It must be
46       called.
47
48       HMAC_CTX_cleanup() erases the key and other data from the HMAC_CTX and
49       releases any associated resources. It must be called when an HMAC_CTX
50       is no longer required.
51
52       HMAC_cleanup() is an alias for HMAC_CTX_cleanup() included for back
53       compatibility with 0.9.6b, it is deprecated.
54
55       The following functions may be used if the message is not completely
56       stored in memory:
57
58       HMAC_Init() initializes a HMAC_CTX structure to use the hash function
59       evp_md and the key key which is key_len bytes long. It is deprecated
60       and only included for backward compatibility with OpenSSL 0.9.6b.
61
62       HMAC_Init_ex() initializes or reuses a HMAC_CTX structure to use the
63       function evp_md and key key. Either can be NULL, in which case the
64       existing one will be reused. HMAC_CTX_init() must have been called
65       before the first use of an HMAC_CTX in this function. N.B. HMAC_Init()
66       had this undocumented behaviour in previous versions of OpenSSL - fail‐
67       ure to switch to HMAC_Init_ex() in programs that expect it will cause
68       them to stop working.
69
70       HMAC_Update() can be called repeatedly with chunks of the message to be
71       authenticated (len bytes at data).
72
73       HMAC_Final() places the message authentication code in md, which must
74       have space for the hash function output.
75

RETURN VALUES

77       HMAC() returns a pointer to the message authentication code.
78
79       HMAC_CTX_init(), HMAC_Init_ex(), HMAC_Update(), HMAC_Final() and
80       HMAC_CTX_cleanup() do not return values.
81

CONFORMING TO

83       RFC 2104
84

SEE ALSO

86       sha(3), evp(3)
87

HISTORY

89       HMAC(), HMAC_Init(), HMAC_Update(), HMAC_Final() and HMAC_cleanup() are
90       available since SSLeay 0.9.0.
91
92       HMAC_CTX_init(), HMAC_Init_ex() and HMAC_CTX_cleanup() are available
93       since OpenSSL 0.9.7.
94
95
96
970.9.8b                            2006-01-30                           hmac(3)
Impressum