crypto_skcipher_setkey(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ crypto_skcipher_setkey(9) β€” the Kernel API Manual, bestie edition πŸŽ€

okay so real talk: this is a page from the Kernel API Manual (yes, that one, section 9, the kernel-flavored section, iykyk) and it's all about handing a cipher its key. it's short, it's sweet, it's giving "tiny function, huge consequences" energy. let's go ✨


🌸 NAME 🌸

crypto_skcipher_setkey β€” set key for cipher

like… that's literally the whole job. it sets the key. for the cipher. slay πŸ’…


✨ SYNOPSIS ✨

int crypto_skcipher_setkey (struct crypto_skcipher *tfm , const u8 *key
, unsigned int keylen );

that's the whole signature, no cap. returns an int, takes three things, we'll get to those 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • tfm β€” the cipher handle. your main character struct. the thing you're setting a key on πŸ’–
  • key β€” a buffer holding the key. the actual bytes. the secret sauce πŸ™ˆ
  • keylen β€” length of the key in bytes. not bits, not vibes, bytes. ⭐

🌈 DESCRIPTION 🌈

so the caller hands over a key, and that key gets set for the skcipher referenced by the cipher handle. simple as that, bestie. the handle knows which cipher it is, you bring the key, done πŸŽ€

but here's the iconic part πŸ‘‘ β€” the key length determines the cipher type. like, the size of the key you pass is literally what decides which flavor you get. many block ciphers implement different cipher modes depending on the key size, such as 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. sixteen bytes in, AES-128 out. that's the vibe check, and it passed πŸ’…βœ¨

🚨 lowkey important: don't assume the handle picks the mode for you β€” the length of the key is the choice. 16 bytes β†’ AES-128. periodt.

πŸ”₯ RETURN πŸ”₯

  • 0 β€” the setting of the key was successful. we love to see it πŸ₯³
  • < 0 β€” an error occurred. something went wrong, go check it 😭

🧚 SEE ALSO 🧚

so many friends in the cast list, fr fr. all of these live in the kernel file ./include/crypto/skcipher.h:


and that's the page, bestie πŸ’– this lil icon lives in ./include/crypto, and the version we're reading is dated October 2026 β€” so go set some keys, pick your key length on purpose, and remember: keylen is the whole personality here πŸ“πŸ§šπŸ’œ

πŸ“¦ where this page comes from