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 (2 * LC_DRBG_HMAC_STATELEN + LC_HMAC_STATE_SIZE)
45#define LC_DRBG_HMAC_CTX_SIZE \
46 (LC_DRBG_HMAC_STATE_SIZE + sizeof(struct lc_drbg_hmac_state) + \
47 sizeof(struct lc_rng))
49#define _LC_DRBG_HMAC_SET_CTX(name, ctx, offset) \
50 _LC_HMAC_SET_CTX((&(name)->hmac_ctx), LC_DRBG_HMAC_CORE, ctx, offset); \
51 (name)->V = (uint8_t *)((uint8_t *)ctx + offset + LC_HMAC_STATE_SIZE); \
52 (name)->C = (uint8_t *)((uint8_t *)ctx + offset + LC_HMAC_STATE_SIZE + \
53 LC_DRBG_HMAC_STATELEN); \
56#define LC_DRBG_HMAC_SET_CTX(name) \
57 _LC_DRBG_HMAC_SET_CTX(name, name, sizeof(struct lc_drbg_hmac_state))
59extern const struct lc_rng *lc_hmac_drbg;
61#define LC_DRBG_HMAC_RNG_CTX(name) \
62 LC_RNG_CTX(name, lc_hmac_drbg); \
63 LC_DRBG_HMAC_SET_CTX((struct lc_drbg_hmac_state *)name->rng_state); \
64 lc_hmac_drbg->zero(name->rng_state)
74#define LC_DRBG_HMAC_CTX_ON_STACK(name) \
75 _Pragma("GCC diagnostic push") _Pragma( \
76 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
77 LC_ALIGNED_BUFFER(name##_ctx_buf, LC_DRBG_HMAC_CTX_SIZE, \
78 LC_HASH_COMMON_ALIGNMENT); \
79 struct lc_rng_ctx *name = (struct lc_rng_ctx *)name##_ctx_buf; \
80 LC_DRBG_HMAC_RNG_CTX(name); \
81 _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.