Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

pal_plat_entropy.h File Reference

pal_plat_entropy.h File Reference

PAL entropy - platform. More...

Go to the source code of this file.

Functions

palStatus_t pal_plat_osEntropyInject (const uint8_t *entropyBuf, size_t bufSizeBytes)
 Inject entropy to non-volatile memory, so that the random number generator may use it.

Detailed Description

PAL entropy - platform.

This file contains entropy injection as part of the platform layer.

Definition in file pal_plat_entropy.h.


Function Documentation

palStatus_t pal_plat_osEntropyInject ( const uint8_t *  entropyBuf,
size_t  bufSizeBytes 
)

Inject entropy to non-volatile memory, so that the random number generator may use it.

In addition to OS functions, the module implementing `pal_plat_drbg.h` will hold a deterministic random bit generator (DRBG) instance that works with the entropy injected by this function.

Note: This API call must be placed prior to any function that may attempt to generate a random number, both by the OS or PAL platform DRBG. After this API call, `pal_plat_osRandomBuffer_blocking()` calls from `pal_plat_drbg.h` will succeed.

Parameters:
entropyBuf- pointer to buffer containing the entropy.
bufSizeBytes- size of `entropyBuf` in bytes.
Returns:
PAL_SUCCESS - if operation is successful.
PAL_ERR_NOT_SUPPORTED - code compiled in a way that does not expect entropy to be injected. TRNG must be available to inject entropy.
PAL_ERR_INVALID_ARGUMENT - `bufSizeBytes` too small.
PAL_ERR_ENTROPY_EXISTS - Entropy already injected.
PAL_ERR_GENERIC_FAILURE - Another cause of error.

Inject entropy to non-volatile memory, so that the random number generator may use it.

* If bufSizeBytes larger than 32, hash (SHA256) and inject the message digest (32 bytes) * If it is exactly 32 inject the buffer * If it is less than 32, return an error

After injecting, this API will seed the DRBG instance in pal_plat_drbg. FIXME: When https://jira.arm.com/browse/IOTCRYPT-180 is resolved - no need to hash, just inject 48 bytes

Parameters:
entropyBuf- pointer to buffer containing the entropy
bufSizeBytes- size of entropyBuf in bytes
Returns:
PAL_SUCCESS - if operation is successful PAL_ERR_NOT_SUPPORTED - if code compiled in a way that does not expect an entropy to be injected (TRNG must be available) PAL_ERR_INVALID_ARGUMENT - bufSizeBytes too small PAL_ERR_ENTROPY_EXISTS - Entropy already injected PAL_ERR_GENERIC_FAILURE - any other case

Definition at line 58 of file pal_plat_entropy_sotp.c.