NimBLE-Arduino 2.1.2
|
Interface to a CTR-PRNG implementation. More...
Go to the source code of this file.
Functions | |
int | tc_ctr_prng_init (TCCtrPrng_t *const ctx, uint8_t const *const entropy, unsigned int entropyLen, uint8_t const *const personalization, unsigned int pLen) |
CTR-PRNG initialization procedure Initializes prng context with entropy and personalization string (if any) | |
int | tc_ctr_prng_reseed (TCCtrPrng_t *const ctx, uint8_t const *const entropy, unsigned int entropyLen, uint8_t const *const additional_input, unsigned int additionallen) |
CTR-PRNG reseed procedure Mixes entropy and additional_input into the prng context. | |
int | tc_ctr_prng_generate (TCCtrPrng_t *const ctx, uint8_t const *const additional_input, unsigned int additionallen, uint8_t *const out, unsigned int outlen) |
CTR-PRNG generate procedure Generates outlen pseudo-random bytes into out buffer, updates prng. | |
void | tc_ctr_prng_uninstantiate (TCCtrPrng_t *const ctx) |
CTR-PRNG uninstantiate procedure Zeroes the internal state of the supplied prng context. | |
Interface to a CTR-PRNG implementation.
Overview: A pseudo-random number generator (PRNG) generates a sequence of numbers that have a distribution close to the one expected for a sequence of truly random numbers. The NIST Special Publication 800-90A specifies several mechanisms to generate sequences of pseudo random numbers, including the CTR-PRNG one which is based on AES. TinyCrypt implements CTR-PRNG with AES-128.
Security: A cryptographically secure PRNG depends on the existence of an entropy source to provide a truly random seed as well as the security of the primitives used as the building blocks (AES-128 in this instance).
Requires: - AES-128
Usage: 1) call tc_ctr_prng_init to seed the prng context
2) call tc_ctr_prng_reseed to mix in additional entropy into the prng context 3) call tc_ctr_prng_generate to output the pseudo-random data 4) call tc_ctr_prng_uninstantiate to zero out the prng context
int tc_ctr_prng_generate | ( | TCCtrPrng_t *const | ctx, |
uint8_t const *const | additional_input, | ||
unsigned int | additionallen, | ||
uint8_t *const | out, | ||
unsigned int | outlen | ||
) |
CTR-PRNG generate procedure Generates outlen pseudo-random bytes into out buffer, updates prng.
ctx | IN/OUT – the PRNG context |
additional_input | IN – additional input to the prng (may be null) |
additionallen | IN – additional input length in bytes |
out | IN/OUT – buffer to receive output |
outlen | IN – size of out buffer in bytes |
int tc_ctr_prng_init | ( | TCCtrPrng_t *const | ctx, |
uint8_t const *const | entropy, | ||
unsigned int | entropyLen, | ||
uint8_t const *const | personalization, | ||
unsigned int | pLen | ||
) |
CTR-PRNG initialization procedure Initializes prng context with entropy and personalization string (if any)
ctx | IN/OUT – the PRNG context to initialize |
entropy | IN – entropy used to seed the PRNG |
entropyLen | IN – entropy length in bytes |
personalization | IN – personalization string used to seed the PRNG (may be null) |
plen | IN – personalization length in bytes |
int tc_ctr_prng_reseed | ( | TCCtrPrng_t *const | ctx, |
uint8_t const *const | entropy, | ||
unsigned int | entropyLen, | ||
uint8_t const *const | additional_input, | ||
unsigned int | additionallen | ||
) |
CTR-PRNG reseed procedure Mixes entropy and additional_input into the prng context.
ctx | IN/OUT – the PRNG state |
entropy | IN – entropy to mix into the prng |
entropylen | IN – length of entropy in bytes |
additional_input | IN – additional input to the prng (may be null) |
additionallen | IN – additional input length in bytes |
void tc_ctr_prng_uninstantiate | ( | TCCtrPrng_t *const | ctx | ) |
CTR-PRNG uninstantiate procedure Zeroes the internal state of the supplied prng context.
ctx | IN/OUT – the PRNG context |