1.5 CRYPT_RNG_BlockGenerate Function
C
int CRYPT_RNG_BlockGenerate(
CRYPT_RNG_CTX* rng,
unsigned char* b,
unsigned int sz
);Description
This function generates several random numbers and places them in the space allocated.
Preconditions
RNG context was initialized using the CRYPT_RNG_Initialize function.
Parameters
| Parameters | Description |
|---|---|
| rng | Pointer to context which saves state between calls |
| b | Pointer to buffer to store the random numbers |
| sz | Number of 8-bit random numbers to generate |
Returns
- BAD_FUNC_ARG - An invalid pointer was passed to the function
- 0 - An invalid pointer was not passed to the function
Remarks
None.
Example
#define RANDOM_BYTE_SZ 32 int ret; CRYPT_RNG_CTX mcRng; byte out[RANDOM_BYTE_SZ]; ret = CRYPT_RNG_Initialize(&mcRng); ret = CRYPT_RNG_Get(&mcRng, &out[0]); ret = CRYPT_RNG_BlockGenerate(&mcRng, out, RANDOM_BYTE_SZ); ret = CRYPT_RNG_Deinitialize(&mcRng);
