crypto_aead_setkey(9)
π 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 aconst u8 *, so it's a "look but don't touch" situation.keylenβ the length of the key in bytes β anunsigned 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 π
- Kernel file
./include/crypto/aead.h - Authenticated Encryption With Associated Data (AEAD) Cipher API(9)
struct aead_request(9)struct aead_alg(9)crypto_alloc_aead(9)crypto_free_aead(9)crypto_has_aead(9)crypto_aead_ivsize(9)crypto_aead_authsize(9)crypto_aead_blocksize(9)crypto_aead_setauthsize(9)crypto_aead_encrypt(9)crypto_aead_decrypt(9)- Asynchronous AEAD Request Handle(9)
crypto_aead_reqsize(9)aead_request_set_tfm(9)aead_request_alloc(9)aead_request_free(9)aead_request_set_callback(9)aead_request_set_crypt(9)aead_request_set_ad(9)
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
- 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