hmac_sha256(9)
π hmac_sha256 β the kernel API manual, bestie edition π
Okay so real talk: this is hmac_sha256(9), and it lives in the Kernel API Manual. She's a one-shot girlie β you give her a key you already prepped and a blob of data, and she hands you back the HMAC-SHA256. No drama, no state, no nothing. β¨
πΈ NAME πΈ
hmac_sha256 β compute HMAC-SHA256 in one shot, using a prepared key
π¦ SYNOPSIS π¦
void hmac_sha256 (const struct hmac_sha256_key *key , const u8 *data ,
size_t data_len , u8 out[static SHA256_DIGEST_SIZE] );
π ARGUMENTS π
keyβ the prepared HMAC key. Like, prepared prepared. It's aconst struct hmac_sha256_key *and it must already be ready to go β no raw-key chaos here.dataβ the message data. Your actual payload, an array ofu8, hearts to it.data_lenβ the data length in bytes,size_tstyle, because the kernel is nothing if not precise.outβ (output) the resulting HMAC-SHA256 value. It'su8 out[static SHA256_DIGEST_SIZE]β the digest lands here and it's iconic. π
π§ DESCRIPTION π§
So here's the vibe check: if you're only using the key once, consider using hmac_sha256_usingrawkey instead. That's it, that's the whole note β she's telling you there's a shorter path if your key isn't sticking around for round two. π
π₯ CONTEXT π₯
Any context. Literally any. No locks, no sleep rules, no "only from process context" gatekeeping. Slay. π«Ά
π SEE ALSO π
Whole fam, all of them, no cap:
- Kernel file
./include/crypto/sha2.h struct sha224_ctx(9),sha224_init(9),sha224_update(9),sha224_final(9),sha224(9)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)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)struct hmac_sha256_key(9),struct hmac_sha256_ctx(9),hmac_sha256_preparekey(9),hmac_sha256_init(9),hmac_sha256_init_usingrawkey(9),hmac_sha256_update(9),hmac_sha256_final(9),hmac_sha256_usingrawkey(9)struct sha384_ctx(9),sha384_init(9),sha384_update(9),sha384_final(9),sha384(9)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)struct sha512_ctx(9),sha512_init(9),sha512_update(9),sha512_final(9),sha512(9)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)
That's the whole page, bestie β no crumbs left behind. π
Signed off from the./include/cryptodirectory, dated October 2026 βhmac_sha256(9)ate and left absolutely zero notes. π
π¦ 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