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        int HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len,
19                      const EVP_MD *md);
20        int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len,
21                          const EVP_MD *md, ENGINE *impl);
22        int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
23        int 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.
42
43       HMAC_CTX_init() initialises a HMAC_CTX before first use. It must be
44       called.
45
46       HMAC_CTX_cleanup() erases the key and other data from the HMAC_CTX and
47       releases any associated resources. It must be called when an HMAC_CTX
48       is no longer required.
49
50       HMAC_cleanup() is an alias for HMAC_CTX_cleanup() included for back
51       compatibility with 0.9.6b, it is deprecated.
52
53       The following functions may be used if the message is not completely
54       stored in memory:
55
56       HMAC_Init() initializes a HMAC_CTX structure to use the hash function
57       evp_md and the key key which is key_len bytes long. It is deprecated
58       and only included for backward compatibility with OpenSSL 0.9.6b.
59
60       HMAC_Init_ex() initializes or reuses a HMAC_CTX structure to use the
61       function evp_md and key key. Either can be NULL, in which case the
62       existing one will be reused. HMAC_CTX_init() must have been called
63       before the first use of an HMAC_CTX in this function. N.B. HMAC_Init()
64       had this undocumented behaviour in previous versions of OpenSSL -
65       failure to switch to HMAC_Init_ex() in programs that expect it will
66       cause them to stop working.
67
68       HMAC_Update() can be called repeatedly with chunks of the message to be
69       authenticated (len bytes at data).
70
71       HMAC_Final() places the message authentication code in md, which must
72       have space for the hash function output.
73

RETURN VALUES

75       HMAC() returns a pointer to the message authentication code or NULL if
76       an error occurred.
77
78       HMAC_Init_ex(), HMAC_Update() and HMAC_Final() return 1 for success or
79       0 if an error occurred.
80
81       HMAC_CTX_init() and HMAC_CTX_cleanup() do not return values.
82

CONFORMING TO

84       RFC 2104
85

SEE ALSO

87       sha(3), evp(3)
88

HISTORY

90       HMAC(), HMAC_Init(), HMAC_Update(), HMAC_Final() and HMAC_cleanup() are
91       available since SSLeay 0.9.0.
92
93       HMAC_CTX_init(), HMAC_Init_ex() and HMAC_CTX_cleanup() are available
94       since OpenSSL 0.9.7.
95
96       HMAC_Init_ex(), HMAC_Update() and HMAC_Final() did not return values in
97       versions of OpenSSL before 1.0.0.
98
99
100
1011.0.1e                            2013-02-11                           hmac(3)
Impressum