CMAC_CTX(3ossl)
π CMAC_CTX(3ossl) β the OpenSSL glow-up nobody asked for but everyone needed
okay so bestie, welcome to the CMAC_CTX(3ossl) page, aka the OpenSSL manual for the old-school low-level CMAC crew. Real talk: this whole squad is deprecated, but you still deserve to know what they do, so let's get into it β¨
πΈ SYNOPSIS
#include <openssl/cmac.h>
The following functions have been deprecated since OpenSSL 3.0, and can be disabled entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7).
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 β¨
so first things first, bestie: the low-level MAC functions documented on this page are deprecated. Not like "oops deprecated" β like, go use the new thing deprecated. Applications should use the new EVP_MAC(3) interface. π«Ά Specifically, utilize the following functions for MAC operations:
EVP_MAC_CTX_new(3)to create a new MAC context.EVP_MAC_CTX_free(3)to free the MAC context.EVP_MAC_init(3)to initialize the MAC context.EVP_MAC_update(3)to update the MAC with data.EVP_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 energy, we love her π
The CMAC_CTX type is a structure used for the provision of CMAC (Cipher-based Message Authentication Code) operations. it's giving "the container where all the CMAC lore lives" π
CMAC_CTX_new()β creates a newCMAC_CTXstructure and returns a pointer to it. fresh start, main character energy πCMAC_CTX_cleanup()β resets theCMAC_CTXstructure, clearing any internal data but not freeing the structure itself. self-care, not goodbye π§CMAC_CTX_free()β frees theCMAC_CTXstructure and any associated resources. If the argument isNULL, no action is taken. no notes, honestly πCMAC_CTX_get0_cipher_ctx()β returns a pointer to the internalEVP_CIPHER_CTXstructure within theCMAC_CTX. peek behind the curtain, iykyk π¦CMAC_CTX_copy()β copies the state from oneCMAC_CTXstructure to another. twins fr fr π―CMAC_Init()β initializes theCMAC_CTXstructure for a new CMAC calculation with the specified key, key length, and cipher type. Optionally, anENGINEcan be provided. setting the vibe before the party β¨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 her, she's hungry π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 withoutset toNULL, which stores only the length inpoutlen. Allocate a buffer of this size and callCMAC_Final()again with the allocated buffer to retrieve the MAC. two-step reveal, iconic π₯CMAC_resume()β resumes a previously finalized CMAC calculation, allowing additional data to be processed and a new MAC to be generated. she's back from her little break, and honestly? obsessed π
π RETURN VALUES π
CMAC_CTX_new()β returns a pointer to a newCMAC_CTXstructure orNULLif an error occurs. π when it'sNULL, it'sNULLCMAC_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. classic 1-or-0 slay π«Ά
π 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). they've moved on and honestly so should you, but no pressure bestie π
lowkey important: these are deprecated. not dangerous, just old news β but don't go building new stuff on them, okay? π«Ά
π 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>.
and that's the whole page, bestie π this was CMAC_CTX(3ossl) from 3.5.0, dated 2026-09-25 β go forth, use EVP_MAC(3), and stay iconic πΈππ¦
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms