aes_ccm_encrypt(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… aes_ccm_encrypt(9) β€” the Kernel API Manual, bestie edition πŸŽ€

okay so. this is aes_ccm_encrypt, and it lives in the Kernel API Manual (yes, the kernel, we're fancy now). it encrypts a message with AES-CCM. that's the whole vibe. ✨


🌸 NAME 🌸

aes_ccm_encrypt β€” encrypt a message with AES-CCM. that's it, that's the function, she's iconic and she encrypts. πŸ”₯


πŸ¦‹ SYNOPSIS πŸ¦‹

int aes_ccm_encrypt (u8 *dst , const u8 *src , size_t data_len , u8
*authtag , const u8 *ad , size_t ad_len , const u8 *nonce , size_t
nonce_len , const struct aes_ccm_key *key );

look at her. nine arguments. she's that girl. πŸ’…


πŸ’– ARGUMENTS πŸ’–

  • dst β€” the destination ciphertext data, where the encrypted glow-up lands. she can be in-place or out-of-place, no drama. but for other overlaps? the behavior is unspecified, so like... don't. πŸ™ˆ
  • src β€” the source plaintext data. the before picture. πŸŽ€
  • data_len β€” length of plaintext in bytes (and yes, also the ciphertext length excluding the tag). the cap is at most 2^(120 - (8 * nonce_len)) - 1. write that down, it's giving math. 😭
  • authtag β€” the output authentication tag. her length is the authtag_len that was passed to aes_ccm_preparekey. usually protocols using AES-CCM put the tag at the end of the ciphertext, and in that case you should set this to dst + data_len β€” and dst must have room for the tag. plan ahead, bestie. 🫢
  • ad β€” the associated data. the plus-one that doesn't get encrypted but is very much part of the group chat. πŸ’œ
  • ad_len β€” length of associated data in bytes. ⭐
  • nonce β€” the nonce. and listen: all (key, nonce) pairs used MUST be distinct. MUST. it's in caps, so you know it's serious. no cap. 🚨
  • nonce_len β€” length of the nonce in bytes: between 7 and 13 inclusive. outside that range? she's not doing it. πŸ’€
  • key β€” the key, already prepared using aes_ccm_preparekey. don't hand her a raw key, she's not doing that today. 🧚

πŸ“ CONTEXT πŸ“

Any context. literally anywhere, she doesn't mind, lowkey the most flexible friend in the crypto header. 🌈


πŸ‘‘ RETURN πŸ‘‘

  • 0 on success β€” ate, no notes πŸ’…
  • -EINVAL if nonce_len is invalid β€” the nonce length vibe check failed πŸ™ˆ
  • -EOVERFLOW if data_len is too large for the selected nonce_len β€” too much data, not enough nonce energy 😭

✨ SEE ALSO ✨

Kernel file ./include/crypto/aes-ccm.h, plus the whole aes-ccm friend group β€” struct aes_ccm_key(9), struct aes_ccm_ctx(9), aes_ccm_preparekey(9), aes_ccm_decrypt(9), aes_ccm_init(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 say hi, they're all in the same header and they're all slaying. πŸ¦‹πŸ’–


and that's the page!! brought to you by ./include/crypto, October 2026 β€” mwah, love u, go encrypt responsibly πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from