Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers entropy_poll.h Source File

entropy_poll.h

Go to the documentation of this file.
00001 /**
00002  * \file entropy_poll.h
00003  *
00004  * \brief Platform-specific and custom entropy polling functions
00005  */
00006 /*
00007  *  Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
00008  *  SPDX-License-Identifier: Apache-2.0
00009  *
00010  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
00011  *  not use this file except in compliance with the License.
00012  *  You may obtain a copy of the License at
00013  *
00014  *  http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  *  Unless required by applicable law or agreed to in writing, software
00017  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00018  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  *  See the License for the specific language governing permissions and
00020  *  limitations under the License.
00021  *
00022  *  This file is part of mbed TLS (https://tls.mbed.org)
00023  */
00024 #ifndef MBEDTLS_ENTROPY_POLL_H
00025 #define MBEDTLS_ENTROPY_POLL_H
00026 
00027 #if !defined(MBEDTLS_CONFIG_FILE)
00028 #include "config.h"
00029 #else
00030 #include MBEDTLS_CONFIG_FILE
00031 #endif
00032 
00033 #include <stddef.h>
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 /*
00040  * Default thresholds for built-in sources, in bytes
00041  */
00042 #define MBEDTLS_ENTROPY_MIN_PLATFORM     32     /**< Minimum for platform source    */
00043 #define MBEDTLS_ENTROPY_MIN_HAVEGE       32     /**< Minimum for HAVEGE             */
00044 #define MBEDTLS_ENTROPY_MIN_HARDCLOCK     4     /**< Minimum for mbedtls_timing_hardclock()        */
00045 #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
00046 #define MBEDTLS_ENTROPY_MIN_HARDWARE     32     /**< Minimum for the hardware source */
00047 #endif
00048 
00049 /**
00050  * \brief           Entropy poll callback that provides 0 entropy.
00051  */
00052 #if defined(MBEDTLS_TEST_NULL_ENTROPY)
00053     int mbedtls_null_entropy_poll( void *data,
00054                                 unsigned char *output, size_t len, size_t *olen );
00055 #endif
00056 
00057 #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
00058 /**
00059  * \brief           Platform-specific entropy poll callback
00060  */
00061 int mbedtls_platform_entropy_poll( void *data,
00062                            unsigned char *output, size_t len, size_t *olen );
00063 #endif
00064 
00065 #if defined(MBEDTLS_HAVEGE_C)
00066 /**
00067  * \brief           HAVEGE based entropy poll callback
00068  *
00069  * Requires an HAVEGE state as its data pointer.
00070  */
00071 int mbedtls_havege_poll( void *data,
00072                  unsigned char *output, size_t len, size_t *olen );
00073 #endif
00074 
00075 #if defined(MBEDTLS_TIMING_C)
00076 /**
00077  * \brief           mbedtls_timing_hardclock-based entropy poll callback
00078  */
00079 int mbedtls_hardclock_poll( void *data,
00080                     unsigned char *output, size_t len, size_t *olen );
00081 #endif
00082 
00083 #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
00084 /**
00085  * \brief           Entropy poll callback for a hardware source
00086  *
00087  * \warning         This is not provided by mbed TLS!
00088  *                  See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h.
00089  *
00090  * \note            This must accept NULL as its first argument.
00091  */
00092 int mbedtls_hardware_poll( void *data,
00093                            unsigned char *output, size_t len, size_t *olen );
00094 #endif
00095 
00096 #if defined(MBEDTLS_ENTROPY_NV_SEED)
00097 /**
00098  * \brief           Entropy poll callback for a non-volatile seed file
00099  *
00100  * \note            This must accept NULL as its first argument.
00101  */
00102 int mbedtls_nv_seed_poll( void *data,
00103                           unsigned char *output, size_t len, size_t *olen );
00104 #endif
00105 
00106 #ifdef __cplusplus
00107 }
00108 #endif
00109 
00110 #endif /* entropy_poll.h */