[PATCH 4/4] random: Apply get_source_long() in several places

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace arch_get_random_long()/random_get_entropy() sequences
with get_source_long().

Signed-off-by: Sandy Harris <sandyinchina@xxxxxxxxx>
---
 drivers/char/random.c | 34 +++++++++-------------------------
 1 file changed, 9 insertions(+), 25 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 6c77fd056f66..20af61a56ec0 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1140,11 +1140,7 @@ static bool crng_init_try_arch(struct crng_state *crng)
     unsigned long rv;

     for (i = 4; i < 16; i++) {
-        if (!arch_get_random_seed_long(&rv) &&
-            !arch_get_random_long(&rv)) {
-            rv = random_get_entropy();
-            arch_init = false;
-        }
+        get_source_long(&rv) ;
         crng->state[i] ^= rv;
     }

@@ -1158,11 +1154,7 @@ static bool __init crng_init_try_arch_early(void)
     unsigned long rv;

     for (i = 4; i < 16; i++) {
-        if (!arch_get_random_seed_long_early(&rv) &&
-            !arch_get_random_long_early(&rv)) {
-            rv = random_get_entropy();
-            arch_init = false;
-        }
+        get_source_long(&rv) ;
         primary_crng.state[i] ^= rv;
     }

@@ -1341,7 +1333,7 @@ static int crng_slow_load(const u8 *cp, size_t len)

 static void crng_reseed(struct crng_state *crng, bool use_input_pool)
 {
-    unsigned long flags;
+    unsigned long flags, rv;
     int i, num;
     union {
         u8 block[CHACHA_BLOCK_SIZE];
@@ -1359,10 +1351,7 @@ static void crng_reseed(struct crng_state
*crng, bool use_input_pool)
     }
     spin_lock_irqsave(&crng->lock, flags);
     for (i = 0; i < 8; i++) {
-        unsigned long rv;
-        if (!arch_get_random_seed_long(&rv) &&
-            !arch_get_random_long(&rv))
-            rv = random_get_entropy();
+        get_source_long(&rv) ;
         crng->state[i + 4] ^= buf.key[i] ^ rv;
     }
     memzero_explicit(&buf, sizeof(buf));
@@ -1728,6 +1717,7 @@ static void extract_buf(u8 *out)
     u8 hash[BLAKE2S_HASH_SIZE];
     unsigned long *salt;
     unsigned long flags;
+    unsigned long v ;

     blake2s_init(&state, sizeof(hash));

@@ -1737,10 +1727,8 @@ static void extract_buf(u8 *out)
      */
     for (salt = (unsigned long *)&state.h[4];
          salt < (unsigned long *)&state.h[8]; ++salt) {
-        unsigned long v;
-        if (!arch_get_random_long(&v))
-            break;
-        *salt ^= v;
+        get_source_long(&v) ;
+        *salt ^= v ;
     }

     /* Generate a hash across the pool */
@@ -2037,9 +2025,7 @@ int __must_check get_random_bytes_arch(void
*buf, int nbytes)
         unsigned long v;
         int chunk = min_t(int, left, sizeof(unsigned long));

-        if (!arch_get_random_long(&v))
-            break;
-
+        get_source_long(&v) ;
         memcpy(p, &v, chunk);
         p += chunk;
         left -= chunk;
@@ -2064,9 +2050,7 @@ static void __init init_std_data(void)

     mix_pool_bytes(&now, sizeof(now));
     for (i = POOL_BYTES; i > 0; i -= sizeof(rv)) {
-        if (!arch_get_random_seed_long(&rv) &&
-            !arch_get_random_long(&rv))
-            rv = random_get_entropy();
+        get_source_long(&rv) ;
         mix_pool_bytes(&rv, sizeof(rv));
     }
     mix_pool_bytes(utsname(), sizeof(*(utsname())));
-- 
2.25.1



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux