1a8e1175bSopenharmony_ci/**
2a8e1175bSopenharmony_ci * \file entropy_poll.h
3a8e1175bSopenharmony_ci *
4a8e1175bSopenharmony_ci * \brief Platform-specific and custom entropy polling functions
5a8e1175bSopenharmony_ci */
6a8e1175bSopenharmony_ci/*
7a8e1175bSopenharmony_ci *  Copyright The Mbed TLS Contributors
8a8e1175bSopenharmony_ci *  SPDX-License-Identifier: Apache-2.0
9a8e1175bSopenharmony_ci *
10a8e1175bSopenharmony_ci *  Licensed under the Apache License, Version 2.0 (the "License"); you may
11a8e1175bSopenharmony_ci *  not use this file except in compliance with the License.
12a8e1175bSopenharmony_ci *  You may obtain a copy of the License at
13a8e1175bSopenharmony_ci *
14a8e1175bSopenharmony_ci *  http://www.apache.org/licenses/LICENSE-2.0
15a8e1175bSopenharmony_ci *
16a8e1175bSopenharmony_ci *  Unless required by applicable law or agreed to in writing, software
17a8e1175bSopenharmony_ci *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18a8e1175bSopenharmony_ci *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19a8e1175bSopenharmony_ci *  See the License for the specific language governing permissions and
20a8e1175bSopenharmony_ci *  limitations under the License.
21a8e1175bSopenharmony_ci */
22a8e1175bSopenharmony_ci#ifndef MBEDTLS_ENTROPY_POLL_H
23a8e1175bSopenharmony_ci#define MBEDTLS_ENTROPY_POLL_H
24a8e1175bSopenharmony_ci
25a8e1175bSopenharmony_ci#include "mbedtls/build_info.h"
26a8e1175bSopenharmony_ci
27a8e1175bSopenharmony_ci#include <stddef.h>
28a8e1175bSopenharmony_ci
29a8e1175bSopenharmony_ci#ifdef __cplusplus
30a8e1175bSopenharmony_ciextern "C" {
31a8e1175bSopenharmony_ci#endif
32a8e1175bSopenharmony_ci
33a8e1175bSopenharmony_ci/*
34a8e1175bSopenharmony_ci * Default thresholds for built-in sources, in bytes
35a8e1175bSopenharmony_ci */
36a8e1175bSopenharmony_ci#define MBEDTLS_ENTROPY_MIN_PLATFORM     32     /**< Minimum for platform source    */
37a8e1175bSopenharmony_ci#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
38a8e1175bSopenharmony_ci#define MBEDTLS_ENTROPY_MIN_HARDWARE     32     /**< Minimum for the hardware source */
39a8e1175bSopenharmony_ci#endif
40a8e1175bSopenharmony_ci
41a8e1175bSopenharmony_ci#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
42a8e1175bSopenharmony_ci/**
43a8e1175bSopenharmony_ci * \brief           Platform-specific entropy poll callback
44a8e1175bSopenharmony_ci */
45a8e1175bSopenharmony_ciint mbedtls_platform_entropy_poll(void *data,
46a8e1175bSopenharmony_ci                                  unsigned char *output, size_t len, size_t *olen);
47a8e1175bSopenharmony_ci#endif
48a8e1175bSopenharmony_ci
49a8e1175bSopenharmony_ci#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
50a8e1175bSopenharmony_ci/**
51a8e1175bSopenharmony_ci * \brief           Entropy poll callback for a hardware source
52a8e1175bSopenharmony_ci *
53a8e1175bSopenharmony_ci * \warning         This is not provided by mbed TLS!
54a8e1175bSopenharmony_ci *                  See \c MBEDTLS_ENTROPY_HARDWARE_ALT in mbedtls_config.h.
55a8e1175bSopenharmony_ci *
56a8e1175bSopenharmony_ci * \note            This must accept NULL as its first argument.
57a8e1175bSopenharmony_ci */
58a8e1175bSopenharmony_ciint mbedtls_hardware_poll(void *data,
59a8e1175bSopenharmony_ci                          unsigned char *output, size_t len, size_t *olen);
60a8e1175bSopenharmony_ci#endif
61a8e1175bSopenharmony_ci
62a8e1175bSopenharmony_ci#if defined(MBEDTLS_ENTROPY_NV_SEED)
63a8e1175bSopenharmony_ci/**
64a8e1175bSopenharmony_ci * \brief           Entropy poll callback for a non-volatile seed file
65a8e1175bSopenharmony_ci *
66a8e1175bSopenharmony_ci * \note            This must accept NULL as its first argument.
67a8e1175bSopenharmony_ci */
68a8e1175bSopenharmony_ciint mbedtls_nv_seed_poll(void *data,
69a8e1175bSopenharmony_ci                         unsigned char *output, size_t len, size_t *olen);
70a8e1175bSopenharmony_ci#endif
71a8e1175bSopenharmony_ci
72a8e1175bSopenharmony_ci#ifdef __cplusplus
73a8e1175bSopenharmony_ci}
74a8e1175bSopenharmony_ci#endif
75a8e1175bSopenharmony_ci
76a8e1175bSopenharmony_ci#endif /* entropy_poll.h */
77