[#EVP_Q_mac]
= EVP&lowbar;Q&lowbar;mac
:mrdocs:

One&hyphen;shot MAC computation&colon; fetch the algorithm, process `data,` and write the tag&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
unsigned char*
EVP&lowbar;Q&lowbar;mac(
    xref:OSSL_LIB_CTX.adoc[OSSL&lowbar;LIB&lowbar;CTX]* libctx,
    char const* name,
    char const* propq,
    char const* subalg,
    xref:OSSL_PARAM.adoc[OSSL&lowbar;PARAM] const* params,
    void const* key,
    size&lowbar;t keylen,
    unsigned char const* data,
    size&lowbar;t datalen,
    unsigned char* out,
    size&lowbar;t outsize,
    size&lowbar;t* outlen);
----

== Return Value

Pointer to `out` on success, or NULL on failure&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *libctx*
| Library context used to fetch the MAC, or NULL for the default&period;
| *name*
| MAC algorithm name (for example &quot;HMAC&quot; or &quot;CMAC&quot;)&period;
| *propq*
| Property query for the MAC fetch, or NULL&period;
| *subalg*
| Optional sub&hyphen;algorithm name (for example the HMAC digest), or NULL&period;
| *params*
| Optional OSSL&lowbar;PARAM array for algorithm setup, or NULL&period;
| *key*
| MAC key octets&period;
| *keylen*
| Length of `key` in bytes&period;
| *data*
| Message bytes to authenticate&period;
| *datalen*
| Length of `data` in bytes&period;
| *out*
| Buffer that receives the MAC, or NULL to query the required size via `outlen&period;`
| *outsize*
| Size of `out` in bytes when `out` is non&hyphen;NULL&period;
| *outlen*
| On success, receives the number of MAC bytes written (or required if `out` is NULL)&period;
|===


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