Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file entropy_poll.h |
| 3 | * |
| 4 | * \brief Platform-specific and custom entropy polling functions |
Darryl Green | a40a101 | 2018-01-05 15:33:17 +0000 | [diff] [blame] | 5 | */ |
| 6 | /* |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 7 | * Copyright The Mbed TLS Contributors |
Dave Rodgman | 16799db | 2023-11-02 19:47:20 +0000 | [diff] [blame] | 8 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 9 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 10 | #ifndef MBEDTLS_ENTROPY_POLL_H |
| 11 | #define MBEDTLS_ENTROPY_POLL_H |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 12 | |
Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 13 | #include "mbedtls/build_info.h" |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 14 | |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 15 | #include <stddef.h> |
| 16 | |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
Paul Bakker | bd4a9d0 | 2011-12-10 17:02:19 +0000 | [diff] [blame] | 21 | /* |
Manuel Pégourié-Gonnard | bf82ff0 | 2015-06-19 09:40:51 +0200 | [diff] [blame] | 22 | * Default thresholds for built-in sources, in bytes |
Paul Bakker | bd4a9d0 | 2011-12-10 17:02:19 +0000 | [diff] [blame] | 23 | */ |
Manuel Pégourié-Gonnard | bf82ff0 | 2015-06-19 09:40:51 +0200 | [diff] [blame] | 24 | #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */ |
Andres AG | 7abc974 | 2016-09-23 17:58:49 +0100 | [diff] [blame] | 25 | #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE) |
Manuel Pégourié-Gonnard | 3f77dfb | 2015-06-19 10:06:21 +0200 | [diff] [blame] | 26 | #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */ |
Andres AG | 7abc974 | 2016-09-23 17:58:49 +0100 | [diff] [blame] | 27 | #endif |
Paul Bakker | bd4a9d0 | 2011-12-10 17:02:19 +0000 | [diff] [blame] | 28 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 29 | #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 30 | /** |
| 31 | * \brief Platform-specific entropy poll callback |
| 32 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 33 | int mbedtls_platform_entropy_poll(void *data, |
| 34 | unsigned char *output, size_t len, size_t *olen); |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 35 | #endif |
| 36 | |
Manuel Pégourié-Gonnard | 3f77dfb | 2015-06-19 10:06:21 +0200 | [diff] [blame] | 37 | #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) |
| 38 | /** |
| 39 | * \brief Entropy poll callback for a hardware source |
| 40 | * |
Gilles Peskine | e820c0a | 2023-08-03 17:45:20 +0200 | [diff] [blame] | 41 | * \warning This is not provided by Mbed TLS! |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 42 | * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in mbedtls_config.h. |
Manuel Pégourié-Gonnard | 3f77dfb | 2015-06-19 10:06:21 +0200 | [diff] [blame] | 43 | * |
| 44 | * \note This must accept NULL as its first argument. |
| 45 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 46 | int mbedtls_hardware_poll(void *data, |
| 47 | unsigned char *output, size_t len, size_t *olen); |
Manuel Pégourié-Gonnard | 3f77dfb | 2015-06-19 10:06:21 +0200 | [diff] [blame] | 48 | #endif |
| 49 | |
Paul Bakker | 9988d6b | 2016-06-01 11:29:42 +0100 | [diff] [blame] | 50 | #if defined(MBEDTLS_ENTROPY_NV_SEED) |
| 51 | /** |
| 52 | * \brief Entropy poll callback for a non-volatile seed file |
| 53 | * |
| 54 | * \note This must accept NULL as its first argument. |
| 55 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 56 | int mbedtls_nv_seed_poll(void *data, |
| 57 | unsigned char *output, size_t len, size_t *olen); |
Paul Bakker | 9988d6b | 2016-06-01 11:29:42 +0100 | [diff] [blame] | 58 | #endif |
| 59 | |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 60 | #ifdef __cplusplus |
| 61 | } |
| 62 | #endif |
| 63 | |
| 64 | #endif /* entropy_poll.h */ |