[#HMAC]
= HMAC
:mrdocs:

Compute an HMAC over `data` using digest `evp&lowbar;md` and key `key&period;`

== Synopsis

Declared in `&lt;openssl&sol;hmac&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
unsigned char*
HMAC(
    xref:EVP_MD.adoc[EVP&lowbar;MD] const* evp&lowbar;md,
    void const* key,
    int key&lowbar;len,
    unsigned char const* data,
    size&lowbar;t data&lowbar;len,
    unsigned char* md,
    unsigned int* md&lowbar;len);
----

== Description

Uses the default OSSL&lowbar;LIB&lowbar;CTX&semi; prefer EVP&lowbar;Q&lowbar;mac() when a library context is required&period;

== Return Value

Pointer to the MAC bytes (`md` or the static buffer), or NULL on error&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *evp&lowbar;md*
| Message digest (e&period;g&period; EVP&lowbar;sha256())&semi; variable&hyphen;length digests such as SHAKE are not supported&period;
| *key*
| HMAC key material, or NULL when `key&lowbar;len` is 0&period;
| *key&lowbar;len*
| Length of `key` in bytes&period;
| *data*
| Message bytes to authenticate&period;
| *data&lowbar;len*
| Number of bytes at `data&period;`
| *md*
| Output buffer of at least EVP&lowbar;MAX&lowbar;MD&lowbar;SIZE bytes, or NULL to use a static buffer (not thread&hyphen;safe)&period;
| *md&lowbar;len*
| Receives the MAC length in bytes&semi; may be NULL&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
