entropy_poll.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * \file entropy_poll.h
  3. *
  4. * \brief Platform-specific and custom entropy polling functions
  5. *
  6. * Copyright (C) 2006-2015, 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. #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
  41. #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
  42. /**
  43. * \brief Platform-specific entropy poll callback
  44. */
  45. int mbedtls_platform_entropy_poll( void *data,
  46. unsigned char *output, size_t len, size_t *olen );
  47. #endif
  48. #if defined(MBEDTLS_HAVEGE_C)
  49. /**
  50. * \brief HAVEGE based entropy poll callback
  51. *
  52. * Requires an HAVEGE state as its data pointer.
  53. */
  54. int mbedtls_havege_poll( void *data,
  55. unsigned char *output, size_t len, size_t *olen );
  56. #endif
  57. #if defined(MBEDTLS_TIMING_C)
  58. /**
  59. * \brief mbedtls_timing_hardclock-based entropy poll callback
  60. */
  61. int mbedtls_hardclock_poll( void *data,
  62. unsigned char *output, size_t len, size_t *olen );
  63. #endif
  64. #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
  65. /**
  66. * \brief Entropy poll callback for a hardware source
  67. *
  68. * \warning This is not provided by mbed TLS!
  69. * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h.
  70. *
  71. * \note This must accept NULL as its first argument.
  72. */
  73. int mbedtls_hardware_poll( void *data,
  74. unsigned char *output, size_t len, size_t *olen );
  75. #endif
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif /* entropy_poll.h */