include/crypto/sha2.h
Source file repositories/reference/linux-study-clean/include/crypto/sha2.h
File Facts
- System
- Linux kernel
- Corpus path
include/crypto/sha2.h- Extension
.h- Size
- 26849 bytes
- Lines
- 914
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.h
Detected Declarations
struct crypto_sha256_statestruct sha256_statestruct sha512_statestruct sha256_block_statestruct __sha256_ctxstruct __hmac_sha256_keystruct __hmac_sha256_ctxstruct sha224_ctxstruct hmac_sha224_keystruct hmac_sha224_ctxstruct sha256_ctxstruct hmac_sha256_keystruct hmac_sha256_ctxstruct sha512_block_statestruct __sha512_ctxstruct __hmac_sha512_keystruct __hmac_sha512_ctxstruct sha384_ctxstruct hmac_sha384_keystruct hmac_sha384_ctxstruct sha512_ctxstruct hmac_sha512_keystruct hmac_sha512_ctxfunction sha224_block_initfunction sha256_block_initfunction sha224_updatefunction hmac_sha224_initfunction hmac_sha224_updatefunction sha256_updatefunction hmac_sha256_initfunction hmac_sha256_updatefunction sha384_updatefunction hmac_sha384_initfunction hmac_sha384_updatefunction sha512_updatefunction hmac_sha512_initfunction hmac_sha512_update
Annotated Snippet
struct crypto_sha256_state {
u32 state[SHA256_STATE_WORDS];
u64 count;
};
static inline void sha224_block_init(struct crypto_sha256_state *sctx)
{
sctx->state[0] = SHA224_H0;
sctx->state[1] = SHA224_H1;
sctx->state[2] = SHA224_H2;
sctx->state[3] = SHA224_H3;
sctx->state[4] = SHA224_H4;
sctx->state[5] = SHA224_H5;
sctx->state[6] = SHA224_H6;
sctx->state[7] = SHA224_H7;
sctx->count = 0;
}
static inline void sha256_block_init(struct crypto_sha256_state *sctx)
{
sctx->state[0] = SHA256_H0;
sctx->state[1] = SHA256_H1;
sctx->state[2] = SHA256_H2;
sctx->state[3] = SHA256_H3;
sctx->state[4] = SHA256_H4;
sctx->state[5] = SHA256_H5;
sctx->state[6] = SHA256_H6;
sctx->state[7] = SHA256_H7;
sctx->count = 0;
}
struct sha256_state {
union {
struct crypto_sha256_state ctx;
struct {
u32 state[SHA256_STATE_WORDS];
u64 count;
};
};
u8 buf[SHA256_BLOCK_SIZE];
};
struct sha512_state {
u64 state[SHA512_DIGEST_SIZE / 8];
u64 count[2];
u8 buf[SHA512_BLOCK_SIZE];
};
/* State for the SHA-256 (and SHA-224) compression function */
struct sha256_block_state {
u32 h[SHA256_STATE_WORDS];
};
/*
* Context structure, shared by SHA-224 and SHA-256. The sha224_ctx and
* sha256_ctx structs wrap this one so that the API has proper typing and
* doesn't allow mixing the SHA-224 and SHA-256 functions arbitrarily.
*/
struct __sha256_ctx {
struct sha256_block_state state;
u64 bytecount;
u8 buf[SHA256_BLOCK_SIZE] __aligned(__alignof__(__be64));
};
void __sha256_update(struct __sha256_ctx *ctx, const u8 *data, size_t len);
/*
* HMAC key and message context structs, shared by HMAC-SHA224 and HMAC-SHA256.
* The hmac_sha224_* and hmac_sha256_* structs wrap this one so that the API has
* proper typing and doesn't allow mixing the functions arbitrarily.
*/
struct __hmac_sha256_key {
struct sha256_block_state istate;
struct sha256_block_state ostate;
};
struct __hmac_sha256_ctx {
struct __sha256_ctx sha_ctx;
struct sha256_block_state ostate;
};
void __hmac_sha256_init(struct __hmac_sha256_ctx *ctx,
const struct __hmac_sha256_key *key);
/**
* struct sha224_ctx - Context for hashing a message with SHA-224
* @ctx: private
*/
struct sha224_ctx {
struct __sha256_ctx ctx;
};
/**
Annotation
- Immediate include surface: `linux/types.h`.
- Detected declarations: `struct crypto_sha256_state`, `struct sha256_state`, `struct sha512_state`, `struct sha256_block_state`, `struct __sha256_ctx`, `struct __hmac_sha256_key`, `struct __hmac_sha256_ctx`, `struct sha224_ctx`, `struct hmac_sha224_key`, `struct hmac_sha224_ctx`.
- 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.