4 * \brief Platform-specific and custom entropy polling functions
6 * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
7 * SPDX-License-Identifier: GPL-2.0
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 * This file is part of mbed TLS (https://tls.mbed.org)
25 #ifndef MBEDTLS_ENTROPY_POLL_H
26 #define MBEDTLS_ENTROPY_POLL_H
28 #if !defined(MBEDTLS_CONFIG_FILE)
31 #include MBEDTLS_CONFIG_FILE
41 * Default thresholds for built-in sources, in bytes
43 #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
44 #define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */
45 #define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */
46 #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
49 * \brief Entropy poll callback that provides 0 entropy.
51 #if defined(MBEDTLS_TEST_NULL_ENTROPY)
52 int mbedtls_null_entropy_poll( void *data
,
53 unsigned char *output
, size_t len
, size_t *olen
);
56 #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
58 * \brief Platform-specific entropy poll callback
60 int mbedtls_platform_entropy_poll( void *data
,
61 unsigned char *output
, size_t len
, size_t *olen
);
64 #if defined(MBEDTLS_HAVEGE_C)
66 * \brief HAVEGE based entropy poll callback
68 * Requires an HAVEGE state as its data pointer.
70 int mbedtls_havege_poll( void *data
,
71 unsigned char *output
, size_t len
, size_t *olen
);
74 #if defined(MBEDTLS_TIMING_C)
76 * \brief mbedtls_timing_hardclock-based entropy poll callback
78 int mbedtls_hardclock_poll( void *data
,
79 unsigned char *output
, size_t len
, size_t *olen
);
82 #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
84 * \brief Entropy poll callback for a hardware source
86 * \warning This is not provided by mbed TLS!
87 * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h.
89 * \note This must accept NULL as its first argument.
91 int mbedtls_hardware_poll( void *data
,
92 unsigned char *output
, size_t len
, size_t *olen
);
95 #if defined(MBEDTLS_ENTROPY_NV_SEED)
97 * \brief Entropy poll callback for a non-volatile seed file
99 * \note This must accept NULL as its first argument.
101 int mbedtls_nv_seed_poll( void *data
,
102 unsigned char *output
, size_t len
, size_t *olen
);
109 #endif /* entropy_poll.h */