4 * \brief Platform-specific and custom entropy polling functions
7 * Copyright The Mbed TLS Contributors
8 * SPDX-License-Identifier: Apache-2.0
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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #ifndef MBEDTLS_ENTROPY_POLL_H
23 #define MBEDTLS_ENTROPY_POLL_H
25 #if !defined(MBEDTLS_CONFIG_FILE)
26 #include "mbedtls/config.h"
28 #include MBEDTLS_CONFIG_FILE
38 * Default thresholds for built-in sources, in bytes
40 #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
41 #define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */
42 #define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */
43 #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
44 #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
48 * \brief Entropy poll callback that provides 0 entropy.
50 #if defined(MBEDTLS_TEST_NULL_ENTROPY)
51 int mbedtls_null_entropy_poll(void *data
,
52 unsigned char *output
, size_t len
, size_t *olen
);
55 #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
57 * \brief Platform-specific entropy poll callback
59 int mbedtls_platform_entropy_poll(void *data
,
60 unsigned char *output
, size_t len
, size_t *olen
);
63 #if defined(MBEDTLS_HAVEGE_C)
65 * \brief HAVEGE based entropy poll callback
67 * Requires an HAVEGE state as its data pointer.
69 int mbedtls_havege_poll(void *data
,
70 unsigned char *output
, size_t len
, size_t *olen
);
73 #if defined(MBEDTLS_TIMING_C)
75 * \brief mbedtls_timing_hardclock-based entropy poll callback
77 int mbedtls_hardclock_poll(void *data
,
78 unsigned char *output
, size_t len
, size_t *olen
);
81 #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
83 * \brief Entropy poll callback for a hardware source
85 * \warning This is not provided by mbed TLS!
86 * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h.
88 * \note This must accept NULL as its first argument.
90 int mbedtls_hardware_poll(void *data
,
91 unsigned char *output
, size_t len
, size_t *olen
);
94 #if defined(MBEDTLS_ENTROPY_NV_SEED)
96 * \brief Entropy poll callback for a non-volatile seed file
98 * \note This must accept NULL as its first argument.
100 int mbedtls_nv_seed_poll(void *data
,
101 unsigned char *output
, size_t len
, size_t *olen
);
108 #endif /* entropy_poll.h */