STRUCT SHASH_ALG(9)
π 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β seestruct ahash_algupdateβ seestruct ahash_algfinalβ seestruct ahash_algfinupβ seestruct ahash_algdigestβ seestruct ahash_algexportβ seestruct ahash_algimportβ seestruct ahash_algexport_coreβ seestruct ahash_algimport_coreβ seestruct ahash_algsetkeyβ seestruct ahash_alginit_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 toinit_tfm, used to remove various changes set ininit_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 forshash_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β seestruct hash_alg_commonhalgβ seestruct 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:
- Kernel file
./include/crypto/hash.hMessage Digest Algorithm Definitions(9) struct ahash_alg(9)- Asynchronous Message Digest API(9)
crypto_alloc_ahash(9)crypto_free_ahash(9)crypto_has_ahash(9)crypto_ahash_blocksize(9)crypto_ahash_digestsize(9)crypto_ahash_statesize(9)crypto_ahash_reqtfm(9)crypto_ahash_reqsize(9)crypto_ahash_setkey(9)crypto_ahash_finup(9)crypto_ahash_final(9)crypto_ahash_digest(9)crypto_ahash_export(9)crypto_ahash_import(9)crypto_ahash_init(9)crypto_ahash_update(9)- Asynchronous Hash Request Handle(9)
ahash_request_set_tfm(9)ahash_request_alloc(9)ahash_request_free(9)ahash_request_set_callback(9)ahash_request_set_crypt(9)ahash_request_set_virt(9)- Synchronous Message Digest API(9)
crypto_alloc_shash(9)crypto_free_shash(9)crypto_shash_blocksize(9)crypto_shash_digestsize(9)crypto_shash_descsize(9)crypto_shash_setkey(9)crypto_shash_digest(9)crypto_shash_tfm_digest(9)crypto_shash_export(9)crypto_shash_import(9)crypto_shash_init(9)crypto_shash_finup(9)crypto_shash_update(9)crypto_shash_final(9)
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
- 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