blob: f2857809e3b908ccd78d2e9ce4df68212418347a [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
5 *
Manuel Pégourié-Gonnard6fb81872015-07-27 11:11:48 +02006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Paul Bakker6083fd22011-12-03 21:45:14 +00007 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +00008 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker6083fd22011-12-03 21:45:14 +00009 *
Paul Bakker6083fd22011-12-03 21:45:14 +000010 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020024#ifndef MBEDTLS_ENTROPY_POLL_H
25#define MBEDTLS_ENTROPY_POLL_H
Paul Bakker6083fd22011-12-03 21:45:14 +000026
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020027#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker6083fd22011-12-03 21:45:14 +000028#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020029#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020030#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020031#endif
Paul Bakker6083fd22011-12-03 21:45:14 +000032
Rich Evans00ab4702015-02-06 13:43:58 +000033#include <stddef.h>
34
Paul Bakker6083fd22011-12-03 21:45:14 +000035#ifdef __cplusplus
36extern "C" {
37#endif
38
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000039/*
Manuel Pégourié-Gonnardbf82ff02015-06-19 09:40:51 +020040 * Default thresholds for built-in sources, in bytes
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000041 */
Manuel Pégourié-Gonnardbf82ff02015-06-19 09:40:51 +020042#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() */
Manuel Pégourié-Gonnard3f77dfb2015-06-19 10:06:21 +020045#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000046
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020047#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
Paul Bakker6083fd22011-12-03 21:45:14 +000048/**
49 * \brief Platform-specific entropy poll callback
50 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020051int mbedtls_platform_entropy_poll( void *data,
Paul Bakker6083fd22011-12-03 21:45:14 +000052 unsigned char *output, size_t len, size_t *olen );
53#endif
54
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020055#if defined(MBEDTLS_HAVEGE_C)
Paul Bakker6083fd22011-12-03 21:45:14 +000056/**
57 * \brief HAVEGE based entropy poll callback
58 *
59 * Requires an HAVEGE state as its data pointer.
60 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020061int mbedtls_havege_poll( void *data,
Paul Bakker6083fd22011-12-03 21:45:14 +000062 unsigned char *output, size_t len, size_t *olen );
63#endif
64
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020065#if defined(MBEDTLS_TIMING_C)
Paul Bakker6083fd22011-12-03 21:45:14 +000066/**
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020067 * \brief mbedtls_timing_hardclock-based entropy poll callback
Paul Bakker6083fd22011-12-03 21:45:14 +000068 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020069int mbedtls_hardclock_poll( void *data,
Paul Bakker6083fd22011-12-03 21:45:14 +000070 unsigned char *output, size_t len, size_t *olen );
71#endif
72
Manuel Pégourié-Gonnard3f77dfb2015-06-19 10:06:21 +020073#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
74/**
75 * \brief Entropy poll callback for a hardware source
76 *
77 * \warning This is not provided by mbed TLS!
78 * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h.
79 *
80 * \note This must accept NULL as its first argument.
81 */
82int mbedtls_hardware_poll( void *data,
83 unsigned char *output, size_t len, size_t *olen );
84#endif
85
Paul Bakker6083fd22011-12-03 21:45:14 +000086#ifdef __cplusplus
87}
88#endif
89
90#endif /* entropy_poll.h */