Sortix nightly manual
This manual documents Sortix nightly, a development build that has not been officially released. You can instead view this document in the latest official manual.
|HMAC(3)||Library Functions Manual||HMAC(3)|
HMAC message authentication code
#include <openssl/hmac.h>unsigned char *
HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d, size_t n, unsigned char *md, unsigned int *md_len); HMAC_CTX *
HMAC_CTX_reset(HMAC_CTX *ctx); void
HMAC_CTX_free(HMAC_CTX *ctx); int
HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md, ENGINE *impl); int
HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md); int
HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len); int
HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len); int
HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); void
HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); const EVP_MD *
HMAC_CTX_get_md(const HMAC_CTX *ctx); size_t
HMAC_size(const HMAC_CTX *e);
HMAC() computes the message authentication code of the n bytes at d using the hash function evp_md and the key key which is key_len bytes long. It places the result in md, which must have space for the output of the hash function, which is no more than
EVP_MAX_MD_SIZEbytes. If md is
NULL, the digest is placed in a static array, which is not thread safe. The size of the output is placed in md_len, unless it is
NULL. evp_md can be EVP_sha1(3), EVP_ripemd160(3), etc.
HMAC_CTX_new() allocates and initializes a new HMAC_CTX object.
HMAC_CTX_reset() zeroes and re-initializes ctx and associated resources, making it suitable for new computations as if it was deleted with
HMAC_CTX_free() and newly created with
HMAC_CTX_free() erases the key and other data from ctx, releases any associated resources, and finally frees ctx itself. The following functions may be used if the message is not completely stored in memory:
HMAC_Init_ex() sets up or reuses ctx to use the hash function evp_md and the key key. Either can be
NULL, in which case the existing one is reused. The ctx must have been created with
HMAC_CTX_new() before the first use in this function. If
HMAC_Init_ex() is called with a
NULLkey but evp_md is neither
NULLnor the same as the previous digest used by ctx, then an error is returned because reuse of an existing key with a different digest is not supported.
HMAC_Init() is a deprecated wrapper around
HMAC_Init_ex() which performs no longer useful extra initialization in some circumstances.
HMAC_Update() can be called repeatedly with chunks of the message to be authenticated (len bytes at data).
HMAC_Final() places the message authentication code in md, which must have space for the hash function output.
HMAC_CTX_copy() copies all of the internal state from sctx into dctx.
HMAC_CTX_set_flags() applies the specified flags to the internal EVP_MD_CTX objects. Possible flag values
EVP_MD_CTX_FLAG_*are defined in
HMAC_size() returns the length in bytes of the underlying hash function output. It is implemented as a macro.
HMAC() returns a pointer to the message authentication code or
NULLif an error occurred.
HMAC_CTX_new() returns a pointer to the new HMAC_CTX object or
NULLif an error occurred.
HMAC_CTX_copy() return 1 for success or 0 if an error occurred.
HMAC_CTX_get_md() returns the message digest that was previously set for ctx with
NULLif none was set.
HMAC_size() returns the length in bytes of the underlying hash function output or 0 on error. CMAC_Init(3), EVP_DigestInit(3)
HMAC_size() first appeared in SSLeay 0.9.0 and have been available since OpenBSD 2.4.
HMAC_Init_ex() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.
HMAC_CTX_set_flags() first appeared in OpenSSL 0.9.7f and have been available since OpenBSD 3.8.
HMAC_CTX_copy() first appeared in OpenSSL 1.0.0 and has been available since OpenBSD 4.9.
HMAC_CTX_get_md() first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.3.
|January 25, 2022||Debian|