include/crypto/hash.h
Source file repositories/reference/linux-study-clean/include/crypto/hash.h
File Facts
- System
- Linux kernel
- Corpus path
include/crypto/hash.h- Extension
.h- Size
- 37096 bytes
- Lines
- 1048
- Domain
- Repository Root And Misc
- Bucket
- include
- Inferred role
- Repository Root And Misc: implementation source
- Status
- source implementation candidate
Why This File Exists
Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/crypto.hlinux/scatterlist.hlinux/slab.hlinux/string.h
Detected Declarations
struct crypto_ahashstruct ahash_requeststruct ahash_algstruct shash_descstruct shash_algstruct HASH_ALG_COMMONstruct crypto_ahashstruct crypto_shashfunction CRYPTO_ALG_TYPE_AHASHfunction crypto_free_ahashfunction crypto_ahash_blocksizefunction crypto_ahash_digestsizefunction crypto_ahash_statesizefunction crypto_ahash_get_flagsfunction crypto_ahash_set_flagsfunction crypto_ahash_clear_flagsfunction crypto_ahash_reqtfmfunction crypto_ahash_reqsizefunction crypto_ahash_finalfunction handlefunction ahash_request_allocfunction ahash_request_zerofunction callback_functionfunction ahash_request_set_cryptfunction ahash_request_set_virtfunction crypto_free_shashfunction crypto_shash_blocksizefunction crypto_shash_digestsizefunction crypto_shash_statesizefunction crypto_shash_get_flagsfunction crypto_shash_set_flagsfunction crypto_shash_clear_flagsfunction crypto_shash_descsizefunction crypto_shash_updatefunction crypto_shash_finalfunction shash_desc_zerofunction ahash_is_async
Annotated Snippet
struct ahash_request {
struct crypto_async_request base;
unsigned int nbytes;
union {
struct scatterlist *src;
const u8 *svirt;
};
u8 *result;
struct scatterlist sg_head[2];
crypto_completion_t saved_complete;
void *saved_data;
void *__ctx[] CRYPTO_MINALIGN_ATTR;
};
/**
* struct ahash_alg - asynchronous message digest definition
* @init: **[mandatory]** Initialize the transformation context. Intended only to initialize the
* state of the HASH transformation at the beginning. This shall fill in
* the internal structures used during the entire duration of the whole
* transformation. No data processing happens at this point. Driver code
* implementation must not use req->result.
* @update: **[mandatory]** Push a chunk of data into the driver for transformation. This
* function actually pushes blocks of data from upper layers into the
* driver, which then passes those to the hardware as seen fit. This
* function must not finalize the HASH transformation by calculating the
* final message digest as this only adds more data into the
* transformation. This function shall not modify the transformation
* context, as this function may be called in parallel with the same
* transformation object. Data processing can happen synchronously
* [SHASH] or asynchronously [AHASH] at this point. Driver must not use
* req->result.
* For block-only algorithms, @update must return the number
* of bytes to store in the API partial block buffer.
* @final: **[mandatory]** Retrieve result from the driver. This function finalizes the
* transformation and retrieves the resulting hash from the driver and
* pushes it back to upper layers. No data processing happens at this
* point unless hardware requires it to finish the transformation
* (then the data buffered by the device driver is processed).
* @finup: **[optional]** Combination of @update and @final. This function is effectively a
* combination of @update and @final calls issued in sequence. As some
* hardware cannot do @update and @final separately, this callback was
* added to allow such hardware to be used at least by IPsec. Data
* processing can happen synchronously [SHASH] or asynchronously [AHASH]
* at this point.
* @digest: Combination of @init and @update and @final. This function
* effectively behaves as the entire chain of operations, @init,
* @update and @final issued in sequence. Just like @finup, this was
* added for hardware which cannot do even the @finup, but can only do
* the whole transformation in one run. Data processing can happen
* synchronously [SHASH] or asynchronously [AHASH] at this point.
* @setkey: Set optional key used by the hashing algorithm. Intended to push
* optional key used by the hashing algorithm from upper layers into
* the driver. This function can store the key in the transformation
* context or can outright program it into the hardware. In the former
* case, one must be careful to program the key into the hardware at
* appropriate time and one must be careful that .setkey() can be
* called multiple times during the existence of the transformation
* object. Not all hashing algorithms do implement this function as it
* is only needed for keyed message digests. SHAx/MDx/CRCx do NOT
* implement this function. HMAC(MDx)/HMAC(SHAx)/CMAC(AES) do implement
* this function. This function must be called before any other of the
* @init, @update, @final, @finup, @digest is called. No data
* processing happens at this point.
* @export: Export partial state of the transformation. This function dumps the
* entire state of the ongoing transformation into a provided block of
* data so it can be @import 'ed back later on. This is useful in case
* you want to save partial result of the transformation after
* processing certain amount of data and reload this partial result
* multiple times later on for multiple re-use. No data processing
* happens at this point. Driver must not use req->result.
* @import: Import partial state of the transformation. This function loads the
* entire state of the ongoing transformation from a provided block of
* data so the transformation can continue from this point onward. No
* data processing happens at this point. Driver must not use
* req->result.
* @export_core: Export partial state without partial block. Only defined
* for algorithms that are not block-only.
* @import_core: Import partial state without partial block. Only defined
* for algorithms that are not block-only.
* @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.
Annotation
- Immediate include surface: `linux/crypto.h`, `linux/scatterlist.h`, `linux/slab.h`, `linux/string.h`.
- Detected declarations: `struct crypto_ahash`, `struct ahash_request`, `struct ahash_alg`, `struct shash_desc`, `struct shash_alg`, `struct HASH_ALG_COMMON`, `struct crypto_ahash`, `struct crypto_shash`, `function CRYPTO_ALG_TYPE_AHASH`, `function crypto_free_ahash`.
- Atlas domain: Repository Root And Misc / include.
- Implementation status: source 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.