Mercurial > dropbear
comparison libtomcrypt/src/headers/tomcrypt_prng.h @ 1439:8d24733026c5 coverity
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 24 Jun 2017 23:33:16 +0800 |
parents | f849a5ca2efc |
children | 6dba84798cd5 |
comparison
equal
deleted
inserted
replaced
1400:238a439670f5 | 1439:8d24733026c5 |
---|---|
1 /* ---- PRNG Stuff ---- */ | 1 /* ---- PRNG Stuff ---- */ |
2 #ifdef YARROW | 2 #ifdef LTC_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 LTC_MUTEX_TYPE(prng_lock) |
8 }; | 8 }; |
9 #endif | 9 #endif |
10 | 10 |
11 #ifdef RC4 | 11 #ifdef LTC_RC4 |
12 struct rc4_prng { | 12 struct rc4_prng { |
13 int x, y; | 13 int x, y; |
14 unsigned char buf[256]; | 14 unsigned char buf[256]; |
15 }; | 15 }; |
16 #endif | 16 #endif |
17 | 17 |
18 #ifdef FORTUNA | 18 #ifdef LTC_FORTUNA |
19 struct fortuna_prng { | 19 struct fortuna_prng { |
20 hash_state pool[FORTUNA_POOLS]; /* the pools */ | 20 hash_state pool[LTC_FORTUNA_POOLS]; /* the pools */ |
21 | 21 |
22 symmetric_key skey; | 22 symmetric_key skey; |
23 | 23 |
24 unsigned char K[32], /* the current key */ | 24 unsigned char K[32], /* the current key */ |
25 IV[16]; /* IV for CTR mode */ | 25 IV[16]; /* IV for CTR mode */ |
31 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) | 32 LTC_MUTEX_TYPE(prng_lock) |
33 }; | 33 }; |
34 #endif | 34 #endif |
35 | 35 |
36 #ifdef SOBER128 | 36 #ifdef LTC_SOBER128 |
37 struct sober128_prng { | 37 struct sober128_prng { |
38 ulong32 R[17], /* Working storage for the shift register */ | 38 ulong32 R[17], /* Working storage for the shift register */ |
39 initR[17], /* saved register contents */ | 39 initR[17], /* saved register contents */ |
40 konst, /* key dependent constant */ | 40 konst, /* key dependent constant */ |
41 sbuf; /* partial word encryption buffer */ | 41 sbuf; /* partial word encryption buffer */ |
47 }; | 47 }; |
48 #endif | 48 #endif |
49 | 49 |
50 typedef union Prng_state { | 50 typedef union Prng_state { |
51 char dummy[1]; | 51 char dummy[1]; |
52 #ifdef YARROW | 52 #ifdef LTC_YARROW |
53 struct yarrow_prng yarrow; | 53 struct yarrow_prng yarrow; |
54 #endif | 54 #endif |
55 #ifdef RC4 | 55 #ifdef LTC_RC4 |
56 struct rc4_prng rc4; | 56 struct rc4_prng rc4; |
57 #endif | 57 #endif |
58 #ifdef FORTUNA | 58 #ifdef LTC_FORTUNA |
59 struct fortuna_prng fortuna; | 59 struct fortuna_prng fortuna; |
60 #endif | 60 #endif |
61 #ifdef SOBER128 | 61 #ifdef LTC_SOBER128 |
62 struct sober128_prng sober128; | 62 struct sober128_prng sober128; |
63 #endif | 63 #endif |
64 } prng_state; | 64 } prng_state; |
65 | 65 |
66 /** PRNG descriptor */ | 66 /** PRNG descriptor */ |
116 @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled | 116 @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled |
117 */ | 117 */ |
118 int (*test)(void); | 118 int (*test)(void); |
119 } prng_descriptor[]; | 119 } prng_descriptor[]; |
120 | 120 |
121 #ifdef YARROW | 121 #ifdef LTC_YARROW |
122 int yarrow_start(prng_state *prng); | 122 int yarrow_start(prng_state *prng); |
123 int yarrow_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); | 123 int yarrow_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); |
124 int yarrow_ready(prng_state *prng); | 124 int yarrow_ready(prng_state *prng); |
125 unsigned long yarrow_read(unsigned char *out, unsigned long outlen, prng_state *prng); | 125 unsigned long yarrow_read(unsigned char *out, unsigned long outlen, prng_state *prng); |
126 int yarrow_done(prng_state *prng); | 126 int yarrow_done(prng_state *prng); |
128 int yarrow_import(const unsigned char *in, unsigned long inlen, prng_state *prng); | 128 int yarrow_import(const unsigned char *in, unsigned long inlen, prng_state *prng); |
129 int yarrow_test(void); | 129 int yarrow_test(void); |
130 extern const struct ltc_prng_descriptor yarrow_desc; | 130 extern const struct ltc_prng_descriptor yarrow_desc; |
131 #endif | 131 #endif |
132 | 132 |
133 #ifdef FORTUNA | 133 #ifdef LTC_FORTUNA |
134 int fortuna_start(prng_state *prng); | 134 int fortuna_start(prng_state *prng); |
135 int fortuna_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); | 135 int fortuna_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); |
136 int fortuna_ready(prng_state *prng); | 136 int fortuna_ready(prng_state *prng); |
137 unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state *prng); | 137 unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state *prng); |
138 int fortuna_done(prng_state *prng); | 138 int fortuna_done(prng_state *prng); |
140 int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prng); | 140 int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prng); |
141 int fortuna_test(void); | 141 int fortuna_test(void); |
142 extern const struct ltc_prng_descriptor fortuna_desc; | 142 extern const struct ltc_prng_descriptor fortuna_desc; |
143 #endif | 143 #endif |
144 | 144 |
145 #ifdef RC4 | 145 #ifdef LTC_RC4 |
146 int rc4_start(prng_state *prng); | 146 int rc4_start(prng_state *prng); |
147 int rc4_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); | 147 int rc4_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); |
148 int rc4_ready(prng_state *prng); | 148 int rc4_ready(prng_state *prng); |
149 unsigned long rc4_read(unsigned char *out, unsigned long outlen, prng_state *prng); | 149 unsigned long rc4_read(unsigned char *out, unsigned long outlen, prng_state *prng); |
150 int rc4_done(prng_state *prng); | 150 int rc4_done(prng_state *prng); |
152 int rc4_import(const unsigned char *in, unsigned long inlen, prng_state *prng); | 152 int rc4_import(const unsigned char *in, unsigned long inlen, prng_state *prng); |
153 int rc4_test(void); | 153 int rc4_test(void); |
154 extern const struct ltc_prng_descriptor rc4_desc; | 154 extern const struct ltc_prng_descriptor rc4_desc; |
155 #endif | 155 #endif |
156 | 156 |
157 #ifdef SPRNG | 157 #ifdef LTC_SPRNG |
158 int sprng_start(prng_state *prng); | 158 int sprng_start(prng_state *prng); |
159 int sprng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); | 159 int sprng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); |
160 int sprng_ready(prng_state *prng); | 160 int sprng_ready(prng_state *prng); |
161 unsigned long sprng_read(unsigned char *out, unsigned long outlen, prng_state *prng); | 161 unsigned long sprng_read(unsigned char *out, unsigned long outlen, prng_state *prng); |
162 int sprng_done(prng_state *prng); | 162 int sprng_done(prng_state *prng); |
164 int sprng_import(const unsigned char *in, unsigned long inlen, prng_state *prng); | 164 int sprng_import(const unsigned char *in, unsigned long inlen, prng_state *prng); |
165 int sprng_test(void); | 165 int sprng_test(void); |
166 extern const struct ltc_prng_descriptor sprng_desc; | 166 extern const struct ltc_prng_descriptor sprng_desc; |
167 #endif | 167 #endif |
168 | 168 |
169 #ifdef SOBER128 | 169 #ifdef LTC_SOBER128 |
170 int sober128_start(prng_state *prng); | 170 int sober128_start(prng_state *prng); |
171 int sober128_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); | 171 int sober128_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); |
172 int sober128_ready(prng_state *prng); | 172 int sober128_ready(prng_state *prng); |
173 unsigned long sober128_read(unsigned char *out, unsigned long outlen, prng_state *prng); | 173 unsigned long sober128_read(unsigned char *out, unsigned long outlen, prng_state *prng); |
174 int sober128_done(prng_state *prng); | 174 int sober128_done(prng_state *prng); |
192 void (*callback)(void)); | 192 void (*callback)(void)); |
193 | 193 |
194 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)); |
195 | 195 |
196 | 196 |
197 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_prng.h,v $ */ | 197 /* $Source$ */ |
198 /* $Revision: 1.8 $ */ | 198 /* $Revision$ */ |
199 /* $Date: 2006/11/05 01:36:43 $ */ | 199 /* $Date$ */ |