blob: 82842ce9d26cd6e188f68f9bbee36aa5c03af98d [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 *
Paul Bakker530927b2015-02-13 14:24:10 +01006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Paul Bakker6083fd22011-12-03 21:45:14 +00007 *
Manuel Pégourié-Gonnarde12abf92015-01-28 17:13:45 +00008 * This file is part of mbed TLS (https://polarssl.org)
Paul Bakker6083fd22011-12-03 21:45:14 +00009 *
10 * 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
29#include "config.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
Paul Bakkerbd4a9d02011-12-10 17:02:19 +000035/*
36 * Default thresholds for built-in sources
37 */
38#define ENTROPY_MIN_PLATFORM 128 /**< Minimum for platform source */
39#define ENTROPY_MIN_HAVEGE 128 /**< Minimum for HAVEGE */
40#define ENTROPY_MIN_HARDCLOCK 32 /**< Minimum for hardclock() */
41
Paul Bakker6083fd22011-12-03 21:45:14 +000042#if !defined(POLARSSL_NO_PLATFORM_ENTROPY)
43/**
44 * \brief Platform-specific entropy poll callback
45 */
46int platform_entropy_poll( void *data,
47 unsigned char *output, size_t len, size_t *olen );
48#endif
49
50#if defined(POLARSSL_HAVEGE_C)
51/**
52 * \brief HAVEGE based entropy poll callback
53 *
54 * Requires an HAVEGE state as its data pointer.
55 */
56int havege_poll( void *data,
57 unsigned char *output, size_t len, size_t *olen );
58#endif
59
60#if defined(POLARSSL_TIMING_C)
61/**
62 * \brief hardclock-based entropy poll callback
63 */
64int hardclock_poll( void *data,
65 unsigned char *output, size_t len, size_t *olen );
66#endif
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* entropy_poll.h */