crypto/ahash.c
Source file repositories/reference/linux-study-clean/crypto/ahash.c
File Facts
- System
- Linux kernel
- Corpus path
crypto/ahash.c- Extension
.c- Size
- 25344 bytes
- Lines
- 1024
- Domain
- Kernel Services
- Bucket
- crypto
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/scatterwalk.hlinux/cryptouser.hlinux/err.hlinux/kernel.hlinux/mm.hlinux/module.hlinux/scatterlist.hlinux/slab.hlinux/seq_file.hlinux/string.hlinux/string_choices.hnet/netlink.hhash.h
Detected Declarations
function crypto_ahash_block_onlyfunction crypto_ahash_final_nonzerofunction crypto_ahash_need_fallbackfunction ahash_op_donefunction hash_walk_nextfunction hash_walk_new_entryfunction crypto_hash_walk_firstfunction crypto_hash_walk_donefunction algorithmfunction shash_ahash_updatefunction shash_ahash_finupfunction shash_ahash_digestfunction crypto_exit_ahash_using_shashfunction crypto_init_ahash_using_shashfunction ahash_nosetkeyfunction ahash_set_needkeyfunction crypto_ahash_setkeyfunction ahash_do_req_chainfunction crypto_ahash_initfunction ahash_save_reqfunction ahash_restore_reqfunction ahash_update_finishfunction ahash_update_donefunction crypto_ahash_updatefunction ahash_finup_finishfunction ahash_finup_donefunction crypto_ahash_finupfunction crypto_ahash_digestfunction ahash_def_finup_done2function ahash_def_finup_finish1function ahash_def_finup_done1function ahash_def_finupfunction crypto_ahash_export_corefunction crypto_ahash_exportfunction crypto_ahash_import_corefunction crypto_ahash_importfunction crypto_ahash_exit_tfmfunction crypto_ahash_init_tfmfunction crypto_ahash_extsizefunction crypto_ahash_free_instancefunction crypto_ahash_reportfunction crypto_ahash_showfunction crypto_grab_ahashfunction crypto_has_ahashfunction crypto_hash_alg_has_setkeyfunction ahash_default_export_corefunction ahash_default_import_corefunction ahash_prepare_alg
Annotated Snippet
if (unlikely(err)) {
crypto_ahash_set_flags(tfm,
crypto_shash_get_flags(shash) &
CRYPTO_TFM_NEED_KEY);
return err;
}
} else {
struct ahash_alg *alg = crypto_ahash_alg(tfm);
int err;
err = alg->setkey(tfm, key, keylen);
if (!err && crypto_ahash_need_fallback(tfm))
err = crypto_ahash_setkey(crypto_ahash_fb(tfm),
key, keylen);
if (unlikely(err)) {
ahash_set_needkey(tfm, alg);
return err;
}
}
crypto_ahash_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
return 0;
}
EXPORT_SYMBOL_GPL(crypto_ahash_setkey);
static int ahash_do_req_chain(struct ahash_request *req,
int (*const *op)(struct ahash_request *req))
{
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
int err;
if (crypto_ahash_req_virt(tfm) || !ahash_request_isvirt(req))
return (*op)(req);
if (crypto_ahash_statesize(tfm) > HASH_MAX_STATESIZE)
return -ENOSYS;
if (!crypto_ahash_need_fallback(tfm))
return -ENOSYS;
if (crypto_hash_no_export_core(tfm))
return -ENOSYS;
{
u8 state[HASH_MAX_STATESIZE];
if (op == &crypto_ahash_alg(tfm)->digest) {
ahash_request_set_tfm(req, crypto_ahash_fb(tfm));
err = crypto_ahash_digest(req);
goto out_no_state;
}
err = crypto_ahash_export(req, state);
ahash_request_set_tfm(req, crypto_ahash_fb(tfm));
err = err ?: crypto_ahash_import(req, state);
if (op == &crypto_ahash_alg(tfm)->finup) {
err = err ?: crypto_ahash_finup(req);
goto out_no_state;
}
err = err ?:
crypto_ahash_update(req) ?:
crypto_ahash_export(req, state);
ahash_request_set_tfm(req, tfm);
return err ?: crypto_ahash_import(req, state);
out_no_state:
ahash_request_set_tfm(req, tfm);
return err;
}
}
int crypto_ahash_init(struct ahash_request *req)
{
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
if (likely(tfm->using_shash))
return crypto_shash_init(prepare_shash_desc(req, tfm));
if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
return -ENOKEY;
if (ahash_req_on_stack(req) && ahash_is_async(tfm))
return -EAGAIN;
if (crypto_ahash_block_only(tfm)) {
u8 *buf = ahash_request_ctx(req);
buf += crypto_ahash_reqsize(tfm) - 1;
*buf = 0;
}
return crypto_ahash_alg(tfm)->init(req);
Annotation
- Immediate include surface: `crypto/scatterwalk.h`, `linux/cryptouser.h`, `linux/err.h`, `linux/kernel.h`, `linux/mm.h`, `linux/module.h`, `linux/scatterlist.h`, `linux/slab.h`.
- Detected declarations: `function crypto_ahash_block_only`, `function crypto_ahash_final_nonzero`, `function crypto_ahash_need_fallback`, `function ahash_op_done`, `function hash_walk_next`, `function hash_walk_new_entry`, `function crypto_hash_walk_first`, `function crypto_hash_walk_done`, `function algorithm`, `function shash_ahash_update`.
- Atlas domain: Kernel Services / crypto.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.