blob: 9c349da2a9b6dc994f857b9674fa7a41a8e413d7 [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é-Gonnard860b5162015-01-28 17:12:07 +00008 * This file is part of mbed TLS (https://polarssl.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 */
24#ifndef POLARSSL_ENTROPY_POLL_H
25#define POLARSSL_ENTROPY_POLL_H
26
27#include <string.h>
28
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020029#if !defined(POLARSSL_CONFIG_FILE)
Paul Bakker6083fd22011-12-03 21:45:14 +000030#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020031#else
32#include POLARSSL_CONFIG_FILE
33#endif
Paul Bakker6083fd22011-12-03 21:45:14 +000034
35#ifdef __cplusplus
36extern "C" {
37#endif
38
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000039/*
40 * Default thresholds for built-in sources
41 */
42#define ENTROPY_MIN_PLATFORM 128 /**< Minimum for platform source */
43#define ENTROPY_MIN_HAVEGE 128 /**< Minimum for HAVEGE */
44#define ENTROPY_MIN_HARDCLOCK 32 /**< Minimum for hardclock() */
45
Paul Bakker6083fd22011-12-03 21:45:14 +000046#if !defined(POLARSSL_NO_PLATFORM_ENTROPY)
47/**
48 * \brief Platform-specific entropy poll callback
49 */
50int platform_entropy_poll( void *data,
51 unsigned char *output, size_t len, size_t *olen );
52#endif
53
54#if defined(POLARSSL_HAVEGE_C)
55/**
56 * \brief HAVEGE based entropy poll callback
57 *
58 * Requires an HAVEGE state as its data pointer.
59 */
60int havege_poll( void *data,
61 unsigned char *output, size_t len, size_t *olen );
62#endif
63
64#if defined(POLARSSL_TIMING_C)
65/**
66 * \brief hardclock-based entropy poll callback
67 */
68int hardclock_poll( void *data,
69 unsigned char *output, size_t len, size_t *olen );
70#endif
71
72#ifdef __cplusplus
73}
74#endif
75
76#endif /* entropy_poll.h */