blob: ca0459ac6e80501a7ef4454591f493fd00f442b0 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file havege.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakkerf3b86c12011-01-27 15:24:17 +00004 * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
Paul Bakker37ca75d2011-01-06 12:28:03 +00005 *
Paul Bakker530927b2015-02-13 14:24:10 +01006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Paul Bakkerb96f1542010-07-18 20:36:00 +00007 *
Manuel Pégourié-Gonnarde12abf92015-01-28 17:13:45 +00008 * This file is part of mbed TLS (https://polarssl.org)
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00009 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +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.
Paul Bakker5121ce52009-01-03 21:22:43 +000023 */
Paul Bakker40e46942009-01-03 21:51:57 +000024#ifndef POLARSSL_HAVEGE_H
25#define POLARSSL_HAVEGE_H
Paul Bakker5121ce52009-01-03 21:22:43 +000026
Paul Bakkera3d195c2011-11-27 21:07:34 +000027#include <string.h>
28
Paul Bakker5121ce52009-01-03 21:22:43 +000029#define COLLECT_SIZE 1024
30
31/**
32 * \brief HAVEGE state structure
33 */
34typedef struct
35{
36 int PT1, PT2, offset[2];
37 int pool[COLLECT_SIZE];
38 int WALK[8192];
39}
40havege_state;
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/**
47 * \brief HAVEGE initialization
48 *
49 * \param hs HAVEGE state to be initialized
50 */
51void havege_init( havege_state *hs );
52
53/**
54 * \brief HAVEGE rand function
55 *
Paul Bakker13e2dfe2009-07-28 07:18:38 +000056 * \param p_rng A HAVEGE state
Paul Bakkera3d195c2011-11-27 21:07:34 +000057 * \param output Buffer to fill
58 * \param len Length of buffer
Paul Bakker5121ce52009-01-03 21:22:43 +000059 *
Paul Bakkere708e5c2012-02-03 08:13:57 +000060 * \return 0
Paul Bakker5121ce52009-01-03 21:22:43 +000061 */
Paul Bakkera3d195c2011-11-27 21:07:34 +000062int havege_random( void *p_rng, unsigned char *output, size_t len );
Paul Bakker5121ce52009-01-03 21:22:43 +000063
64#ifdef __cplusplus
65}
66#endif
67
68#endif /* havege.h */