bootloader_random.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stddef.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /**
  12. * @brief Enable early entropy source for RNG
  13. *
  14. * Uses the SAR ADC to feed entropy into the HWRNG. The ADC is put
  15. * into a test mode that reads the 1.1V internal reference source and
  16. * feeds the LSB of data into the HWRNG.
  17. *
  18. * Can also be used from app code early during operation, if entropy
  19. * is required before WiFi stack is initialised. Call this function
  20. * from app code only if WiFi/BT are not yet enabled and I2S and SAR
  21. * ADC are not in use.
  22. *
  23. * Call bootloader_random_disable() when done.
  24. */
  25. void bootloader_random_enable(void);
  26. /**
  27. * @brief Disable early entropy source for RNG
  28. *
  29. * Disables SAR ADC source and resets the I2S hardware.
  30. *
  31. */
  32. void bootloader_random_disable(void);
  33. /**
  34. * @brief Fill buffer with 'length' random bytes
  35. *
  36. * @param buffer Pointer to buffer
  37. * @param length This many bytes of random data will be copied to buffer
  38. */
  39. void bootloader_fill_random(void *buffer, size_t length);
  40. #ifdef __cplusplus
  41. }
  42. #endif