| 1 | /** |
| 2 | * \file havege.h |
| 3 | * |
| 4 | * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine |
| 5 | * |
| 6 | * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org> |
| 7 | * |
| 8 | * All rights reserved. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * |
| 14 | * * Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * * Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * * Neither the names of PolarSSL or XySSL nor the names of its contributors |
| 20 | * may be used to endorse or promote products derived from this software |
| 21 | * without specific prior written permission. |
| 22 | * |
| 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 29 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 30 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | */ |
| 35 | #ifndef POLARSSL_HAVEGE_H |
| 36 | #define POLARSSL_HAVEGE_H |
| 37 | |
| 38 | #define COLLECT_SIZE 1024 |
| 39 | |
| 40 | /** |
| 41 | * \brief HAVEGE state structure |
| 42 | */ |
| 43 | typedef struct |
| 44 | { |
| 45 | int PT1, PT2, offset[2]; |
| 46 | int pool[COLLECT_SIZE]; |
| 47 | int WALK[8192]; |
| 48 | } |
| 49 | havege_state; |
| 50 | |
| 51 | #ifdef __cplusplus |
| 52 | extern "C" { |
| 53 | #endif |
| 54 | |
| 55 | /** |
| 56 | * \brief HAVEGE initialization |
| 57 | * |
| 58 | * \param hs HAVEGE state to be initialized |
| 59 | */ |
| 60 | void havege_init( havege_state *hs ); |
| 61 | |
| 62 | /** |
| 63 | * \brief HAVEGE rand function |
| 64 | * |
| 65 | * \param rng_st points to an HAVEGE state |
| 66 | * |
| 67 | * \return A random int |
| 68 | */ |
| 69 | int havege_rand( void *p_rng ); |
| 70 | |
| 71 | #ifdef __cplusplus |
| 72 | } |
| 73 | #endif |
| 74 | |
| 75 | #endif /* havege.h */ |
| 76 | |