aes_ccm_init(9)
β¨ aes_ccm_init β Kernel API Manual energy β¨
okay so bestie, welcome to the <cyan>Kernel API Manual</cyan> page for aes_ccm_init π
this is the one that sets up your whole AES-CCM situation before you start streaming data through it, and yes it's giving "responsible main character" because you have to do math before you begin. iconic behavior honestly π
πΈ NAME πΈ
aes_ccm_init β Initialize context for incremental AES-CCM encryption or decryption π¦
like literally, it's the "get your ctx ready" girl of the AES-CCM friend group β¨
π SYNOPSIS π
int aes_ccm_init (struct aes_ccm_ctx *ctx , u64 data_len , u64 ad_len ,
const u8 *nonce , size_t nonce_len , const struct aes_ccm_key *key );
π«Ά ARGUMENTS π«Ά
ctxβ the context you're initializing. this is your girl, you're waking her up πdata_lenβ how many bytes of data you're gonna en/decrypt, in bytes. and ngl there's a ceiling: at most2^(120 - (8 * nonce_len)) - 1. do not test her, she means it πad_lenβ the length in bytes of the associated data you're gonna hand over later. yes, later. yes, you still have to say now. we'll get to that π«nonceβ the nonce β¨ and listen, IMPORTANT: all(key, nonce)pairs used for encryption MUST be distinct. like, MUST MUST. no repeats, periodt. π₯nonce_lenβ how long the nonce is, in bytes: between7and13inclusive, bestie. that's the whole range. don't color outside those lines πkeyβ the key, already prepared usingaes_ccm_preparekey. and heads up, because this is the sneaky part: a pointer to the key is saved in the context, so the key must live at least as long as the context. so don't go freeing your key and leaving your ctx out here orphaned ππ
β¨ DESCRIPTION β¨
so here's the vibe check: unlike AES-GCM, AES-CCM requires the total lengths of the associated data and the en/decrypted data to be known during initialization. that's not a suggestion, that's the whole thing. callers MUST ensure that these lengths are correct. no cap. π
if this function returns success, the context should be zeroized at the end of its lifetime. normally that happens in aes_ccm_encrypt_final or aes_ccm_decrypt_final β those two handle it for you, they're the responsible ones π«Ά β but if you're a caller that abandons a context without finalizing it, you'd better explicitly zeroize it yourself. clean up after yourself, we're not animals π
IMPORTANT: callers that are decrypting MUST NOT assume that any decrypted or associated data is authentic until the authentication tag has been verified. like, literally do not trust that data yet. this incremental API exists solely to support callers that can't efficiently use the one-shot functions due to using a nonlinear data layout. that's the only reason. she's a specialist, not a generalist π
π¦ incremental AES-CCM encryption β do it in this order, bestie π¦
aes_ccm_initaes_ccm_auth_update(any number of times)aes_ccm_encrypt_update(any number of times)aes_ccm_encrypt_final
π incremental AES-CCM decryption β same energy, different middle π
aes_ccm_initaes_ccm_auth_update(any number of times)aes_ccm_decrypt_update(any number of times)aes_ccm_decrypt_final
like the way that it's the same shape but the update/final pair swaps out π so clean. so symmetric. we love a consistent pipeline π
π§ CONTEXT π§
Any context. that's it. that's the whole section. a queen of brevity π
β RETURN β
0on success π slay-EINVALifnonce_lenis invalid β you went outside7β13, shame π₯-EOVERFLOWifdata_lenis too large for the selectednonce_lenβ she's too big for her boots, pick a different nonce length π
π SEE ALSO π
Kernel file ./include/crypto/aes-ccm.h and her whole friend group:
struct aes_ccm_key(9)struct aes_ccm_ctx(9)aes_ccm_preparekey(9)aes_ccm_encrypt(9)aes_ccm_decrypt(9)aes_ccm_auth_update(9)aes_ccm_encrypt_update(9)aes_ccm_decrypt_update(9)aes_ccm_encrypt_final(9)aes_ccm_decrypt_final(9)
go read them, iykyk π
okay that's the whole page, mwah π«Ά this one came from ./include/crypto and it's dated October 2026 β so like, freshly stamped, very demure, very mindful. bye bestie, go zeroize your contexts πΈβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms