| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /** | 
|  | 2 | * \file havege.h | 
| Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 3 | * | 
| Paul Bakker | f3b86c1 | 2011-01-27 15:24:17 +0000 | [diff] [blame] | 4 | * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion | 
| Paul Bakker | 37ca75d | 2011-01-06 12:28:03 +0000 | [diff] [blame] | 5 | * | 
| Paul Bakker | 84f12b7 | 2010-07-18 10:13:04 +0000 | [diff] [blame] | 6 | *  Copyright (C) 2006-2010, Brainspark B.V. | 
| Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 7 | * | 
|  | 8 | *  This file is part of PolarSSL (http://www.polarssl.org) | 
| Paul Bakker | 84f12b7 | 2010-07-18 10:13:04 +0000 | [diff] [blame] | 9 | *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> | 
| Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 10 | * | 
| Paul Bakker | 77b385e | 2009-07-28 17:23:11 +0000 | [diff] [blame] | 11 | *  All rights reserved. | 
| Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 12 | * | 
| Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 13 | *  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 Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 26 | */ | 
| Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 27 | #ifndef POLARSSL_HAVEGE_H | 
|  | 28 | #define POLARSSL_HAVEGE_H | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 29 |  | 
| Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 30 | #include <string.h> | 
|  | 31 |  | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 32 | #define COLLECT_SIZE 1024 | 
|  | 33 |  | 
|  | 34 | /** | 
|  | 35 | * \brief          HAVEGE state structure | 
|  | 36 | */ | 
|  | 37 | typedef struct | 
|  | 38 | { | 
|  | 39 | int PT1, PT2, offset[2]; | 
|  | 40 | int pool[COLLECT_SIZE]; | 
|  | 41 | int WALK[8192]; | 
|  | 42 | } | 
|  | 43 | havege_state; | 
|  | 44 |  | 
|  | 45 | #ifdef __cplusplus | 
|  | 46 | extern "C" { | 
|  | 47 | #endif | 
|  | 48 |  | 
|  | 49 | /** | 
|  | 50 | * \brief          HAVEGE initialization | 
|  | 51 | * | 
|  | 52 | * \param hs       HAVEGE state to be initialized | 
|  | 53 | */ | 
|  | 54 | void havege_init( havege_state *hs ); | 
|  | 55 |  | 
|  | 56 | /** | 
|  | 57 | * \brief          HAVEGE rand function | 
|  | 58 | * | 
| Paul Bakker | 13e2dfe | 2009-07-28 07:18:38 +0000 | [diff] [blame] | 59 | * \param p_rng    A HAVEGE state | 
| Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 60 | * \param output   Buffer to fill | 
|  | 61 | * \param len      Length of buffer | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 62 | * | 
| Paul Bakker | e708e5c | 2012-02-03 08:13:57 +0000 | [diff] [blame] | 63 | * \return         0 | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 64 | */ | 
| Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 65 | int havege_random( void *p_rng, unsigned char *output, size_t len ); | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 66 |  | 
|  | 67 | #ifdef __cplusplus | 
|  | 68 | } | 
|  | 69 | #endif | 
|  | 70 |  | 
|  | 71 | #endif /* havege.h */ |