hmac_sha256_preparekey(9)
π hmac_sha256_preparekey β from the Kernel API Manual, bestie π«Ά
okay so picture this: you're deep in the kernel, you've got a raw key just sitting there looking like a random pile of bytes, and you need it to become a proper HMAC-SHA256 key structure. that's literally this function's whole job. it's the glow-up station for your key. the manual calls it hmac_sha256_preparekey(9) and it lives in the Kernel API Manual, and yes it's giving "small function, big responsibility" energy β¨
πΈ NAME πΈ
hmac_sha256_preparekey β prepare a key for HMAC-SHA256 π
π SYNOPSIS π
void hmac_sha256_preparekey (struct hmac_sha256_key *key , const u8
*raw_key , size_t raw_key_len );
β¨ ARGUMENTS β¨
keyβ (output) the key structure you're initializing. this is the makeover target, the one that comes out looking iconic πraw_keyβ the raw HMAC-SHA256 key, aka the before picture π¦raw_key_lenβ the key length in bytes. and listen β all key lengths are supported. no gatekeeping, no minimum, no maximum, everyone's invited to the party π
β οΈ NOTE β οΈ
not me reminding you again but β the caller is responsible for zeroizing both the struct hmac_sha256_key and the raw key once they are no longer needed. that's on you, bestie, not on the function. please don't leave your secrets lying around, it's not the vibe ππ
π§ CONTEXT π§
Any context. yeah, she's flexible like that. no special requirements, no drama, no "must not sleep" asterisks. slay π
π₯ SEE ALSO π₯
the whole extended friend group, fr fr. starting with the kernel file, then everybody by family π
- Kernel file
./include/crypto/sha2.hπ - the sha224 girlies:
struct sha224_ctx(9),sha224_init(9),sha224_update(9),sha224_final(9),sha224(9) - the hmac_sha224 crew:
struct hmac_sha224_key(9),struct hmac_sha224_ctx(9),hmac_sha224_preparekey(9),hmac_sha224_init(9),hmac_sha224_init_usingrawkey(9),hmac_sha224_update(9),hmac_sha224_final(9),hmac_sha224(9),hmac_sha224_usingrawkey(9) - the sha256 squad:
struct sha256_ctx(9),sha256_init(9),sha256_update(9),sha256_final(9),sha256(9),sha256_finup_2x(9),sha256_finup_2x_is_optimized(9) - the hmac_sha256 main characters (hi bestie):
struct hmac_sha256_key(9),struct hmac_sha256_ctx(9),hmac_sha256_init(9),hmac_sha256_init_usingrawkey(9),hmac_sha256_update(9),hmac_sha256_final(9),hmac_sha256(9),hmac_sha256_usingrawkey(9) - the sha384 delegation:
struct sha384_ctx(9),sha384_init(9),sha384_update(9),sha384_final(9),sha384(9) - the hmac_sha384 delegation (with love):
struct hmac_sha384_key(9),struct hmac_sha384_ctx(9),hmac_sha384_preparekey(9),hmac_sha384_init(9),hmac_sha384_init_usingrawkey(9),hmac_sha384_update(9),hmac_sha384_final(9),hmac_sha384(9),hmac_sha384_usingrawkey(9) - the sha512 big sisters:
struct sha512_ctx(9),sha512_init(9),sha512_update(9),sha512_final(9),sha512(9) - and the hmac_sha512 finale:
struct hmac_sha512_key(9),struct hmac_sha512_ctx(9),hmac_sha512_preparekey(9),hmac_sha512_init(9),hmac_sha512_init_usingrawkey(9),hmac_sha512_update(9),hmac_sha512_final(9),hmac_sha512(9),hmac_sha512_usingrawkey(9)
okay that's the whole page, no crumbs left behind π this one's sourced from ./include/crypto, dated October 2026, and that's the tea. mwah, go prep those keys responsibly, ily ππ
π¦ 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