blob: 536eb088227367d5fb1c3210d4a7346f79da2af7 [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 Bakker407a0da2013-06-27 14:29:21 +02006 * Copyright (C) 2006-2013, Brainspark B.V.
Paul Bakkerb96f1542010-07-18 20:36:00 +00007 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
Paul Bakker84f12b72010-07-18 10:13:04 +00009 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakkerb96f1542010-07-18 20:36:00 +000010 *
Paul Bakker77b385e2009-07-28 17:23:11 +000011 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000012 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000013 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000026 */
Paul Bakker40e46942009-01-03 21:51:57 +000027#ifndef POLARSSL_HAVEGE_H
28#define POLARSSL_HAVEGE_H
Paul Bakker5121ce52009-01-03 21:22:43 +000029
Paul Bakkera3d195c2011-11-27 21:07:34 +000030#include <string.h>
31
Paul Bakker5121ce52009-01-03 21:22:43 +000032#define COLLECT_SIZE 1024
33
Paul Bakker407a0da2013-06-27 14:29:21 +020034#ifdef __cplusplus
35extern "C" {
36#endif
37
Paul Bakker5121ce52009-01-03 21:22:43 +000038/**
39 * \brief HAVEGE state structure
40 */
41typedef struct
42{
43 int PT1, PT2, offset[2];
44 int pool[COLLECT_SIZE];
45 int WALK[8192];
46}
47havege_state;
48
Paul Bakker5121ce52009-01-03 21:22:43 +000049/**
50 * \brief HAVEGE initialization
51 *
52 * \param hs HAVEGE state to be initialized
53 */
54void havege_init( havege_state *hs );
55
56/**
Paul Bakkera317a982014-06-18 16:44:11 +020057 * \brief Clear HAVEGE state
58 *
59 * \param hs HAVEGE state to be cleared
60 */
61void havege_free( havege_state *hs );
62
63/**
Paul Bakker5121ce52009-01-03 21:22:43 +000064 * \brief HAVEGE rand function
65 *
Paul Bakker13e2dfe2009-07-28 07:18:38 +000066 * \param p_rng A HAVEGE state
Paul Bakkera3d195c2011-11-27 21:07:34 +000067 * \param output Buffer to fill
68 * \param len Length of buffer
Paul Bakker5121ce52009-01-03 21:22:43 +000069 *
Paul Bakkere708e5c2012-02-03 08:13:57 +000070 * \return 0
Paul Bakker5121ce52009-01-03 21:22:43 +000071 */
Paul Bakkera3d195c2011-11-27 21:07:34 +000072int havege_random( void *p_rng, unsigned char *output, size_t len );
Paul Bakker5121ce52009-01-03 21:22:43 +000073
74#ifdef __cplusplus
75}
76#endif
77
78#endif /* havege.h */