2021-05-09 22:56:51 -04:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2016-11-11 01:00:34 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2019-06-25 21:02:15 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-01-03 23:36:04 -05:00
|
|
|
/**
|
2021-05-10 21:40:38 -04:00
|
|
|
* @brief Enable an entropy source for RNG if RF is disabled
|
2017-01-03 23:36:04 -05:00
|
|
|
*
|
2021-05-10 21:40:38 -04:00
|
|
|
* The exact internal entropy source mechanism depends on the chip in use but
|
|
|
|
* all SoCs use the SAR ADC to continuously mix random bits (an internal
|
|
|
|
* noise reading) into the HWRNG. Consult the SoC Technical Reference
|
|
|
|
* Manual for more information.
|
2017-01-03 23:36:04 -05:00
|
|
|
*
|
2021-05-06 02:59:02 -04:00
|
|
|
* Can also be used from app code early during operation, if true
|
2021-05-10 21:40:38 -04:00
|
|
|
* random numbers are required before RF is initialised. Consult
|
|
|
|
* ESP-IDF Programming Guide "Random Number Generation" section for
|
|
|
|
* details.
|
2017-01-03 23:36:04 -05:00
|
|
|
*/
|
|
|
|
void bootloader_random_enable(void);
|
|
|
|
|
|
|
|
/**
|
2021-05-10 21:40:38 -04:00
|
|
|
* @brief Disable entropy source for RNG
|
2017-01-03 23:36:04 -05:00
|
|
|
*
|
2021-05-10 21:40:38 -04:00
|
|
|
* Disables internal entropy source. Must be called after
|
|
|
|
* bootloader_random_enable() and before RF features, ADC, or
|
|
|
|
* I2S (ESP32 only) are initialized.
|
2017-01-03 23:36:04 -05:00
|
|
|
*
|
2021-05-10 21:40:38 -04:00
|
|
|
* Consult the ESP-IDF Programming Guide "Random Number Generation"
|
|
|
|
* section for details.
|
2017-01-03 23:36:04 -05:00
|
|
|
*/
|
|
|
|
void bootloader_random_disable(void);
|
|
|
|
|
2016-11-11 01:00:34 -05:00
|
|
|
/**
|
|
|
|
* @brief Fill buffer with 'length' random bytes
|
|
|
|
*
|
2021-05-10 21:40:38 -04:00
|
|
|
* @note If this function is being called from app code only, and never
|
|
|
|
* from the bootloader, then it's better to call esp_fill_random().
|
|
|
|
*
|
2016-11-11 01:00:34 -05:00
|
|
|
* @param buffer Pointer to buffer
|
|
|
|
* @param length This many bytes of random data will be copied to buffer
|
|
|
|
*/
|
|
|
|
void bootloader_fill_random(void *buffer, size_t length);
|
2019-06-25 21:02:15 -04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|