Mercurial > dropbear
comparison random.c @ 755:b07eb3dc23ec ecc
refactor kexdh code a bit, start working on ecdh etc
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 26 Mar 2013 01:35:22 +0800 |
parents | 84157e435c52 |
children | 76fba0856749 |
comparison
equal
deleted
inserted
replaced
725:49f68a7b7a55 | 755:b07eb3dc23ec |
---|---|
34 #define MAX_COUNTER 1<<30 | 34 #define MAX_COUNTER 1<<30 |
35 | 35 |
36 static unsigned char hashpool[SHA1_HASH_SIZE] = {0}; | 36 static unsigned char hashpool[SHA1_HASH_SIZE] = {0}; |
37 static int donerandinit = 0; | 37 static int donerandinit = 0; |
38 | 38 |
39 int dropbear_ltc_prng = -1; | |
40 | |
39 #define INIT_SEED_SIZE 32 /* 256 bits */ | 41 #define INIT_SEED_SIZE 32 /* 256 bits */ |
40 | 42 |
41 /* The basic setup is we read some data from /dev/(u)random or prngd and hash it | 43 /* The basic setup is we read some data from /dev/(u)random or prngd and hash it |
42 * into hashpool. To read data, we hash together current hashpool contents, | 44 * into hashpool. To read data, we hash together current hashpool contents, |
43 * and a counter. We feed more data in by hashing the current pool and new | 45 * and a counter. We feed more data in by hashing the current pool and new |
229 /* When a private key is read by the client or server it will | 231 /* When a private key is read by the client or server it will |
230 * be added to the hashpool - see runopts.c */ | 232 * be added to the hashpool - see runopts.c */ |
231 | 233 |
232 sha1_done(&hs, hashpool); | 234 sha1_done(&hs, hashpool); |
233 | 235 |
236 #ifdef DROPBEAR_LTC_PRNG | |
237 if (dropbear_ltc_prng == -1) { | |
238 dropbear_ltc_prng = register_prng(&dropbear_prng_desc); | |
239 dropbear_assert(dropbear_ltc_prng != -1); | |
240 } | |
241 #endif | |
242 | |
234 counter = 0; | 243 counter = 0; |
235 donerandinit = 1; | 244 donerandinit = 1; |
236 | 245 |
237 /* Feed it all back into /dev/urandom - this might help if Dropbear | 246 /* Feed it all back into /dev/urandom - this might help if Dropbear |
238 * is running from inetd and gets new state each time */ | 247 * is running from inetd and gets new state each time */ |