comparison src/headers/tomcrypt_prng.h @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16

Update to LibTomCrypt 1.16
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 02:22:00 +0000
parents 59400faa4b44
children
comparison
equal deleted inserted replaced
280:59400faa4b44 380:d5faf4814ddb
2 #ifdef YARROW 2 #ifdef YARROW
3 struct yarrow_prng { 3 struct yarrow_prng {
4 int cipher, hash; 4 int cipher, hash;
5 unsigned char pool[MAXBLOCKSIZE]; 5 unsigned char pool[MAXBLOCKSIZE];
6 symmetric_CTR ctr; 6 symmetric_CTR ctr;
7 LTC_MUTEX_TYPE(prng_lock)
7 }; 8 };
8 #endif 9 #endif
9 10
10 #ifdef RC4 11 #ifdef RC4
11 struct rc4_prng { 12 struct rc4_prng {
26 unsigned long pool_idx, /* current pool we will add to */ 27 unsigned long pool_idx, /* current pool we will add to */
27 pool0_len, /* length of 0'th pool */ 28 pool0_len, /* length of 0'th pool */
28 wd; 29 wd;
29 30
30 ulong64 reset_cnt; /* number of times we have reset */ 31 ulong64 reset_cnt; /* number of times we have reset */
32 LTC_MUTEX_TYPE(prng_lock)
31 }; 33 };
32 #endif 34 #endif
33 35
34 #ifdef SOBER128 36 #ifdef SOBER128
35 struct sober128_prng { 37 struct sober128_prng {
44 46
45 }; 47 };
46 #endif 48 #endif
47 49
48 typedef union Prng_state { 50 typedef union Prng_state {
51 char dummy[1];
49 #ifdef YARROW 52 #ifdef YARROW
50 struct yarrow_prng yarrow; 53 struct yarrow_prng yarrow;
51 #endif 54 #endif
52 #ifdef RC4 55 #ifdef RC4
53 struct rc4_prng rc4; 56 struct rc4_prng rc4;
58 #ifdef SOBER128 61 #ifdef SOBER128
59 struct sober128_prng sober128; 62 struct sober128_prng sober128;
60 #endif 63 #endif
61 } prng_state; 64 } prng_state;
62 65
66 /** PRNG descriptor */
63 extern struct ltc_prng_descriptor { 67 extern struct ltc_prng_descriptor {
64 /** Name of the PRNG */ 68 /** Name of the PRNG */
65 char *name; 69 char *name;
66 /** size in bytes of exported state */ 70 /** size in bytes of exported state */
67 int export_size; 71 int export_size;
176 180
177 int find_prng(const char *name); 181 int find_prng(const char *name);
178 int register_prng(const struct ltc_prng_descriptor *prng); 182 int register_prng(const struct ltc_prng_descriptor *prng);
179 int unregister_prng(const struct ltc_prng_descriptor *prng); 183 int unregister_prng(const struct ltc_prng_descriptor *prng);
180 int prng_is_valid(int idx); 184 int prng_is_valid(int idx);
181 LTC_MUTEX_PROTO(ltc_prng_mutex); 185 LTC_MUTEX_PROTO(ltc_prng_mutex)
182 186
183 /* Slow RNG you **might** be able to use to seed a PRNG with. Be careful as this 187 /* Slow RNG you **might** be able to use to seed a PRNG with. Be careful as this
184 * might not work on all platforms as planned 188 * might not work on all platforms as planned
185 */ 189 */
186 unsigned long rng_get_bytes(unsigned char *out, 190 unsigned long rng_get_bytes(unsigned char *out,
189 193
190 int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void)); 194 int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void));
191 195
192 196
193 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_prng.h,v $ */ 197 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_prng.h,v $ */
194 /* $Revision: 1.3 $ */ 198 /* $Revision: 1.8 $ */
195 /* $Date: 2005/06/19 18:00:28 $ */ 199 /* $Date: 2006/11/05 01:36:43 $ */