1.8 CRYPT_RNG_Get Function
C
int CRYPT_RNG_Get(
CRYPT_RNG_CTX* rng,
unsigned char* b
);Description
This function gets one random number from the random number generator.
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 8-bit location to store the result |
Returns
- BAD_FUNC_ARG - An invalid pointer was passed to the function
- Less than 0 - An error occurred
- 0 or greater - Success
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);
