Leancrypto 0.12.0
Post-Quantum Cryptographic Library
Loading...
Searching...
No Matches
lc_hmac_drbg.h File Reference
#include "lc_drbg.h"
#include "lc_hmac.h"
#include "lc_rng.h"
+ Include dependency graph for lc_hmac_drbg.h:

Go to the source code of this file.

Macros

#define LC_DRBG_HMAC_CTX_ON_STACK(name)
 Allocate stack memory for the Hash DRBG context.
 

Functions

int lc_drbg_hmac_alloc (struct lc_rng_ctx **drbg)
 Allocate HMAC DRBG context on heap.
 
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.
 

Macro Definition Documentation

◆ LC_DRBG_HMAC_CTX_ON_STACK

#define LC_DRBG_HMAC_CTX_ON_STACK ( name)
Value:
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
"GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
name##_ctx_buf, \
LC_DRBG_HMAC_CTX_SIZE(LC_DRBG_HMAC_CORE), \
LC_HASH_COMMON_ALIGNMENT); \
struct lc_rng_ctx *name = (struct lc_rng_ctx *)name##_ctx_buf; \
LC_DRBG_HMAC_RNG_CTX(name); \
_Pragma("GCC diagnostic pop")
#define LC_ALIGNED_BUFFER(name, size, alignment)
Allocate aligned stack memory.

Allocate stack memory for the Hash DRBG context.

Parameters
[in]nameName of the stack variable
Warning
You MUST seed the DRNG!

Definition at line 77 of file lc_hmac_drbg.h.

Function Documentation

◆ lc_drbg_hmac_alloc()

int lc_drbg_hmac_alloc ( struct lc_rng_ctx ** drbg)

Allocate HMAC DRBG context on heap.

Parameters
[out]drbgAllocated HMAC DRBG context
Warning
You MUST seed the DRNG!
Returns
: 0 on success, < 0 on error

◆ lc_drbg_hmac_healthcheck_sanity()

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.

Parameters
[in]drbgDRBG state handle that is used solely for the testing. It shall not be a production handle unless you call drbg_seed on that handle afterwards.

Note: testing of failing seed source as defined in 11.3.2 must be handled by the caller.

Note 2: There is no sensible way of testing the reseed counter enforcement, so skip it.

Returns
: 0 on success, < 0 on error