1 /* This file is derived from sober128 implementation in corosync 2 cluster engine. corosync cluster engine borrows the implementation 3 from LibTomCrypt. 4 5 The latest version of the original code can be found at 6 http://www.libtom.net/LibTomCrypt/ according to which this code is in the 7 Public Domain 8 */ 9 10 /* About LibTomCrypt: 11 * --------------------------------------------------------------------- 12 * LibTomCrypt, modular cryptographic library -- Tom St Denis 13 * 14 * LibTomCrypt is a library that provides various cryptographic 15 * algorithms in a highly modular and flexible manner. 16 * 17 * The library is free for all purposes without any express 18 * guarantee it works. 19 * 20 * Tom St Denis, tomstdenis@iahu.ca, http://www.libtom.net/LibTomCrypt/ 21 */ 22 23 #ifndef _SOBER127_H 24 #define _SOBER127_H 25 26 #include "ws_symbol_export.h" 27 28 typedef struct _sober128_prng { 29 unsigned long R[17], /* Working storage for the shift register */ 30 initR[17], /* saved register contents */ 31 konst, /* key dependent constant */ 32 sbuf; /* partial word encryption buffer */ 33 34 int nbuf, /* number of part-word stream bits buffered */ 35 flag, /* first add_entropy call or not? */ 36 set; /* did we call add_entropy to set key? */ 37 38 } sober128_prng; 39 40 WS_DLL_PUBLIC 41 int sober128_start(sober128_prng *prng); 42 WS_DLL_PUBLIC 43 int sober128_add_entropy(const unsigned char *buf, unsigned long len, sober128_prng *prng); 44 WS_DLL_PUBLIC 45 unsigned long sober128_read(unsigned char *buf, unsigned long len, sober128_prng *prng); 46 47 #endif /* sober128.h */ 48