bootloader_random.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #pragma once
  15. #include <stddef.h>
  16. /**
  17. * @brief Enable early entropy source for RNG
  18. *
  19. * Uses the SAR ADC to feed entropy into the HWRNG. The ADC is put
  20. * into a test mode that reads the 1.1V internal reference source and
  21. * feeds the LSB of data into the HWRNG.
  22. *
  23. * Can also be used from app code early during operation, if entropy
  24. * is required before WiFi stack is initialised. Call this function
  25. * from app code only if WiFi/BT are not yet enabled and I2S and SAR
  26. * ADC are not in use.
  27. *
  28. * Call bootloader_random_disable() when done.
  29. */
  30. void bootloader_random_enable(void);
  31. /**
  32. * @brief Disable early entropy source for RNG
  33. *
  34. * Disables SAR ADC source and resets the I2S hardware.
  35. *
  36. */
  37. void bootloader_random_disable(void);
  38. /**
  39. * @brief Fill buffer with 'length' random bytes
  40. *
  41. * @param buffer Pointer to buffer
  42. * @param length This many bytes of random data will be copied to buffer
  43. */
  44. void bootloader_fill_random(void *buffer, size_t length);