STRUCT SHASH_ALG(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct shash_alg(9) πŸ’–

okay so bestie, welcome to the Kernel API Manual ✨ β€” this is the page for struct shash_alg, and it's literally the blueprint for a synchronous message digest definition πŸŽ€. That's the whole NAME section, no cap, and it's iconic.


🌸 SYNOPSIS 🌸

here's the struct in all her main character glory β€” copy it exactly, she does NOT like being retyped wrong:

struct shash_alg {
    int (*init)(struct shash_desc *desc);
    int (*update)(struct shash_desc *desc, const u8 *data, unsigned int len);
    int (*final)(struct shash_desc *desc, u8 *out);
    int (*finup)(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out);
    int (*digest)(struct shash_desc *desc, const u8 *data, unsigned int len, u8 *out);
    int (*export)(struct shash_desc *desc, void *out);
    int (*import)(struct shash_desc *desc, const void *in);
    int (*export_core)(struct shash_desc *desc, void *out);
    int (*import_core)(struct shash_desc *desc, const void *in);
    int (*setkey)(struct crypto_shash *tfm, const u8 *key, unsigned int keylen);
    int (*init_tfm)(struct crypto_shash *tfm);
    void (*exit_tfm)(struct crypto_shash *tfm);
    unsigned int descsize;
    union {
      struct HASH_ALG_COMMON;
      struct hash_alg_common halg;
    };
};

like… look at her. so many function pointers. she's booked and busy πŸ’…


πŸ¦‹ Members πŸ¦‹

a bunch of these are just "go read the other struct, bestie" β€” and honestly? respect. here's the full rundown:

  • init β€” see struct ahash_alg
  • update β€” see struct ahash_alg
  • final β€” see struct ahash_alg
  • finup β€” see struct ahash_alg
  • digest β€” see struct ahash_alg
  • export β€” see struct ahash_alg
  • import β€” see struct ahash_alg
  • export_core β€” see struct ahash_alg
  • import_core β€” see struct ahash_alg
  • setkey β€” see struct ahash_alg
  • init_tfm β€” Initialize the cryptographic transformation object πŸ”₯. This function is called only once at the instantiation time, right after the transformation context was allocated. In case the cryptographic hardware has some special requirements which need to be handled by software, this function shall check for the precise requirement of the transformation and put any software fallbacks in place. (so: hardware's got quirks β†’ software picks up the slack, periodt)
  • exit_tfm β€” Deinitialize the cryptographic transformation object. This is a counterpart to init_tfm, used to remove various changes set in init_tfm. it's giving cleanup era 🧹✨
  • descsize β€” Size of the operational state for the message digest 🫢. This state size is the memory size that needs to be allocated for shash_desc.__ctx. do NOT forget to actually allocate it, bestie, that's the whole vibe check.
  • {unnamed_union} β€” anonymous πŸ™ˆ (yes, that's genuinely all it says, she's mysterious like that)
  • HASH_ALG_COMMON β€” see struct hash_alg_common
  • halg β€” see struct hash_alg_common

πŸŽ€ SEE ALSO πŸŽ€

grab a snack, this list is LONG and we're not skipping a single one 😭 β€” every reference, exactly as written:


and that's the page, bestie!! 🌈 this one came from ./include/crypto and the version stamp on it says October 2026 β€” so yeah, she's fresh πŸ’œ mwah, go hash something responsibly 🫢✨

πŸ“¦ where this page comes from