ADC Entropy Source Plugin#
Collect entropy from the ADC on Silicon Labs devices.
The ADC entropy module implements an entropy source plugin module for mbedTLS that can be used in applications needing random numbers or indirectly using mbedTLS modules that depend on the random number generation interfaces of mbed TLS. This module can be compiled by selecting Mbed TLS support for ADC entropy on series-1 devices component. Note that the IADC peripheral is not currently supported.
Modules#
Functions#
Initialize an ADC entropy context.
Set and initialize an ADC hardware instance.
Free ADC entropy context.
Poll for entropy data.
Function Documentation#
mbedtls_entropy_adc_init#
void mbedtls_entropy_adc_init (mbedtls_entropy_adc_context * ctx)
Initialize an ADC entropy context.
[in] | ctx | ADC entropy context to be initialized. |
This function will initialize an ADC entropy context. This function will not initialize the ADC hardware instance as an entropy source. The user must call mbedtls_entropy_adc_set_instance in order to initialize the ADC hardware to entropy source mode.
100
of file platform/security/sl_component/sl_mbedtls_support/inc/sl_entropy_adc.h
mbedtls_entropy_adc_set_instance#
int mbedtls_entropy_adc_set_instance (mbedtls_entropy_adc_context * ctx, unsigned int adc_inst)
Set and initialize an ADC hardware instance.
[in] | ctx | ADC entropy context. |
[in] | adc_inst | ADC instance number to use. |
This function will initialize an ADC hardware instance as an entropy source by starting the ADC clock and initializing registers to prepare collecting entropy in single sample mode. This function assumes that the ADC clock mode is set to SYNC, i.e. the HFPERCLK generates the ADC_CLK.
Returns
0 for success or MBEDTLS_ERR_ENTROPY_SOURCE_FAILED if adc_inst is invalid.
123
of file platform/security/sl_component/sl_mbedtls_support/inc/sl_entropy_adc.h
mbedtls_entropy_adc_free#
void mbedtls_entropy_adc_free (mbedtls_entropy_adc_context * ctx)
Free ADC entropy context.
[in] | ctx | ADC entropy context to be released. |
This function will reset the ADC peripheral and stop the ADC clock. If more than one ENTROPY_ADC contexts are instantiated the user should be aware that one call to mbedtls_entropy_adc_free with any of the ADC entropy contexts will disable the ADC and effectively disable all other calls in the ADC entropy API, except mbedtls_entropy_adc_init and mbedtls_entropy_adc_set_instance which will enable the ADC again. Normally the application will need only one ADC entropy context.
145
of file platform/security/sl_component/sl_mbedtls_support/inc/sl_entropy_adc.h
mbedtls_entropy_adc_poll#
int mbedtls_entropy_adc_poll (mbedtls_entropy_adc_context * ctx, unsigned char * output, size_t len, size_t * olen)
Poll for entropy data.
[in] | ctx | ADC entropy context. |
[out] | output | Buffer to fill with entropy data from ADC. |
[in] | len | Maximum number of bytes to fill in output buffer. |
[out] | olen | The actual amount of bytes put into the buffer (Can be 0). |
This function will return entropy data from the ADC and place it into the output buffer. The len parameter tells this function the maximum number of bytes to read.
Note that the number of bytes read from the ADC might differ from the number of bytes requested.
The return value should be used to see if the operation was successful of if an error was encountered while reading the ADC. The content of the olen parameter can be used to check how many bytes were actually read.
Returns
Always 0 for success.
178
of file platform/security/sl_component/sl_mbedtls_support/inc/sl_entropy_adc.h