aes_preparekey(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 either AES_KEYSIZE_128, AES_KEYSIZE_192, or AES_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 ⭐

  • 0 on success πŸŽ‰
  • -EINVAL if 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 πŸ‘‘

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