HMAC(3) Library Functions Manual HMAC(3)

NAME

hmaccompute a key-Hash Message Authentication Code

LIBRARY

Standard C Library (libc, -lc)

SYNOPSIS

#include <stdlib.h>
ssize_t
hmac(const char *hname, const void *key, size_t klen, const void *text, size_t tlen, void *digest, size_t dlen);

DESCRIPTION

The hmac() function computes the key-Hash Message Authentication Code per RFC 2104 and places the result in digest writing up to dlen bytes. The actual number of bytes that would be written is returned.
The hash functions supported are: md2, md4, md5, rmd160, sha1, sha224, sha256, sha384, and sha512.

RETURN VALUES

The hmac() function returns -1 if the hname is not found. Otherwise the actual length of the digest string is returned (which could be bigger or smaller than dlen). This length depends on the hashing function selected.

SEE ALSO

md2(3), md4(3), md5(3), rmd160(3), sha1(3), sha2(3)

STANDARDS

RFC 2104.

NOTES

The maximum digest length has been extended from 64 to 128 bytes to handle SHA2.

HISTORY

The hmac() function appeared in NetBSD 8.
July 1, 2016 NetBSD 8.2