CMAC_CTX(3ossl)
π CMAC_CTX β the 3ossl OpenSSL glow-up
Okay bestie, sit down, grab your boba π β this is the OpenSSL manual page for CMAC_CTX and its whole friend group, and yes, they're all lowkey retired π. This page lives in section 3ossl of the OpenSSL manuals, so iykyk.
β¨ NAME β¨
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, CMAC_resume β the whole squad that makes cipher-based message authentication codes happen π
πΈ SYNOPSIS πΈ
#include <openssl/cmac.h>
β οΈ Heads up bestie: the following functions have been deprecated since OpenSSL 3.0, and can be disabled entirely by definingOPENSSL_API_COMPATwith a suitable version value, seeopenssl_user_macros(7). So likeβ¦ they still work but they're giving "senior who won't retire" energy π
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 here's the tea β: the low-level MAC functions documented on this page are deprecated. Like, not "deprecated" in a cute way β in an actual "please move on" way. Applications should use the new EVP_MAC(3) interface instead. Specifically, use these besties for your MAC operations, periodt:
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 π
Or, alternatively, for a single-step MAC computation, use the EVP_Q_mac(3) function. One and done, no cap π
The CMAC_CTX type is a structure used for the provision of CMAC (Cipher-based Message Authentication Code) operations. That's the whole vibe.
CMAC_CTX_new() creates a new CMAC_CTX structure and returns a pointer to it. Fresh out the box, main character energy π
CMAC_CTX_cleanup() resets the CMAC_CTX structure, clearing any internal data but not freeing the structure itself. So it wipes the slate but keeps the body, iconic β¨
CMAC_CTX_free() frees the CMAC_CTX structure and any associated resources. If the argument is NULL, no action is taken β very "no thoughts, head empty" of it π
CMAC_CTX_get0_cipher_ctx() returns a pointer to the internal EVP_CIPHER_CTX structure within the CMAC_CTX. Peek inside, it's giving backstage pass ποΈ
CMAC_CTX_copy() copies the state from one CMAC_CTX structure to another. Twin energy fr fr π«Ά
CMAC_Init() initializes the CMAC_CTX structure for a new CMAC calculation with the specified key, key length, and cipher type. Optionally, an ENGINE can be provided. Basically setting up the whole situation π₯
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 data in chunks, it eats every time π
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 by poutlen. To determine the required buffer size, call with out set to NULL, which stores only the length in poutlen. Allocate a buffer of this size and call CMAC_Final() again with the allocated buffer to retrieve the MAC. Two-step slay: first ask how big, then actually do it π
CMAC_resume() resumes a previously finalized CMAC calculation, allowing additional data to be processed and a new MAC to be generated. It's the "wait, one more thing" of functions π
π RETURN VALUES π
CMAC_CTX_new()returns a pointer to a newCMAC_CTXstructure orNULLif an error occurs.NULL= it's not you, it's the error π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()return 1 for success or 0 if an error occurs. Binary queen β either ate or didn't π
β 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). Move on bestie, the new interface is right there and it's gorgeous π
π 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, hope it ate πβ¨ β courtesy of the OpenSSL crew, version 3.5.6, dated 2026-04-07, and that's the cute little sign-off, mwah π«Άπ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms