Go to the documentation of this file.
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
40 #if (XDRBG_SUPPORT == ENABLED)
65 if(context == NULL || xofAlgo == NULL)
78 #if (SHAKE_SUPPORT == ENABLED)
89 #if (SHAKE_SUPPORT == ENABLED)
100 #if (ASCON_XOF128_SUPPORT == ENABLED)
148 const uint8_t *alpha,
size_t alphaLen)
155 if(context == NULL || seed == NULL)
159 if(alpha == NULL && alphaLen != 0)
186 xofAlgo->
init(xofContext);
187 xofAlgo->
absorb(xofContext, seed, seedLen);
188 xofAlgo->
absorb(xofContext, alpha, alphaLen);
189 xofAlgo->
absorb(xofContext, &encode,
sizeof(encode));
190 xofAlgo->
final(xofContext);
230 size_t seedLen,
const uint8_t *alpha,
size_t alphaLen)
237 if(context == NULL || seed == NULL)
241 if(alpha == NULL && alphaLen != 0)
253 if(seedLen < context->securityStrength)
272 xofAlgo->
init(xofContext);
274 xofAlgo->
absorb(xofContext, seed, seedLen);
275 xofAlgo->
absorb(xofContext, alpha, alphaLen);
276 xofAlgo->
absorb(xofContext, &encode,
sizeof(encode));
277 xofAlgo->
final(xofContext);
317 size_t alphaLen, uint8_t *output,
size_t outputLen)
329 if(alpha == NULL && alphaLen != 0)
362 xofAlgo->
init(xofContext);
364 xofAlgo->
absorb(xofContext, alpha, alphaLen);
365 xofAlgo->
absorb(xofContext, &encode,
sizeof(encode));
366 xofAlgo->
final(xofContext);
370 xofAlgo->
squeeze(xofContext, output,
n);
void xdrbgDeinit(XdrbgContext *context)
Release PRNG context.
error_t xdrbgSeed(XdrbgContext *context, const uint8_t *seed, size_t length)
Seed the PRNG state.
#define SHAKE128_XOF_ALGO
error_t xdrbgSeedEx(XdrbgContext *context, const uint8_t *seed, size_t seedLen, const uint8_t *alpha, size_t alphaLen)
Seed the PRNG state (with nonce and personalization string)
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
error_t(* PrngAlgoSeed)(void *context, const uint8_t *seed, size_t length)
error_t(* PrngAlgoReseed)(void *context, const uint8_t *seed, size_t length)
error_t xdrbgReseedEx(XdrbgContext *context, const uint8_t *seed, size_t seedLen, const uint8_t *alpha, size_t alphaLen)
Reseed the PRNG state (with additional input)
#define SHAKE256_XOF_ALGO
error_t xdrbgGenerate(XdrbgContext *context, uint8_t *output, size_t length)
Generate pseudorandom data.
XofContext xofContext
XOF context.
@ ERROR_INVALID_PARAMETER
Invalid parameter.
size_t maxOutputLen
Maximum output length.
error_t xdrbgReseed(XdrbgContext *context, const uint8_t *seed, size_t length)
Reseed the PRNG state.
const PrngAlgo xdrbgPrngAlgo
error_t xdrbgInit(XdrbgContext *context, const XofAlgo *xofAlgo)
Initialize PRNG context.
General definitions for cryptographic algorithms.
#define XDRBG_ENCODE(alphaLen, n)
Generic XOF algorithm context.
XDRBG pseudorandom number generator.
Common interface for XOF algorithms.
OsMutex mutex
Mutex preventing simultaneous access to the PRNG state.
void(* PrngAlgoDeinit)(void *context)
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
error_t(* PrngAlgoGenerate)(void *context, uint8_t *output, size_t length)
size_t securityStrength
Security strength.
error_t xdrbgGenerateEx(XdrbgContext *context, const uint8_t *alpha, size_t alphaLen, uint8_t *output, size_t outputLen)
Generate pseudorandom data (with additional input)
#define XDRBG_MAX_ALPHA_LEN
uint64_t reseedCounter
Reseed counter.
#define osMemset(p, value, length)
error_t(* PrngAlgoInit)(void *context)
const XofAlgo * xofAlgo
XOF algorithm.
#define ASCON_XOF128_XOF_ALGO
uint8_t v[XDRBG_MAX_V_SIZE]
Internal state V.