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.

Dependency Surface

Detected Declarations

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

Implementation Notes