Leancrypto 1.7.2
Post-Quantum Cryptographic Library
Macros | Functions
lc_chacha20_drng.h File Reference
#include "ext_headers.h"
#include "lc_chacha20.h"
#include "lc_rng.h"
+ Include dependency graph for lc_chacha20_drng.h:

Go to the source code of this file.

Macros

#define LC_CC20_DRNG_CTX_ON_STACK(name)
 Allocate stack memory for the ChaCha20 context. More...
 

Functions

int lc_cc20_drng_alloc (struct lc_rng_ctx **state)
 Allocation of a ChaCha20 DRNG context. More...
 

Macro Definition Documentation

◆ LC_CC20_DRNG_CTX_ON_STACK

#define LC_CC20_DRNG_CTX_ON_STACK (   name)
Value:
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wvla\"") _Pragma( \
"GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
LC_ALIGNED_BUFFER(name##_ctx_buf, \
LC_CC20_DRNG_CTX_SIZE, \
LC_SYM_COMMON_ALIGNMENT); \
struct lc_rng_ctx *name = (struct lc_rng_ctx *)name##_ctx_buf; \
LC_CC20_DRNG_SET_CTX(name); \
_Pragma("GCC diagnostic pop")
#define LC_ALIGNED_BUFFER(name, size, alignment)
Allocate aligned stack memory.

Allocate stack memory for the ChaCha20 context.

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

Definition at line 62 of file lc_chacha20_drng.h.

Function Documentation

◆ lc_cc20_drng_alloc()

int lc_cc20_drng_alloc ( struct lc_rng_ctx **  state)

Allocation of a ChaCha20 DRNG context.

Parameters
[out]stateRNG context allocated by the function

The cipher handle including its memory is allocated with this function.

The memory is pinned so that the DRNG state cannot be swapped out to disk.

Warning
You MUST seed the DRNG!
Returns
0 upon success; < 0 on error