Mercurial > dropbear
comparison random.c @ 689:c3de235d9506
/dev/random blocks on busy servers too.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 19 Jul 2012 21:34:27 +0800 |
parents | 650c41a4909a |
children | c85bb68e1db6 |
comparison
equal
deleted
inserted
replaced
688:650c41a4909a | 689:c3de235d9506 |
---|---|
153 fwrite(buf, sizeof(buf), 1, f); | 153 fwrite(buf, sizeof(buf), 1, f); |
154 fclose(f); | 154 fclose(f); |
155 #endif | 155 #endif |
156 } | 156 } |
157 | 157 |
158 /* add entropy from the stronger, blocking source /dev/random. Only used | |
159 * for generating persistent private keys (RSA and DSS) */ | |
160 void seedstrongrandom() | |
161 { | |
162 /* We assume that PRNGD is a strong source, so don't need to do anything here */ | |
163 #ifndef DROPBEAR_PRNGD_SOCKET | |
164 hash_state hs; | |
165 | |
166 sha1_process(&hs, (void*)hashpool, sizeof(hashpool)); | |
167 if (process_file(&hs, "/dev/random", INIT_SEED_SIZE, 0) | |
168 != DROPBEAR_SUCCESS) { | |
169 dropbear_exit("Failure reading random device %s", "/dev/random"); | |
170 } | |
171 | |
172 sha1_done(&hs, hashpool); | |
173 #endif | |
174 } | |
175 | |
176 /* Initialise the prng from /dev/urandom or prngd. This function can | 158 /* Initialise the prng from /dev/urandom or prngd. This function can |
177 * be called multiple times */ | 159 * be called multiple times */ |
178 void seedrandom() { | 160 void seedrandom() { |
179 | 161 |
180 hash_state hs; | 162 hash_state hs; |