entropy_poll.h 3.2 KB

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