[398] | 1 | /**
|
---|
| 2 | * \file entropy_poll.h
|
---|
| 3 | *
|
---|
| 4 | * \brief Platform-specific and custom entropy polling functions
|
---|
| 5 | */
|
---|
| 6 | /*
|
---|
| 7 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
---|
| 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 | * This file is part of mbed TLS (https://tls.mbed.org)
|
---|
| 23 | */
|
---|
| 24 | #ifndef MBEDTLS_ENTROPY_POLL_H
|
---|
| 25 | #define MBEDTLS_ENTROPY_POLL_H
|
---|
| 26 |
|
---|
| 27 | #if !defined(MBEDTLS_CONFIG_FILE)
|
---|
| 28 | #include "config.h"
|
---|
| 29 | #else
|
---|
| 30 | #include MBEDTLS_CONFIG_FILE
|
---|
| 31 | #endif
|
---|
| 32 |
|
---|
| 33 | #include <stddef.h>
|
---|
| 34 |
|
---|
| 35 | #ifdef __cplusplus
|
---|
| 36 | extern "C" {
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 | /*
|
---|
| 40 | * Default thresholds for built-in sources, in bytes
|
---|
| 41 | */
|
---|
| 42 | #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
|
---|
| 43 | #define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */
|
---|
| 44 | #define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */
|
---|
| 45 | #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
|
---|
| 46 | #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
|
---|
| 47 | #endif
|
---|
| 48 |
|
---|
| 49 | /**
|
---|
| 50 | * \brief Entropy poll callback that provides 0 entropy.
|
---|
| 51 | */
|
---|
| 52 | #if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
---|
| 53 | int mbedtls_null_entropy_poll( void *data,
|
---|
| 54 | unsigned char *output, size_t len, size_t *olen );
|
---|
| 55 | #endif
|
---|
| 56 |
|
---|
| 57 | #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
|
---|
| 58 | /**
|
---|
| 59 | * \brief Platform-specific entropy poll callback
|
---|
| 60 | */
|
---|
| 61 | int mbedtls_platform_entropy_poll( void *data,
|
---|
| 62 | unsigned char *output, size_t len, size_t *olen );
|
---|
| 63 | #endif
|
---|
| 64 |
|
---|
| 65 | #if defined(MBEDTLS_HAVEGE_C)
|
---|
| 66 | /**
|
---|
| 67 | * \brief HAVEGE based entropy poll callback
|
---|
| 68 | *
|
---|
| 69 | * Requires an HAVEGE state as its data pointer.
|
---|
| 70 | */
|
---|
| 71 | int mbedtls_havege_poll( void *data,
|
---|
| 72 | unsigned char *output, size_t len, size_t *olen );
|
---|
| 73 | #endif
|
---|
| 74 |
|
---|
| 75 | #if defined(MBEDTLS_TIMING_C)
|
---|
| 76 | /**
|
---|
| 77 | * \brief mbedtls_timing_hardclock-based entropy poll callback
|
---|
| 78 | */
|
---|
| 79 | int mbedtls_hardclock_poll( void *data,
|
---|
| 80 | unsigned char *output, size_t len, size_t *olen );
|
---|
| 81 | #endif
|
---|
| 82 |
|
---|
| 83 | #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
---|
| 84 | /**
|
---|
| 85 | * \brief Entropy poll callback for a hardware source
|
---|
| 86 | *
|
---|
| 87 | * \warning This is not provided by mbed TLS!
|
---|
| 88 | * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h.
|
---|
| 89 | *
|
---|
| 90 | * \note This must accept NULL as its first argument.
|
---|
| 91 | */
|
---|
| 92 | int mbedtls_hardware_poll( void *data,
|
---|
| 93 | unsigned char *output, size_t len, size_t *olen );
|
---|
| 94 | #endif
|
---|
| 95 |
|
---|
| 96 | #if defined(MBEDTLS_ENTROPY_NV_SEED)
|
---|
| 97 | /**
|
---|
| 98 | * \brief Entropy poll callback for a non-volatile seed file
|
---|
| 99 | *
|
---|
| 100 | * \note This must accept NULL as its first argument.
|
---|
| 101 | */
|
---|
| 102 | int mbedtls_nv_seed_poll( void *data,
|
---|
| 103 | unsigned char *output, size_t len, size_t *olen );
|
---|
| 104 | #endif
|
---|
| 105 |
|
---|
| 106 | #ifdef __cplusplus
|
---|
| 107 | }
|
---|
| 108 | #endif
|
---|
| 109 |
|
---|
| 110 | #endif /* entropy_poll.h */
|
---|