comparison random.c @ 442:d82a2a44c684

Add -u option to specify /dev/urandom instead
author Matt Johnston <matt@ucc.asn.au>
date Mon, 16 Apr 2007 13:39:50 +0000
parents c216212001fc
children 2cd2edfa11ee
comparison
equal deleted inserted replaced
441:fdf06a5a54e4 442:d82a2a44c684
24 24
25 #include "includes.h" 25 #include "includes.h"
26 #include "buffer.h" 26 #include "buffer.h"
27 #include "dbutil.h" 27 #include "dbutil.h"
28 #include "bignum.h" 28 #include "bignum.h"
29
30 #ifdef DROPBEAR_RANDOM_DEV
31 const char* random_dev = DROPBEAR_RANDOM_DEV;
32 #else
33 const char* random_dev = NULL;
34 #endif
35
29 36
30 static int donerandinit = 0; 37 static int donerandinit = 0;
31 38
32 /* this is used to generate unique output from the same hashpool */ 39 /* this is used to generate unique output from the same hashpool */
33 static uint32_t counter = 0; 40 static uint32_t counter = 0;
60 struct sockaddr_un egdsock; 67 struct sockaddr_un egdsock;
61 char egdcmd[2]; 68 char egdcmd[2];
62 #endif 69 #endif
63 70
64 #ifdef DROPBEAR_RANDOM_DEV 71 #ifdef DROPBEAR_RANDOM_DEV
65 readfd = open(DROPBEAR_RANDOM_DEV, O_RDONLY); 72 readfd = open(random_dev, O_RDONLY);
66 if (readfd < 0) { 73 if (readfd < 0) {
67 dropbear_exit("couldn't open random device"); 74 dropbear_exit("couldn't open %s", random_dev);
68 } 75 }
69 #endif 76 #endif
70 77
71 #ifdef DROPBEAR_PRNGD_SOCKET 78 #ifdef DROPBEAR_PRNGD_SOCKET
72 memset((void*)&egdsock, 0x0, sizeof(egdsock)); 79 memset((void*)&egdsock, 0x0, sizeof(egdsock));