Skip to content

Commit 6602a97

Browse files
sungjungkazat
authored andcommitted
Remove needless check for arc4_seeded_ok
(cherry picked from commit 16a151d)
1 parent 5e39750 commit 6602a97

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

arc4random.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ static int rs_initialized;
8989
static struct arc4_stream rs;
9090
static pid_t arc4_stir_pid;
9191
static int arc4_count;
92-
static int arc4_seeded_ok;
9392

9493
static inline unsigned char arc4_getbyte(void);
9594

@@ -163,7 +162,6 @@ arc4_seed_win32(void)
163162
return -1;
164163
arc4_addrandom(buf, sizeof(buf));
165164
evutil_memclear_(buf, sizeof(buf));
166-
arc4_seeded_ok = 1;
167165
return 0;
168166
}
169167
#endif
@@ -201,7 +199,6 @@ arc4_seed_sysctl_linux(void)
201199

202200
arc4_addrandom(buf, sizeof(buf));
203201
evutil_memclear_(buf, sizeof(buf));
204-
arc4_seeded_ok = 1;
205202
return 0;
206203
}
207204
#endif
@@ -241,7 +238,6 @@ arc4_seed_sysctl_bsd(void)
241238

242239
arc4_addrandom(buf, sizeof(buf));
243240
evutil_memclear_(buf, sizeof(buf));
244-
arc4_seeded_ok = 1;
245241
return 0;
246242
}
247243
#endif
@@ -287,7 +283,6 @@ arc4_seed_proc_sys_kernel_random_uuid(void)
287283
}
288284
evutil_memclear_(entropy, sizeof(entropy));
289285
evutil_memclear_(buf, sizeof(buf));
290-
arc4_seeded_ok = 1;
291286
return 0;
292287
}
293288
#endif
@@ -311,7 +306,6 @@ static int arc4_seed_urandom_helper_(const char *fname)
311306
return -1;
312307
arc4_addrandom(buf, sizeof(buf));
313308
evutil_memclear_(buf, sizeof(buf));
314-
arc4_seeded_ok = 1;
315309
return 0;
316310
}
317311

@@ -382,9 +376,6 @@ arc4_stir(void)
382376
if (0 != arc4_seed())
383377
return -1;
384378

385-
if (!arc4_seeded_ok)
386-
return -1;
387-
388379
/*
389380
* Discard early keystream, as per recommendations in
390381
* "Weaknesses in the Key Scheduling Algorithm of RC4" by

evutil_rand.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ evutil_secure_rng_init(void)
171171
int val;
172172

173173
ARC4_LOCK_();
174-
if (!arc4_seeded_ok)
175-
arc4_stir();
176-
val = arc4_seeded_ok ? 0 : -1;
174+
val = (!arc4_stir()) ? 0 : -1;
177175
ARC4_UNLOCK_();
178176
return val;
179177
}

0 commit comments

Comments
 (0)