| Use Case | Command | Description |
|---|---|---|
| Create HMAC key | EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, NULL, key, keylen) |
Create a new HMAC key from raw bytes |
| Create CMAC key | EVP_PKEY_new_raw_private_key(EVP_PKEY_CMAC, NULL, key, keylen) |
Create a new CMAC key from raw bytes |
| Set MAC key parameter | EVP_PKEY_CTX_set_params(ctx, params) |
Set the "priv" (OSSL_PKEY_PARAM_PRIV_KEY) parameter |
| Set CMAC cipher | EVP_PKEY_CTX_set_params(ctx, params) |
Set the "cipher" (OSSL_PKEY_PARAM_CIPHER) parameter for CMAC |
| Generate MAC key | EVP_PKEY_keygen(ctx, &pkey) |
Create a provider key object with supplied raw key value |
| Preferred MAC API | EVP_MAC_init(3) |
Use EVP_MAC APIs instead of EVP_PKEY for new code |
The HMAC and CMAC key types are implemented in OpenSSL's default and FIPS providers. Additionally the Siphash and Poly1305 key types are implemented in the default provider. Performing MAC operations via an EVP_PKEY is considered legacy and are only available for backwards compatibility purposes and for a restricted set of algorithms. The preferred way of performing MAC operations is via the EVP_MAC APIs. See EVP_MAC_init(3).
For further details on using EVP_PKEY based MAC keys see EVP_SIGNATURE-HMAC(7), EVP_SIGNATURE-Siphash(7), EVP_SIGNATURE-Poly1305(7) or EVP_SIGNATURE-CMAC(7).
All the MAC keytypes support the following parameters.
As well as the parameters described above, the CMAC keytype additionally supports the following parameters.
MAC key generation is unusual in that no new key is actually generated. Instead a new provider side key object is created with the supplied raw key value. This is done for backwards compatibility with previous versions of OpenSSL.
In addition to the common MAC key generation parameters, the CMAC key generation additionally recognises the following.
EVP_KEYMGMT(3), EVP_PKEY(3), provider-keymgmt(7)
Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.
Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-04 12:53 @216.73.217.98
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format