comparison common-runopts.c @ 687:167fdc091c05

Improve RNG seeding. Try to read from /dev/urandom multiple times, take input from extra sources, and use /dev/random when generating private keys
author Matt Johnston <matt@ucc.asn.au>
date Fri, 29 Jun 2012 23:19:43 +0800
parents 4edea9f363d0
children e22d5f5f6e37
comparison
equal deleted inserted replaced
683:63f8d6c469cf 687:167fdc091c05
27 #include "signkey.h" 27 #include "signkey.h"
28 #include "buffer.h" 28 #include "buffer.h"
29 #include "dbutil.h" 29 #include "dbutil.h"
30 #include "auth.h" 30 #include "auth.h"
31 #include "algo.h" 31 #include "algo.h"
32 #include "random.h"
32 33
33 runopts opts; /* GLOBAL */ 34 runopts opts; /* GLOBAL */
34 35
35 /* returns success or failure, and the keytype in *type. If we want 36 /* returns success or failure, and the keytype in *type. If we want
36 * to restrict the type, type can contain a type to return */ 37 * to restrict the type, type can contain a type to return */
43 44
44 if (buf_readfile(buf, filename) == DROPBEAR_FAILURE) { 45 if (buf_readfile(buf, filename) == DROPBEAR_FAILURE) {
45 goto out; 46 goto out;
46 } 47 }
47 buf_setpos(buf, 0); 48 buf_setpos(buf, 0);
49
50 addrandom(buf_getptr(buf, buf->len), buf->len);
51
48 if (buf_get_priv_key(buf, hostkey, type) == DROPBEAR_FAILURE) { 52 if (buf_get_priv_key(buf, hostkey, type) == DROPBEAR_FAILURE) {
49 goto out; 53 goto out;
50 } 54 }
51 55
52 ret = DROPBEAR_SUCCESS; 56 ret = DROPBEAR_SUCCESS;