blob: 34746f9d1cfc35747a6d0d792ffd74520f33c1f0 [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é-Gonnarda658a402015-01-23 09:45:19 +00006 * Copyright (C) 2006-2011, 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/*
40 * Default thresholds for built-in sources
41 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020042#define MBEDTLS_ENTROPY_MIN_PLATFORM 128 /**< Minimum for platform source */
43#define MBEDTLS_ENTROPY_MIN_HAVEGE 128 /**< Minimum for HAVEGE */
44#define MBEDTLS_ENTROPY_MIN_HARDCLOCK 32 /**< Minimum for mbedtls_timing_hardclock() */
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000045
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020046#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
Paul Bakker6083fd22011-12-03 21:45:14 +000047/**
48 * \brief Platform-specific entropy poll callback
49 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020050int mbedtls_platform_entropy_poll( void *data,
Paul Bakker6083fd22011-12-03 21:45:14 +000051 unsigned char *output, size_t len, size_t *olen );
52#endif
53
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020054#if defined(MBEDTLS_HAVEGE_C)
Paul Bakker6083fd22011-12-03 21:45:14 +000055/**
56 * \brief HAVEGE based entropy poll callback
57 *
58 * Requires an HAVEGE state as its data pointer.
59 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020060int mbedtls_havege_poll( void *data,
Paul Bakker6083fd22011-12-03 21:45:14 +000061 unsigned char *output, size_t len, size_t *olen );
62#endif
63
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020064#if defined(MBEDTLS_TIMING_C)
Paul Bakker6083fd22011-12-03 21:45:14 +000065/**
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020066 * \brief mbedtls_timing_hardclock-based entropy poll callback
Paul Bakker6083fd22011-12-03 21:45:14 +000067 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020068int mbedtls_hardclock_poll( void *data,
Paul Bakker6083fd22011-12-03 21:45:14 +000069 unsigned char *output, size_t len, size_t *olen );
70#endif
71
72#ifdef __cplusplus
73}
74#endif
75
76#endif /* entropy_poll.h */