| 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 | 
| Manuel Pégourié-Gonnard | 37ff140 | 2015-09-04 14:21:07 +0200 | [diff] [blame] | 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. | 
| Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 21 | */ | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 22 | #ifndef MBEDTLS_ENTROPY_POLL_H | 
|  | 23 | #define MBEDTLS_ENTROPY_POLL_H | 
| Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 24 |  | 
| Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 25 | #include "mbedtls/build_info.h" | 
| Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 26 |  | 
| Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 27 | #include <stddef.h> | 
|  | 28 |  | 
| Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 29 | #ifdef __cplusplus | 
|  | 30 | extern "C" { | 
|  | 31 | #endif | 
|  | 32 |  | 
| Paul Bakker | bd4a9d0 | 2011-12-10 17:02:19 +0000 | [diff] [blame] | 33 | /* | 
| Manuel Pégourié-Gonnard | bf82ff0 | 2015-06-19 09:40:51 +0200 | [diff] [blame] | 34 | * Default thresholds for built-in sources, in bytes | 
| Paul Bakker | bd4a9d0 | 2011-12-10 17:02:19 +0000 | [diff] [blame] | 35 | */ | 
| Manuel Pégourié-Gonnard | bf82ff0 | 2015-06-19 09:40:51 +0200 | [diff] [blame] | 36 | #define MBEDTLS_ENTROPY_MIN_PLATFORM     32     /**< Minimum for platform source    */ | 
| Andres AG | 7abc974 | 2016-09-23 17:58:49 +0100 | [diff] [blame] | 37 | #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE) | 
| Manuel Pégourié-Gonnard | 3f77dfb | 2015-06-19 10:06:21 +0200 | [diff] [blame] | 38 | #define MBEDTLS_ENTROPY_MIN_HARDWARE     32     /**< Minimum for the hardware source */ | 
| Andres AG | 7abc974 | 2016-09-23 17:58:49 +0100 | [diff] [blame] | 39 | #endif | 
| Paul Bakker | bd4a9d0 | 2011-12-10 17:02:19 +0000 | [diff] [blame] | 40 |  | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 41 | #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) | 
| Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 42 | /** | 
|  | 43 | * \brief           Platform-specific entropy poll callback | 
|  | 44 | */ | 
| Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 45 | int mbedtls_platform_entropy_poll(void *data, | 
|  | 46 | unsigned char *output, size_t len, size_t *olen); | 
| Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 47 | #endif | 
|  | 48 |  | 
| Manuel Pégourié-Gonnard | 3f77dfb | 2015-06-19 10:06:21 +0200 | [diff] [blame] | 49 | #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) | 
|  | 50 | /** | 
|  | 51 | * \brief           Entropy poll callback for a hardware source | 
|  | 52 | * | 
|  | 53 | * \warning         This is not provided by mbed TLS! | 
| Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 54 | *                  See \c MBEDTLS_ENTROPY_HARDWARE_ALT in mbedtls_config.h. | 
| Manuel Pégourié-Gonnard | 3f77dfb | 2015-06-19 10:06:21 +0200 | [diff] [blame] | 55 | * | 
|  | 56 | * \note            This must accept NULL as its first argument. | 
|  | 57 | */ | 
| Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 58 | int mbedtls_hardware_poll(void *data, | 
|  | 59 | unsigned char *output, size_t len, size_t *olen); | 
| Manuel Pégourié-Gonnard | 3f77dfb | 2015-06-19 10:06:21 +0200 | [diff] [blame] | 60 | #endif | 
|  | 61 |  | 
| Paul Bakker | 9988d6b | 2016-06-01 11:29:42 +0100 | [diff] [blame] | 62 | #if defined(MBEDTLS_ENTROPY_NV_SEED) | 
|  | 63 | /** | 
|  | 64 | * \brief           Entropy poll callback for a non-volatile seed file | 
|  | 65 | * | 
|  | 66 | * \note            This must accept NULL as its first argument. | 
|  | 67 | */ | 
| Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 68 | int mbedtls_nv_seed_poll(void *data, | 
|  | 69 | unsigned char *output, size_t len, size_t *olen); | 
| Paul Bakker | 9988d6b | 2016-06-01 11:29:42 +0100 | [diff] [blame] | 70 | #endif | 
|  | 71 |  | 
| Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 72 | #ifdef __cplusplus | 
|  | 73 | } | 
|  | 74 | #endif | 
|  | 75 |  | 
|  | 76 | #endif /* entropy_poll.h */ |