• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <stddef.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /**
24  * @brief Enable early entropy source for RNG
25  *
26  * Uses the SAR ADC to feed entropy into the HWRNG. The ADC is put
27  * into a test mode that reads the 1.1V internal reference source and
28  * feeds the LSB of data into the HWRNG.
29  *
30  * Can also be used from app code early during operation, if entropy
31  * is required before WiFi stack is initialised. Call this function
32  * from app code only if WiFi/BT are not yet enabled and I2S and SAR
33  * ADC are not in use.
34  *
35  * Call bootloader_random_disable() when done.
36  */
37 void bootloader_random_enable(void);
38 
39 /**
40  * @brief Disable early entropy source for RNG
41  *
42  * Disables SAR ADC source and resets the I2S hardware.
43  *
44  */
45 void bootloader_random_disable(void);
46 
47 /**
48  * @brief Fill buffer with 'length' random bytes
49  *
50  * @param buffer Pointer to buffer
51  * @param length This many bytes of random data will be copied to buffer
52  */
53 void bootloader_fill_random(void *buffer, size_t length);
54 
55 #ifdef __cplusplus
56 }
57 #endif
58