include/crypto/sm3.h

Source file repositories/reference/linux-study-clean/include/crypto/sm3.h

File Facts

System
Linux kernel
Corpus path
include/crypto/sm3.h
Extension
.h
Size
2293 bytes
Lines
88
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 sm3_block_state {
	u32 h[SM3_DIGEST_SIZE / 4];
};

/**
 * struct sm3_ctx - Context for hashing a message with SM3
 * @state: the compression function state
 * @bytecount: number of bytes processed so far
 * @buf: partial block buffer; bytecount % SM3_BLOCK_SIZE bytes are valid
 */
struct sm3_ctx {
	struct sm3_block_state state;
	u64 bytecount;
	u8 buf[SM3_BLOCK_SIZE] __aligned(__alignof__(__be64));
};

/**
 * sm3_init() - Initialize an SM3 context for a new message
 * @ctx: the context to initialize
 *
 * If you don't need incremental computation, consider sm3() instead.
 *
 * Context: Any context.
 */
void sm3_init(struct sm3_ctx *ctx);

/**
 * sm3_update() - Update an SM3 context with message data
 * @ctx: the context to update; must have been initialized
 * @data: the message data
 * @len: the data length in bytes
 *
 * This can be called any number of times.
 *
 * Context: Any context.
 */
void sm3_update(struct sm3_ctx *ctx, const u8 *data, size_t len);

/**
 * sm3_final() - Finish computing an SM3 message digest
 * @ctx: the context to finalize; must have been initialized
 * @out: (output) the resulting SM3 message digest
 *
 * After finishing, this zeroizes @ctx.  So the caller does not need to do it.
 *
 * Context: Any context.
 */
void sm3_final(struct sm3_ctx *ctx, u8 out[at_least SM3_DIGEST_SIZE]);

/**
 * sm3() - Compute SM3 message digest in one shot
 * @data: the message data
 * @len: the data length in bytes
 * @out: (output) the resulting SM3 message digest
 *
 * Context: Any context.
 */
void sm3(const u8 *data, size_t len, u8 out[at_least SM3_DIGEST_SIZE]);

#endif /* _CRYPTO_SM3_H */

Annotation

Implementation Notes