Skip to content

Latest commit

 

History

History
52 lines (32 loc) · 915 Bytes

GUID-302E82E5-8878-47A6-90AE-451B424C87A0.md

File metadata and controls

52 lines (32 loc) · 915 Bytes

CRYPT_RNG_Initialize Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_RNG_Initialize(
CRYPT_RNG_CTX* rng
);

Description

This function initializes the context that stores information relative to random number generation.

Preconditions

None.

Parameters

Parameters Description
rng Pointer to random number generator context.

Returns

  • negative - An error occurred setting up the random number generator.

  • 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);