entropy_poll.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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
  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. #ifndef MBEDTLS_ENTROPY_POLL_H
  23. #define MBEDTLS_ENTROPY_POLL_H
  24. #include "mbedtls/build_info.h"
  25. #include <stddef.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /*
  30. * Default thresholds for built-in sources, in bytes
  31. */
  32. #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
  33. #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
  34. #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
  35. #endif
  36. #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
  37. /**
  38. * \brief Platform-specific entropy poll callback
  39. */
  40. int mbedtls_platform_entropy_poll( void *data,
  41. unsigned char *output, size_t len, size_t *olen );
  42. #endif
  43. #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
  44. /**
  45. * \brief Entropy poll callback for a hardware source
  46. *
  47. * \warning This is not provided by mbed TLS!
  48. * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in mbedtls_config.h.
  49. *
  50. * \note This must accept NULL as its first argument.
  51. */
  52. int mbedtls_hardware_poll( void *data,
  53. unsigned char *output, size_t len, size_t *olen );
  54. #endif
  55. #if defined(MBEDTLS_ENTROPY_NV_SEED)
  56. /**
  57. * \brief Entropy poll callback for a non-volatile seed file
  58. *
  59. * \note This must accept NULL as its first argument.
  60. */
  61. int mbedtls_nv_seed_poll( void *data,
  62. unsigned char *output, size_t len, size_t *olen );
  63. #endif
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif /* entropy_poll.h */