]> granicus.if.org Git - libevent/commitdiff
Remove needless check for arc4_seeded_ok
authorSeong-Joong Kim <sungjungk@gmail.com>
Thu, 21 Feb 2019 16:19:10 +0000 (16:19 +0000)
committerSeong-Joong Kim <sungjungk@gmail.com>
Fri, 1 Mar 2019 18:06:29 +0000 (18:06 +0000)
arc4random.c
evutil_rand.c

index ea2f3e7c03c8dd5a1f45c05d7ffba5dd2edb1b49..02fd74478d3cc891aa5651b794add9b824193aca 100644 (file)
@@ -89,7 +89,6 @@ static int rs_initialized;
 static struct arc4_stream rs;
 static pid_t arc4_stir_pid;
 static int arc4_count;
-static int arc4_seeded_ok;
 
 static inline unsigned char arc4_getbyte(void);
 
@@ -163,7 +162,6 @@ arc4_seed_win32(void)
                return -1;
        arc4_addrandom(buf, sizeof(buf));
        evutil_memclear_(buf, sizeof(buf));
-       arc4_seeded_ok = 1;
        return 0;
 }
 #endif
@@ -201,7 +199,6 @@ arc4_seed_sysctl_linux(void)
 
        arc4_addrandom(buf, sizeof(buf));
        evutil_memclear_(buf, sizeof(buf));
-       arc4_seeded_ok = 1;
        return 0;
 }
 #endif
@@ -241,7 +238,6 @@ arc4_seed_sysctl_bsd(void)
 
        arc4_addrandom(buf, sizeof(buf));
        evutil_memclear_(buf, sizeof(buf));
-       arc4_seeded_ok = 1;
        return 0;
 }
 #endif
@@ -287,7 +283,6 @@ arc4_seed_proc_sys_kernel_random_uuid(void)
        }
        evutil_memclear_(entropy, sizeof(entropy));
        evutil_memclear_(buf, sizeof(buf));
-       arc4_seeded_ok = 1;
        return 0;
 }
 #endif
@@ -311,7 +306,6 @@ static int arc4_seed_urandom_helper_(const char *fname)
                return -1;
        arc4_addrandom(buf, sizeof(buf));
        evutil_memclear_(buf, sizeof(buf));
-       arc4_seeded_ok = 1;
        return 0;
 }
 
@@ -382,9 +376,6 @@ arc4_stir(void)
        if (0 != arc4_seed())
                return -1;
 
-       if (!arc4_seeded_ok)
-               return -1;
-
        /*
         * Discard early keystream, as per recommendations in
         * "Weaknesses in the Key Scheduling Algorithm of RC4" by
index 4be0b1c5e2bb130e7692e359f8ecf0d3813218e5..8e9afdaa67535748697ff93d5a4dc1c05fc9ea7c 100644 (file)
@@ -171,9 +171,7 @@ evutil_secure_rng_init(void)
        int val;
 
        ARC4_LOCK_();
-       if (!arc4_seeded_ok)
-               arc4_stir();
-       val = arc4_seeded_ok ? 0 : -1;
+       val = (!arc4_stir()) ? 0 : -1;
        ARC4_UNLOCK_();
        return val;
 }