entropy_poll.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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: Apache-2.0
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  10. * not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  17. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. *
  21. * This file is part of mbed TLS (https://tls.mbed.org)
  22. */
  23. #ifndef MBEDTLS_ENTROPY_POLL_H
  24. #define MBEDTLS_ENTROPY_POLL_H
  25. #if !defined(MBEDTLS_CONFIG_FILE)
  26. #include "config.h"
  27. #else
  28. #include MBEDTLS_CONFIG_FILE
  29. #endif
  30. #include <stddef.h>
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /*
  35. * Default thresholds for built-in sources, in bytes
  36. */
  37. #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
  38. #define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */
  39. #define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */
  40. #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
  41. #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
  42. #endif
  43. /**
  44. * \brief Entropy poll callback that provides 0 entropy.
  45. */
  46. #if defined(MBEDTLS_TEST_NULL_ENTROPY)
  47. int mbedtls_null_entropy_poll( void *data,
  48. unsigned char *output, size_t len, size_t *olen );
  49. #endif
  50. #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
  51. /**
  52. * \brief Platform-specific entropy poll callback
  53. */
  54. int mbedtls_platform_entropy_poll( void *data,
  55. unsigned char *output, size_t len, size_t *olen );
  56. #endif
  57. #if defined(MBEDTLS_HAVEGE_C)
  58. /**
  59. * \brief HAVEGE based entropy poll callback
  60. *
  61. * Requires an HAVEGE state as its data pointer.
  62. */
  63. int mbedtls_havege_poll( void *data,
  64. unsigned char *output, size_t len, size_t *olen );
  65. #endif
  66. #if defined(MBEDTLS_TIMING_C)
  67. /**
  68. * \brief mbedtls_timing_hardclock-based entropy poll callback
  69. */
  70. int mbedtls_hardclock_poll( void *data,
  71. unsigned char *output, size_t len, size_t *olen );
  72. #endif
  73. #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
  74. /**
  75. * \brief Entropy poll callback for a hardware source
  76. *
  77. * \warning This is not provided by mbed TLS!
  78. * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h.
  79. *
  80. * \note This must accept NULL as its first argument.
  81. */
  82. int mbedtls_hardware_poll( void *data,
  83. unsigned char *output, size_t len, size_t *olen );
  84. #endif
  85. #if defined(MBEDTLS_ENTROPY_NV_SEED)
  86. /**
  87. * \brief Entropy poll callback for a non-volatile seed file
  88. *
  89. * \note This must accept NULL as its first argument.
  90. */
  91. int mbedtls_nv_seed_poll( void *data,
  92. unsigned char *output, size_t len, size_t *olen );
  93. #endif
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif /* entropy_poll.h */