31#if !defined(LC_DRBG_HMAC_STATELEN) || !defined(LC_DRBG_HMAC_BLOCKLEN) || \
32 !defined(LC_DRBG_HMAC_CORE)
33#error "Do not include this header file directly! Use lc_hmac_drbg_<hashtype>.h"
37struct lc_drbg_hmac_state {
38 struct lc_hmac_ctx hmac_ctx;
41 unsigned int seeded : 1;
44#define LC_DRBG_HMAC_STATE_SIZE(x) \
45 (2 * LC_DRBG_HMAC_STATELEN + LC_HMAC_STATE_SIZE(x))
46#define LC_DRBG_HMAC_CTX_SIZE(x) \
47 (LC_DRBG_HMAC_STATE_SIZE(x) + sizeof(struct lc_drbg_hmac_state) + \
48 sizeof(struct lc_rng))
50#define _LC_DRBG_HMAC_SET_CTX(name, ctx, offset) \
51 _LC_HMAC_SET_CTX((&(name)->hmac_ctx), LC_DRBG_HMAC_CORE, ctx, offset); \
52 (name)->V = (uint8_t *)((uint8_t *)ctx + offset + \
53 LC_HMAC_STATE_SIZE(LC_DRBG_HMAC_CORE)); \
54 (name)->C = (uint8_t *)((uint8_t *)ctx + offset + \
55 LC_HMAC_STATE_SIZE(LC_DRBG_HMAC_CORE) + \
56 LC_DRBG_HMAC_STATELEN); \
59#define LC_DRBG_HMAC_SET_CTX(name) \
60 _LC_DRBG_HMAC_SET_CTX(name, name, sizeof(struct lc_drbg_hmac_state))
62extern const struct lc_rng *lc_hmac_drbg;
64#define LC_DRBG_HMAC_RNG_CTX(name) \
65 LC_RNG_CTX(name, lc_hmac_drbg); \
66 LC_DRBG_HMAC_SET_CTX((struct lc_drbg_hmac_state *)name->rng_state); \
67 lc_hmac_drbg->zero(name->rng_state)
77#define LC_DRBG_HMAC_CTX_ON_STACK(name) \
78 _Pragma("GCC diagnostic push") \
79 _Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
80 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
83 LC_DRBG_HMAC_CTX_SIZE(LC_DRBG_HMAC_CORE), \
84 LC_HASH_COMMON_ALIGNMENT); \
85 struct lc_rng_ctx *name = (struct lc_rng_ctx *)name##_ctx_buf; \
86 LC_DRBG_HMAC_RNG_CTX(name); \
87 _Pragma("GCC diagnostic pop")
int lc_drbg_hmac_healthcheck_sanity(struct lc_rng_ctx *drbg)
Tests as defined in 11.3.2 in addition to the cipher tests: testing of the error handling.
int lc_drbg_hmac_alloc(struct lc_rng_ctx **drbg)
Allocate HMAC DRBG context on heap.