aes_ctr(9)
π aes_ctr(9) β like, the AES-CTR en/decryption page, bestie π
okay so this is aes_ctr from the Kernel API Manual, and no cap it's a short one but every single word is doing WORK. let's get into it β¨
β¨ NAME β¨
aes_ctr β AES-CTR en/decryption. that's it. that's the vibe. π
πΈ SYNOPSIS πΈ
void aes_ctr (u8 *dst , const u8 *src , size_t len , u8 ctr[static
AES_BLOCK_SIZE] , aes_encrypt_arg key );
like, look at her. iconic signature. π
π¦ ARGUMENTS π¦
dstβ the destination buffer, bestie. it can be in-place OR out-of-place, both are valid, it's flexible like that π . but for other overlaps? the behavior is unspecified β so like, don't, and if you do, that's on you πsrcβ the source data. the raw material. the moment. β¨lenβ number of bytes to en/decrypt. how much we're cookin' π₯ctrβ the counter. it will be incremented byceil(len / AES_BLOCK_SIZE). yes,ceilβ they're rounding UP, not down, don't get cute πkeyβ the key, already prepared usingaes_preparekeyoraes_prepareenckey. already prepared!! do NOT hand this function a raw un-prepped key, that's not the assignment π ββοΈ
π DESCRIPTION π
so this implements AES in counter mode with a 128-bit big endian counter. big endian. she's old school like that π§
this exists only for use by the implementation of modes built on top of CTR (e.g., GCM and CCM) and some legacy protocols that use CTR mode directly. so like, if you're just some random caller showing up to use this directly, read the next part VERY carefully π
callers are expected to know how to use CTR mode appropriately, including choosing (key, counter) pairs appropriately to avoid keystream reuse. that's the whole ballgame, fr fr β the function is not gonna hold your hand and it is not gonna check. keystream reuse is giving π and the manpage is trusting you to not do it.
this supports incremental en/decryption π«Ά. the length of each non-final chunk must be a multiple of AES_BLOCK_SIZE, and the updated ctr must be passed in each time. so like: chunk, feed back the new counter, chunk again, feed back the new counter. keep the chain going, bestie π
β οΈ real talk: this is lowkey a footgun if you don't already know CTR mode. the "callers are expected to know" line is doing a LOT of heavy lifting. know your mode, choose your (key, counter) pairs right, and please please please don't reuse the keystream. π
π CONTEXT π
any context. literally any. she's flexible. slay. β
π SEE ALSO π
- Kernel file
./include/crypto/aes-ctr.h aes_xctr(9)β her cousin π
π so yeah that's the whole page β short, sweet, and absolutely unhinged about the keystream reuse thing, as she should be.
this lil gem lives in ./include/crypto, dated October 2026, and it's aes_ctr(9) signing off β mwah π stay safe out there and don't reuse your keystreams π«Άβ¨
π¦ 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