crypto_aead_setkey(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… crypto_aead_setkey(9) β€” the Kernel API Manual, but make it make sense

okay so bestie, welcome to crypto_aead_setkey(9) 🌸 β€” yes that's a kernel function, yes it lives in section 9 of the manual, and yes we're gonna get through it together. It's giving "small function, big responsibilities" and honestly? Iconic.


✨ NAME ✨

crypto_aead_setkey β€” set the key for a cipher πŸ”‘


πŸŽ€ SYNOPSIS πŸŽ€

int crypto_aead_setkey (struct crypto_aead *tfm , const u8 *key ,
       unsigned int keylen );

That's the whole signature, no cap. Returns an int, takes three things. Let's meet them πŸ’–


πŸ¦‹ ARGUMENTS πŸ¦‹

  • tfm β€” the cipher handle 🫢 literally the AEAD object you're working with. This is the main character.
  • key β€” the buffer holding the key 🌈 it's a const u8 *, so it's a "look but don't touch" situation.
  • keylen β€” the length of the key in bytes ⭐ an unsigned int, because negative key lengths are not a vibe.

πŸ”₯ DESCRIPTION πŸ”₯

So here's the tea β˜• β€” the key you provide gets set for the AEAD referenced by the cipher handle. That's it, that's the job. You hand over the key, it becomes the key. Slay.

But wait, there's a plot twist πŸŒ€ Note that the key length determines the cipher type. Lowkey the most important sentence on this whole page, ngl.

Many block ciphers implement different cipher modes depending on the key size β€” think AES-128 vs AES-192 vs. AES-256 πŸ‘‘. So when you provide a 16 byte key for an AES cipher handle, AES-128 is what gets performed. Sixteen bytes in, AES-128 out. The key length is doing all the talking, fr fr πŸ’…

🚨 no cap, read that again if you skimmed it: the length of your key changes which cipher you're actually running. That is not a detail, that is THE detail.

πŸ’€ RETURN πŸ’€

  • 0 β€” the setting of the key was successful πŸŽ‰ periodt, we love a clean zero.
  • < 0 β€” an error occurred 😭 something went wrong, go check your inputs.

🌸 SEE ALSO 🌸

Bestie, buckle up, this list is long and every single one is here because I would never do you like that πŸ™ˆ

Like, the whole AEAD friend group 🫢 go read them, they're all iconic in their own way.


🧚 a lil sign-off 🧚

this page came from ./include/crypto, dated October 2026, and it's crypto_aead_setkey(9) babes β€” go set some keys, mind your keylen, and remember: sixteen bytes means AES-128 whether you planned for it or not πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from