blob: 3cfd4a444421eaa96ee0219a03fa2572a6e81775 [file] [log] [blame]
Jens Wiklander32b31802023-10-06 16:59:46 +02001/**
2 * \file entropy_poll.h
3 *
4 * \brief Platform-specific and custom entropy polling functions
5 */
6/*
7 * Copyright The Mbed TLS Contributors
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.
21 */
22#ifndef MBEDTLS_ENTROPY_POLL_H
23#define MBEDTLS_ENTROPY_POLL_H
24
25#include "mbedtls/build_info.h"
26
27#include <stddef.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/*
34 * Default thresholds for built-in sources, in bytes
35 */
36#define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
37#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
38#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
39#endif
40
41#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
42/**
43 * \brief Platform-specific entropy poll callback
44 */
45int mbedtls_platform_entropy_poll(void *data,
46 unsigned char *output, size_t len, size_t *olen);
47#endif
48
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!
54 * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in mbedtls_config.h.
55 *
56 * \note This must accept NULL as its first argument.
57 */
58int mbedtls_hardware_poll(void *data,
59 unsigned char *output, size_t len, size_t *olen);
60#endif
61
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 */
68int mbedtls_nv_seed_poll(void *data,
69 unsigned char *output, size_t len, size_t *olen);
70#endif
71
72#ifdef __cplusplus
73}
74#endif
75
76#endif /* entropy_poll.h */