comparison random.c @ 311:36d21680a9d3

A few more fixups, make sure that variable declarations are the first thing in a function
author Matt Johnston <matt@ucc.asn.au>
date Sun, 26 Mar 2006 09:26:43 +0000
parents 7dad470ad4aa
children 08b69964e408 959c66ccf1b5 00703f1df67a
comparison
equal deleted inserted replaced
301:fb3678bdb8c7 311:36d21680a9d3
132 unsigned char readbuf[INIT_SEED_SIZE]; 132 unsigned char readbuf[INIT_SEED_SIZE];
133 133
134 hash_state hs; 134 hash_state hs;
135 135
136 /* initialise so that things won't warn about 136 /* initialise so that things won't warn about
137 * hashing an undefined buffer */ 137 * hashing an undefined buffer */
138 if (!donerandinit) { 138 if (!donerandinit) {
139 m_burn(hashpool, sizeof(hashpool)); 139 m_burn(hashpool, sizeof(hashpool));
140 } 140 }
141 141
142 /* get the seed data */ 142 /* get the seed data */
155 /* hash the current random pool with some unique identifiers 155 /* hash the current random pool with some unique identifiers
156 * for this process and point-in-time. this is used to separate 156 * for this process and point-in-time. this is used to separate
157 * the random pools for fork()ed processes. */ 157 * the random pools for fork()ed processes. */
158 void reseedrandom() { 158 void reseedrandom() {
159 159
160 pid_t pid; 160 pid_t pid;
161 struct timeval tv; 161 hash_state hs;
162 struct timeval tv;
162 163
163 if (!donerandinit) { 164 if (!donerandinit) {
164 dropbear_exit("seedrandom not done"); 165 dropbear_exit("seedrandom not done");
165 } 166 }
166 167
167 pid = getpid(); 168 pid = getpid();
168 gettimeofday(&tv, NULL); 169 gettimeofday(&tv, NULL);
169 170
170 hash_state hs;
171 sha1_init(&hs); 171 sha1_init(&hs);
172 sha1_process(&hs, (void*)hashpool, sizeof(hashpool)); 172 sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
173 sha1_process(&hs, (void*)&pid, sizeof(pid)); 173 sha1_process(&hs, (void*)&pid, sizeof(pid));
174 sha1_process(&hs, (void*)&tv, sizeof(tv)); 174 sha1_process(&hs, (void*)&tv, sizeof(tv));
175 sha1_done(&hs, hashpool); 175 sha1_done(&hs, hashpool);