aes_prepareenckey(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 either AES_KEYSIZE_128, AES_KEYSIZE_192, or AES_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 🌈

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