Leancrypto 0.12.0
Post-Quantum Cryptographic Library
Loading...
Searching...
No Matches
lc_hash_drbg.h File Reference
#include "lc_drbg.h"
#include "lc_rng.h"
#include "lc_sha512.h"
+ Include dependency graph for lc_hash_drbg.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

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

Functions

int lc_drbg_hash_alloc (struct lc_rng_ctx **drbg)
 Allocate Hash DRBG context on heap.
 
int lc_drbg_hash_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_HASH_CTX_ON_STACK

#define LC_DRBG_HASH_CTX_ON_STACK ( name)
Value:
_Pragma("GCC diagnostic push") _Pragma( \
"GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
LC_ALIGNED_BUFFER(name##_ctx_buf, LC_DRBG_HASH_CTX_SIZE, \
LC_HASH_COMMON_ALIGNMENT); \
struct lc_rng_ctx *name = (struct lc_rng_ctx *)name##_ctx_buf; \
LC_DRBG_HASH_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 75 of file lc_hash_drbg.h.

Function Documentation

◆ lc_drbg_hash_alloc()

int lc_drbg_hash_alloc ( struct lc_rng_ctx ** drbg)

Allocate Hash DRBG context on heap.

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

◆ lc_drbg_hash_healthcheck_sanity()

int lc_drbg_hash_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