20#ifndef LC_KMAC256_DRNG_H
21#define LC_KMAC256_DRNG_H
31#define LC_KMAC256_DRNG_KEYSIZE 64
33struct lc_kmac256_drng_state {
34 uint8_t initially_seeded;
35 uint8_t key[LC_KMAC256_DRNG_KEYSIZE];
38#define LC_KMAC256_DRNG_MAX_CHUNK (LC_SHA3_256_SIZE_BLOCK * 2)
39#define LC_KMAC256_DRNG_STATE_SIZE (sizeof(struct lc_kmac256_drng_state))
40#define LC_KMAC256_DRNG_CTX_SIZE \
41 (sizeof(struct lc_rng) + LC_KMAC256_DRNG_STATE_SIZE)
44extern const struct lc_rng *lc_kmac256_drng;
46#define LC_KMAC256_RNG_CTX(name) \
47 LC_RNG_CTX(name, lc_kmac256_drng); \
48 lc_kmac256_drng->zero(name->rng_state)
58#define LC_KMAC256_DRNG_CTX_ON_STACK(name) \
59 _Pragma("GCC diagnostic push") _Pragma( \
60 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
61 LC_ALIGNED_BUFFER(name##_ctx_buf, LC_KMAC256_DRNG_CTX_SIZE, \
62 LC_HASH_COMMON_ALIGNMENT); \
63 struct lc_rng_ctx *name = (struct lc_rng_ctx *)name##_ctx_buf; \
64 LC_KMAC256_RNG_CTX(name); \
65 _Pragma("GCC diagnostic pop")
int lc_kmac256_drng_alloc(struct lc_rng_ctx **state)
Allocation of a KMAC DRNG context.