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 OR GPL-2.0-or-later 9 */ 10 #ifndef MBEDTLS_ENTROPY_POLL_H 11 #define MBEDTLS_ENTROPY_POLL_H 12 13 #if !defined(MBEDTLS_CONFIG_FILE) 14 #include "mbedtls/config.h" 15 #else 16 #include MBEDTLS_CONFIG_FILE 17 #endif 18 19 #include <stddef.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /* 26 * Default thresholds for built-in sources, in bytes 27 */ 28 #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */ 29 #define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */ 30 #define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */ 31 #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE) 32 #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */ 33 #endif 34 35 /** 36 * \brief Entropy poll callback that provides 0 entropy. 37 */ 38 #if defined(MBEDTLS_TEST_NULL_ENTROPY) 39 int mbedtls_null_entropy_poll(void *data, 40 unsigned char *output, size_t len, size_t *olen); 41 #endif 42 43 #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) 44 /** 45 * \brief Platform-specific entropy poll callback 46 */ 47 int mbedtls_platform_entropy_poll(void *data, 48 unsigned char *output, size_t len, size_t *olen); 49 #endif 50 51 #if defined(MBEDTLS_HAVEGE_C) 52 /** 53 * \brief HAVEGE based entropy poll callback 54 * 55 * Requires an HAVEGE state as its data pointer. 56 */ 57 int mbedtls_havege_poll(void *data, 58 unsigned char *output, size_t len, size_t *olen); 59 #endif 60 61 #if defined(MBEDTLS_TIMING_C) 62 /** 63 * \brief mbedtls_timing_hardclock-based entropy poll callback 64 */ 65 int mbedtls_hardclock_poll(void *data, 66 unsigned char *output, size_t len, size_t *olen); 67 #endif 68 69 #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) 70 /** 71 * \brief Entropy poll callback for a hardware source 72 * 73 * \warning This is not provided by Mbed TLS! 74 * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h. 75 * 76 * \note This must accept NULL as its first argument. 77 */ 78 int mbedtls_hardware_poll(void *data, 79 unsigned char *output, size_t len, size_t *olen); 80 #endif 81 82 #if defined(MBEDTLS_ENTROPY_NV_SEED) 83 /** 84 * \brief Entropy poll callback for a non-volatile seed file 85 * 86 * \note This must accept NULL as its first argument. 87 */ 88 int mbedtls_nv_seed_poll(void *data, 89 unsigned char *output, size_t len, size_t *olen); 90 #endif 91 92 #ifdef __cplusplus 93 } 94 #endif 95 96 #endif /* entropy_poll.h */ 97