[#EVP_PKEY_CTX_set_mac_key]
= EVP&lowbar;PKEY&lowbar;CTX&lowbar;set&lowbar;mac&lowbar;key
:mrdocs:

Set the MAC key bytes on a keygen&sol;paramgen EVP&lowbar;PKEY&lowbar;CTX (for example HMAC or Poly1305)&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
EVP&lowbar;PKEY&lowbar;CTX&lowbar;set&lowbar;mac&lowbar;key(
    xref:EVP_PKEY_CTX.adoc[EVP&lowbar;PKEY&lowbar;CTX]* ctx,
    unsigned char const* key,
    int keylen);
----

== Return Value

1 on success, or a negative value &sol; 0 on failure&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *ctx*
| Key generation context for a MAC algorithm&period;
| *key*
| MAC key octets&semi; may be NULL when `keylen` is 0&period;
| *keylen*
| Length of `key` in bytes&period;
|===


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