aes_prepareenckey(9)
π aes_prepareenckey(9) β Kernel API Manual π
okay so bestie, welcome to the glow-up era of aes_prepareenckey π
this one lives in the Kernel API Manual and it's genuinely such a slay little function β it sets you up an AES key for encryption only, no decryption, no drama.
β¨ NAME β¨
aes_prepareenckey β prepare an AES key for encryption-only π
πΈ SYNOPSIS πΈ
int aes_prepareenckey (struct aes_enckey *key , const u8 *in_key ,
size_t key_len );
like, look at her. three args. icon behavior.
π¦ ARGUMENTS π¦
keyβ (output) the key structure you're gonna initialize π this is where the magic lands.in_keyβ the raw AES key, straight up, no filter.key_lenβ length of the raw key in bytes. should be eitherAES_KEYSIZE_128,AES_KEYSIZE_192, orAES_KEYSIZE_256. those three, bestie. no other vibes accepted.
π DESCRIPTION π
so what does she actually do? this prepares an AES key for only the encryption direction of the block cipher. that's the whole assignment, and she eats every time π₯
typically that means expanding the raw key into only the standard round keys β which means you end up with a struct about half the size of struct aes_key. smaller struct, same main character energy.
β οΈ okay this part is important, don't scroll past it: the caller is responsible for zeroizing both the struct aes_enckey and the raw key once they're no longer needed. that's on you, not her. take care of your secrets fr fr π
and here's the lil plot twist that's actually lowkey iconic β even though the resulting prepared key only supports AES encryption, it can still be used for decrypting in a mode of operation that uses AES in only the encryption (forward) direction. counter mode is the example. so yeah, she's encryption-only but she's still showing up for the decrypt shift when the mode says so ππ
π RETURN π
0on success π-EINVALif the given key length is invalid π«
and that's literally it β no other errors are possible, so if your callers always pass a valid key length, they don't need to check for errors at all. no error-checking anxiety required. she's low-maintenance. π«Ά
β CONTEXT β
Any context. she does not gatekeep, she's welcome everywhere π
π SEE ALSO π
Kernel file ./include/crypto/aes.h struct aes_enckey(9), struct aes_key(9), aes_expandkey(9), aes_preparekey(9), aes_encrypt(9), aes_decrypt(9) β go read the whole friend group, they're all linked π
and that's the page!! brought to you by ./include/crypto, the October 2026 edition of aes_prepareenckey(9) β mwah, go zeroize your keys, ily, bye π§β¨
π¦ 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