entropy_poll.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * \file entropy_poll.h
  3. *
  4. * \brief Platform-specific and custom entropy polling functions
  5. */
  6. /*
  7. * Copyright The Mbed TLS Contributors
  8. * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  9. */
  10. #ifndef MBEDTLS_ENTROPY_POLL_H
  11. #define MBEDTLS_ENTROPY_POLL_H
  12. #include "mbedtls/build_info.h"
  13. #include <stddef.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /*
  18. * Default thresholds for built-in sources, in bytes
  19. */
  20. #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
  21. #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
  22. #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
  23. #endif
  24. #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
  25. /**
  26. * \brief Platform-specific entropy poll callback
  27. */
  28. int mbedtls_platform_entropy_poll(void *data,
  29. unsigned char *output, size_t len, size_t *olen);
  30. #endif
  31. #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
  32. /**
  33. * \brief Entropy poll callback for a hardware source
  34. *
  35. * \warning This is not provided by Mbed TLS!
  36. * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in mbedtls_config.h.
  37. *
  38. * \note This must accept NULL as its first argument.
  39. */
  40. int mbedtls_hardware_poll(void *data,
  41. unsigned char *output, size_t len, size_t *olen);
  42. #endif
  43. #if defined(MBEDTLS_ENTROPY_NV_SEED)
  44. /**
  45. * \brief Entropy poll callback for a non-volatile seed file
  46. *
  47. * \note This must accept NULL as its first argument.
  48. */
  49. int mbedtls_nv_seed_poll(void *data,
  50. unsigned char *output, size_t len, size_t *olen);
  51. #endif
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* entropy_poll.h */