crypto_cipher_setkey(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… crypto_cipher_setkey πŸ’…

okay so bestie, welcome to crypto_cipher_setkey(9) β€” that's section 9 of the Kernel API Manual, and yes we're in kernel-land now, put your seatbelt on πŸŽ€


✨ NAME ✨

crypto_cipher_setkey β€” set key for cipher πŸ”‘


🌸 SYNOPSIS 🌸

int crypto_cipher_setkey (struct crypto_cipher *tfm , const u8 *key ,
unsigned int keylen );

that's literally the whole signature, no cap. three things go in, one int comes out πŸ’–


πŸ¦‹ ARGUMENTS πŸ¦‹

  • tfm β€” the cipher handle, aka your main character struct, the struct crypto_cipher * you're working with 🫢
  • key β€” the buffer holding the key. that's it, that's the buffer, const u8 *
  • keylen β€” length of the key in bytes, an unsigned int, very demure, very mindful

πŸ‘‘ DESCRIPTION πŸ‘‘

so the way this works: the caller-provided key gets set for the single block cipher referenced by the cipher handle. one key, one cipher, slay ✨

note note note πŸŽ€ the key length determines the cipher type. like, it literally decides who the cipher is that day.

many block ciphers implement different cipher modes depending on the key size β€” the iconic example being AES-128 vs AES-192 vs. AES-256 πŸ”₯ so when you provide a 16 byte key for an AES cipher handle, AES-128 is performed. periodt. 16 bytes = AES-128, that's the vibe check πŸ’…


🌈 RETURN 🌈

  • 0 β€” yay! the setting of the key was successful πŸŽ‰
  • < 0 β€” uh oh bestie, an error occurred 😭 (literally anything less than zero)

🧚 SEE ALSO 🧚

go read all of them, iykyk πŸ¦‹


okay that's the whole page, mwah πŸ’‹ big kiss to ./include/crypto/internal, dated October 2026, filed under crypto_cipher_setkey(9) β€” and that's on periodt πŸ’œπŸŽ€

πŸ“¦ where this page comes from