CMAC_CTX(3SSL)
π CMAC_CTX π
okay bestie, so in the OpenSSL manual, this page covers CMAC_CTX, CMAC_CTX_new, CMAC_CTX_cleanup, CMAC_CTX_free, CMAC_CTX_get0_cipher_ctx, CMAC_CTX_copy, CMAC_Init, CMAC_Update, CMAC_Final, and CMAC_resume β aka the whole girl gang that makes cipher-based message authentication codes β¨
β¨ SYNOPSIS β¨
#include <openssl/cmac.h>
heads up queen: the following functions have been deprecated since OpenSSL 3.0, and you can disable them entirely by defining OPENSSL_API_COMPAT with a suitable version value β peep openssl_user_macros(7) for the deets.
typedef struct CMAC_CTX_st CMAC_CTX;
CMAC_CTX *CMAC_CTX_new(void);
void CMAC_CTX_cleanup(CMAC_CTX *ctx);
void CMAC_CTX_free(CMAC_CTX *ctx);
EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);
int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);
int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
const EVP_CIPHER *cipher, ENGINE *impl);
int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);
int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);
int CMAC_resume(CMAC_CTX *ctx);
πΈ DESCRIPTION πΈ
ngl, the low-level MAC functions documented on this page are deprecated. Like, retired. Gone girl era. Applications should use the new EVP_MAC(3) interface instead. Specifically, bestie, use these for MAC operations:
EVP_MAC_CTX_new(3)β to create a new MAC context πEVP_MAC_CTX_free(3)β to free the MAC contextEVP_MAC_init(3)β to initialize the MAC contextEVP_MAC_update(3)β to update the MAC with dataEVP_MAC_final(3)β to finalize the MAC and retrieve the output
Alternatively, for a single-step MAC computation, use the EVP_Q_mac(3) function. one and done, no drama π
The CMAC_CTX type is a structure used for the provision of CMAC (Cipher-based Message Authentication Code) operations.
CMAC_CTX_new()β creates a newCMAC_CTXstructure and returns a pointer to it. fresh out the box β¨CMAC_CTX_cleanup()β resets theCMAC_CTXstructure, clearing any internal data but not freeing the structure itself. it's giving "reset, not delete" πCMAC_CTX_free()β frees theCMAC_CTXstructure and any associated resources. If the argument isNULL, no action is taken. no argument, no problem π«ΆCMAC_CTX_get0_cipher_ctx()β returns a pointer to the internalEVP_CIPHER_CTXstructure within theCMAC_CTX.CMAC_CTX_copy()β copies the state from oneCMAC_CTXstructure to another. twin behavior, lowkey π―CMAC_Init()β initializes theCMAC_CTXstructure for a new CMAC calculation with the specified key, key length, and cipher type. And bestie,implmust beNULL. periodt.CMAC_Update()β processes data to be included in the CMAC calculation. This function can be called multiple times to update the context with additional data. feed it, feed it, feed it πCMAC_Final()β finalizes the CMAC calculation and retrieves the resulting MAC value. The output is stored in the provided buffer, and the length is stored in the variable pointed to bypoutlen. To determine the required buffer size, call it withoutset toNULL, which stores only the length inpoutlen. Then allocate a buffer of this size and callCMAC_Final()again with the allocated buffer to retrieve the MAC. two-step queen πCMAC_resume()β resumes a previously finalized CMAC calculation, allowing additional data to be processed and a new MAC to be generated. she's back π¦
π RETURN VALUES π
CMAC_CTX_new()β returns a pointer to a newCMAC_CTXstructure, orNULLif an error occurs.CMAC_CTX_get0_cipher_ctx()β returns a pointer to the internalEVP_CIPHER_CTXstructure, orNULLif an error occurs.CMAC_CTX_copy(),CMAC_Init(),CMAC_Update(),CMAC_Final()andCMAC_resume()β return1for success or0if an error occurs.
π°οΈ HISTORY π°οΈ
All functions described here were deprecated in OpenSSL 3.0. For replacements, see EVP_MAC_CTX_new(3), EVP_MAC_CTX_free(3), EVP_MAC_init(3), EVP_MAC_update(3), and EVP_MAC_final(3). glow-up arc, honestly π
π COPYRIGHT π
Copyright 2024 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>.
okay that's the whole page, bestie π this was OpenSSL 4.0.3, dated 2026-09-29 β go forth and CMAC responsibly, mwah π«Άβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms