42#define LC_SHA512_SIZE_BLOCK 128
43#define LC_SHA512_SIZE_DIGEST 64
44#define LC_SHA512_STATE_WORDS 8
46struct lc_sha512_state {
47 uint64_t H[LC_SHA512_STATE_WORDS];
49 uint8_t partial[LC_SHA512_SIZE_BLOCK];
52#define LC_SHA512_STATE_SIZE \
53 LC_HASH_STATE_SIZE_ALIGN(sizeof(struct lc_sha512_state))
54#define LC_SHA512_CTX_SIZE (sizeof(struct lc_hash_ctx) + LC_SHA512_STATE_SIZE)
56#define LC_SHA512_CTX(name) \
57 LC_HASH_SET_CTX(name, lc_sha512); \
60#define LC_SHA384_SIZE_BLOCK 128
61#define LC_SHA384_SIZE_DIGEST 48
63#define LC_SHA384_STATE_SIZE LC_SHA512_STATE_SIZE
64#define LC_SHA384_CTX_SIZE LC_SHA512_CTX_SIZE
66#define LC_SHA384_CTX(name) \
67 LC_HASH_SET_CTX(name, lc_sha384); \
76#define LC_SHA384_CTX_ON_STACK(name) \
77 _Pragma("GCC diagnostic push") _Pragma( \
78 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
79 LC_ALIGNED_BUFFER(name##_ctx_buf, LC_SHA384_CTX_SIZE, \
80 LC_HASH_COMMON_ALIGNMENT); \
81 struct lc_hash_ctx *name = (struct lc_hash_ctx *)name##_ctx_buf; \
82 LC_SHA384_CTX(name); \
83 _Pragma("GCC diagnostic pop")
90#define LC_SHA512_CTX_ON_STACK(name) \
91 _Pragma("GCC diagnostic push") _Pragma( \
92 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
93 LC_ALIGNED_BUFFER(name##_ctx_buf, LC_SHA512_CTX_SIZE, \
94 LC_HASH_COMMON_ALIGNMENT); \
95 struct lc_hash_ctx *name = (struct lc_hash_ctx *)name##_ctx_buf; \
96 LC_SHA512_CTX(name); \
97 _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_sha512
SHA2-512 algorithm reference.
const struct lc_hash * lc_sha384
SHA2-384 algorithm reference.