36#define LC_SHA256_SIZE_BLOCK 64
37#define LC_SHA256_SIZE_DIGEST 32
39struct lc_sha256_state {
42 uint8_t partial[LC_SHA256_SIZE_BLOCK];
45#define LC_SHA256_STATE_SIZE \
46 LC_HASH_STATE_SIZE_ALIGN(sizeof(struct lc_sha256_state))
47#define LC_SHA256_CTX_SIZE (sizeof(struct lc_hash_ctx) + LC_SHA256_STATE_SIZE)
49#define LC_SHA256_CTX(name) \
50 LC_HASH_SET_CTX(name, lc_sha256); \
59#define LC_SHA256_CTX_ON_STACK(name) \
60 _Pragma("GCC diagnostic push") _Pragma( \
61 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
62 LC_ALIGNED_BUFFER(name##_ctx_buf, LC_SHA256_CTX_SIZE, \
63 LC_HASH_COMMON_ALIGNMENT); \
64 struct lc_hash_ctx *name = (struct lc_hash_ctx *)name##_ctx_buf; \
65 LC_SHA256_CTX(name); \
66 _Pragma("GCC diagnostic pop")
int lc_hash(const struct lc_hash *hash, const uint8_t *in, size_t inlen, uint8_t *digest)
Calculate message digest - one-shot.
const struct lc_hash * lc_sha256
SHA2-256 algorithm reference.