| 1 | /** |
|---|
| 2 | * \file havege.h |
|---|
| 3 | * |
|---|
| 4 | * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion |
|---|
| 5 | * |
|---|
| 6 | * Copyright (C) 2006-2010, Brainspark B.V. |
|---|
| 7 | * |
|---|
| 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
|---|
| 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
|---|
| 10 | * |
|---|
| 11 | * All rights reserved. |
|---|
| 12 | * |
|---|
| 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. |
|---|
| 26 | */ |
|---|
| 27 | #ifndef POLARSSL_HAVEGE_H |
|---|
| 28 | #define POLARSSL_HAVEGE_H |
|---|
| 29 | |
|---|
| 30 | #include <string.h> |
|---|
| 31 | |
|---|
| 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 | * |
|---|
| 59 | * \param p_rng A HAVEGE state |
|---|
| 60 | * \param output Buffer to fill |
|---|
| 61 | * \param len Length of buffer |
|---|
| 62 | * |
|---|
| 63 | * \return 0 |
|---|
| 64 | */ |
|---|
| 65 | int havege_random( void *p_rng, unsigned char *output, size_t len ); |
|---|
| 66 | |
|---|
| 67 | #ifdef __cplusplus |
|---|
| 68 | } |
|---|
| 69 | #endif |
|---|
| 70 | |
|---|
| 71 | #endif /* havege.h */ |
|---|