comparison random.c @ 355:c61bd8f9e32d debug-unrandom

make sure that random number generator is correct endian
author Matt Johnston <matt@ucc.asn.au>
date Wed, 09 Aug 2006 16:45:05 +0000
parents e66eec4dcba7
children
comparison
equal deleted inserted replaced
354:0e38c039a9c8 355:c61bd8f9e32d
71 hash_state hs; 71 hash_state hs;
72 unsigned char hash[SHA1_HASH_SIZE]; 72 unsigned char hash[SHA1_HASH_SIZE];
73 unsigned int copylen; 73 unsigned int copylen;
74 const unsigned int total_len = len; 74 const unsigned int total_len = len;
75 unsigned char* start_buf = buf; 75 unsigned char* start_buf = buf;
76 unsigned char counter_buf[4];
76 77
77 if (!donerandinit) { 78 if (!donerandinit) {
78 dropbear_exit("seedrandom not done"); 79 dropbear_exit("seedrandom not done");
79 } 80 }
80 81
81 while (len > 0) { 82 while (len > 0) {
82 sha1_init(&hs); 83 sha1_init(&hs);
83 sha1_process(&hs, (void*)hashpool, sizeof(hashpool)); 84 sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
84 sha1_process(&hs, (void*)&counter, sizeof(counter)); 85 STORE32H(counter, counter_buf);
86 sha1_process(&hs, (void*)counter_buf, sizeof(counter));
85 sha1_done(&hs, hash); 87 sha1_done(&hs, hash);
86 88
87 counter++; 89 counter++;
88 if (counter > MAX_COUNTER) { 90 if (counter > MAX_COUNTER) {
89 seedrandom(); 91 seedrandom();