blob: 068e7e5a05a6c69324cbb586281ce413e8f118d6 [file] [log] [blame]
Paul Bakker6083fd22011-12-03 21:45:14 +00001/**
2 * \file entropy_poll.h
3 *
4 * \brief Platform-specific and custom entropy polling functions
Darryl Greena40a1012018-01-05 15:33:17 +00005 */
6/*
Bence Szépkúti1e148272020-08-07 13:07:28 +02007 * Copyright The Mbed TLS Contributors
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02008 * 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 Bakker6083fd22011-12-03 21:45:14 +000021 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020022#ifndef MBEDTLS_ENTROPY_POLL_H
23#define MBEDTLS_ENTROPY_POLL_H
Paul Bakker6083fd22011-12-03 21:45:14 +000024
Bence Szépkútic662b362021-05-27 11:25:03 +020025#include "mbedtls/build_info.h"
Paul Bakker6083fd22011-12-03 21:45:14 +000026
Rich Evans00ab4702015-02-06 13:43:58 +000027#include <stddef.h>
28
Paul Bakker6083fd22011-12-03 21:45:14 +000029#ifdef __cplusplus
30extern "C" {
31#endif
32
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000033/*
Manuel Pégourié-Gonnardbf82ff02015-06-19 09:40:51 +020034 * Default thresholds for built-in sources, in bytes
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000035 */
Mateusz Starzyk16fec332021-07-22 16:43:35 +020036/** Minimum for platform source */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020037#define MBEDTLS_ENTROPY_MIN_PLATFORM 32
Andres AG7abc9742016-09-23 17:58:49 +010038#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
Mateusz Starzyk16fec332021-07-22 16:43:35 +020039/** Minimum for the hardware source */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020040# define MBEDTLS_ENTROPY_MIN_HARDWARE 32
Andres AG7abc9742016-09-23 17:58:49 +010041#endif
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000042
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020043#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
Paul Bakker6083fd22011-12-03 21:45:14 +000044/**
45 * \brief Platform-specific entropy poll callback
46 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020047int mbedtls_platform_entropy_poll(void *data,
48 unsigned char *output,
49 size_t len,
50 size_t *olen);
Paul Bakker6083fd22011-12-03 21:45:14 +000051#endif
52
Manuel Pégourié-Gonnard3f77dfb2015-06-19 10:06:21 +020053#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
54/**
55 * \brief Entropy poll callback for a hardware source
56 *
57 * \warning This is not provided by mbed TLS!
Bence Szépkútibb0cfeb2021-05-28 09:42:25 +020058 * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in mbedtls_config.h.
Manuel Pégourié-Gonnard3f77dfb2015-06-19 10:06:21 +020059 *
60 * \note This must accept NULL as its first argument.
61 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020062int mbedtls_hardware_poll(void *data,
63 unsigned char *output,
64 size_t len,
65 size_t *olen);
Manuel Pégourié-Gonnard3f77dfb2015-06-19 10:06:21 +020066#endif
67
Paul Bakker9988d6b2016-06-01 11:29:42 +010068#if defined(MBEDTLS_ENTROPY_NV_SEED)
69/**
70 * \brief Entropy poll callback for a non-volatile seed file
71 *
72 * \note This must accept NULL as its first argument.
73 */
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020074int mbedtls_nv_seed_poll(void *data,
75 unsigned char *output,
76 size_t len,
77 size_t *olen);
Paul Bakker9988d6b2016-06-01 11:29:42 +010078#endif
79
Paul Bakker6083fd22011-12-03 21:45:14 +000080#ifdef __cplusplus
81}
82#endif
83
84#endif /* entropy_poll.h */