blob: 6b4aec03e18b269653814c31cffefec13870a76e [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
Dave Rodgman16799db2023-11-02 19:47:20 +00008 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Paul Bakker6083fd22011-12-03 21:45:14 +00009 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020010#ifndef MBEDTLS_ENTROPY_POLL_H
11#define MBEDTLS_ENTROPY_POLL_H
Paul Bakker6083fd22011-12-03 21:45:14 +000012
Bence Szépkútic662b362021-05-27 11:25:03 +020013#include "mbedtls/build_info.h"
Paul Bakker6083fd22011-12-03 21:45:14 +000014
Rich Evans00ab4702015-02-06 13:43:58 +000015#include <stddef.h>
16
Paul Bakker6083fd22011-12-03 21:45:14 +000017#ifdef __cplusplus
18extern "C" {
19#endif
20
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000021/*
Manuel Pégourié-Gonnardbf82ff02015-06-19 09:40:51 +020022 * Default thresholds for built-in sources, in bytes
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000023 */
Manuel Pégourié-Gonnardbf82ff02015-06-19 09:40:51 +020024#define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
Andres AG7abc9742016-09-23 17:58:49 +010025#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
Manuel Pégourié-Gonnard3f77dfb2015-06-19 10:06:21 +020026#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
Andres AG7abc9742016-09-23 17:58:49 +010027#endif
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000028
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020029#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
Paul Bakker6083fd22011-12-03 21:45:14 +000030/**
31 * \brief Platform-specific entropy poll callback
32 */
Gilles Peskine449bd832023-01-11 14:50:10 +010033int mbedtls_platform_entropy_poll(void *data,
34 unsigned char *output, size_t len, size_t *olen);
Paul Bakker6083fd22011-12-03 21:45:14 +000035#endif
36
Manuel Pégourié-Gonnard3f77dfb2015-06-19 10:06:21 +020037#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
38/**
39 * \brief Entropy poll callback for a hardware source
40 *
Gilles Peskinee820c0a2023-08-03 17:45:20 +020041 * \warning This is not provided by Mbed TLS!
Bence Szépkútibb0cfeb2021-05-28 09:42:25 +020042 * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in mbedtls_config.h.
Manuel Pégourié-Gonnard3f77dfb2015-06-19 10:06:21 +020043 *
44 * \note This must accept NULL as its first argument.
45 */
Gilles Peskine449bd832023-01-11 14:50:10 +010046int mbedtls_hardware_poll(void *data,
47 unsigned char *output, size_t len, size_t *olen);
Manuel Pégourié-Gonnard3f77dfb2015-06-19 10:06:21 +020048#endif
49
Paul Bakker9988d6b2016-06-01 11:29:42 +010050#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 Peskine449bd832023-01-11 14:50:10 +010056int mbedtls_nv_seed_poll(void *data,
57 unsigned char *output, size_t len, size_t *olen);
Paul Bakker9988d6b2016-06-01 11:29:42 +010058#endif
59
Paul Bakker6083fd22011-12-03 21:45:14 +000060#ifdef __cplusplus
61}
62#endif
63
64#endif /* entropy_poll.h */