entropy_poll.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * \file entropy_poll.h
  3. *
  4. * \brief Platform-specific and custom entropy polling functions
  5. *
  6. * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
  7. * SPDX-License-Identifier: GPL-2.0
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. *
  23. * This file is part of mbed TLS (https://tls.mbed.org)
  24. */
  25. #ifndef MBEDTLS_ENTROPY_POLL_H
  26. #define MBEDTLS_ENTROPY_POLL_H
  27. #if !defined(MBEDTLS_CONFIG_FILE)
  28. #include "config.h"
  29. #else
  30. #include MBEDTLS_CONFIG_FILE
  31. #endif
  32. #include <stddef.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /*
  37. * Default thresholds for built-in sources, in bytes
  38. */
  39. #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
  40. #define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */
  41. #define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */
  42. #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
  43. #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
  44. #endif
  45. /**
  46. * \brief Entropy poll callback that provides 0 entropy.
  47. */
  48. #if defined(MBEDTLS_TEST_NULL_ENTROPY)
  49. int mbedtls_null_entropy_poll( void *data,
  50. unsigned char *output, size_t len, size_t *olen );
  51. #endif
  52. #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
  53. /**
  54. * \brief Platform-specific entropy poll callback
  55. */
  56. int mbedtls_platform_entropy_poll( void *data,
  57. unsigned char *output, size_t len, size_t *olen );
  58. #endif
  59. #if defined(MBEDTLS_HAVEGE_C)
  60. /**
  61. * \brief HAVEGE based entropy poll callback
  62. *
  63. * Requires an HAVEGE state as its data pointer.
  64. */
  65. int mbedtls_havege_poll( void *data,
  66. unsigned char *output, size_t len, size_t *olen );
  67. #endif
  68. #if defined(MBEDTLS_TIMING_C)
  69. /**
  70. * \brief mbedtls_timing_hardclock-based entropy poll callback
  71. */
  72. int mbedtls_hardclock_poll( void *data,
  73. unsigned char *output, size_t len, size_t *olen );
  74. #endif
  75. #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
  76. /**
  77. * \brief Entropy poll callback for a hardware source
  78. *
  79. * \warning This is not provided by mbed TLS!
  80. * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h.
  81. *
  82. * \note This must accept NULL as its first argument.
  83. */
  84. int mbedtls_hardware_poll( void *data,
  85. unsigned char *output, size_t len, size_t *olen );
  86. #endif
  87. #if defined(MBEDTLS_ENTROPY_NV_SEED)
  88. /**
  89. * \brief Entropy poll callback for a non-volatile seed file
  90. *
  91. * \note This must accept NULL as its first argument.
  92. */
  93. int mbedtls_nv_seed_poll( void *data,
  94. unsigned char *output, size_t len, size_t *olen );
  95. #endif
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif /* entropy_poll.h */