aes_preparekey(9)
β¨ aes_preparekey(9) β¨
the kernel api manual page you didn't know you needed π
okay so bestie, this is aes_preparekey, a function from the Kernel API Manual, and honestly? she's a little workhorse and she deserves her flowers πΈ
π NAME π
aes_preparekey β prepare an AES key for encryption and decryption, both directions, no cap π
π SYNOPSIS π
int aes_preparekey (struct aes_key *key , const u8 *in_key , size_t
key_len );
that's the whole vibe. three args, one int back. iconic signature fr π«Ά
π¦ ARGUMENTS π¦
keyβ (output) the key structure you're initializing. she's the destination, the main character, the one getting filled in β¨in_keyβ the raw AES key. the actual secret juice π₯key_lenβ length of the raw key, in bytes. should be eitherAES_KEYSIZE_128,AES_KEYSIZE_192, orAES_KEYSIZE_256. like, pick one of those three, that's the whole menu π
π DESCRIPTION π
so what she does is: this prepares an AES key for both the encryption and decryption directions of the block cipher. both! multitalented! π
typically that involves expanding the raw key into both the standard round keys and the Equivalent Inverse Cipher round keys β but ngl, some architecture-specific implementations don't do the full expansion here. so like, don't assume, iykyk π§
important!! bestie, the caller is responsible for zeroizing both the struct aes_key and the raw key once they're no longer needed. that's on you, not on her. please don't leave secrets lying around π
and if you don't need decryption support at all? then use aes_prepareenckey instead β why do the full expansion when you only need one direction, right? π
β RETURN β
0on success π-EINVALif the given key length is invalid π
and that's literally it β no other errors are possible. so if you're a caller who always passes a valid key length, you don't even need to check for errors. slay, low-maintenance queen π
πΈ CONTEXT πΈ
Any context. literally wherever, whenever, she's ready π¦
π SEE ALSO π
- Kernel file
./include/crypto/aes.h struct aes_enckey(9)struct aes_key(9)aes_expandkey(9)aes_prepareenckey(9)aes_encrypt(9)aes_decrypt(9)
the whole friend group, go say hi π«Άβ¨
okay that's the page!! this little gem lives in ./include/crypto and the version/date on the tin is October 2026 β mwah, go encrypt something responsibly, 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