[PATCH 06/10] Switch from using os_random() to using os_get_random(...) in ieee802_1x_kay_create_mka(...)

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

 



 Switch from using os_random() to using
 os_get_random(...) in ieee802_1x_kay_create_mka(...) The intention is to
 facilitate the future removal of os_random(). os_random() uses a low quality
 PRNG which we should avoid using outright unless there is a compelling
 performance justification to do so.

Signed-off-by: Nick Lowe <nick.lowe@xxxxxxxxxxxx>
---
 src/pae/ieee802_1x_kay.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
index ef74430..8053b61 100644
--- a/src/pae/ieee802_1x_kay.c
+++ b/src/pae/ieee802_1x_kay.c
@@ -3384,7 +3384,9 @@ ieee802_1x_kay_create_mka(struct ieee802_1x_kay
*kay, struct mka_key_name *ckn,
     wpa_hexdump(MSG_DEBUG, "KaY: Participant created:",
             ckn->name, ckn->len);

-    usecs = os_random() % (MKA_HELLO_TIME * 1000);
+    if (os_get_random((u8 *) &usecs, sizeof(usecs)) < 0)
+        goto fail;
+    usecs = usecs % (MKA_HELLO_TIME * 1000);
     eloop_register_timeout(0, usecs, ieee802_1x_participant_timer,
                    participant, NULL);
     participant->mka_life = MKA_LIFE_TIME / 1000 + time(NULL) +
-- 
2.5.0
From 90728d95100f5f63daa0f29fe19d2c2d3d0ebe0c Mon Sep 17 00:00:00 2001
From: Nick Lowe <nick.lowe@xxxxxxxxxxxx>
Date: Tue, 9 Feb 2016 16:15:31 +0000
Subject: [PATCH 06/10] Switch from using os_random() to using
 os_get_random(...) in ieee802_1x_kay_create_mka(...) The intention is to
 facilitate the future removal of os_random(). os_random() uses a low quality
 PRNG which we should avoid using outright unless there is a compelling
 performance justification to do so.

Signed-off-by: Nick Lowe <nick.lowe@xxxxxxxxxxxx>
---
 src/pae/ieee802_1x_kay.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
index ef74430..8053b61 100644
--- a/src/pae/ieee802_1x_kay.c
+++ b/src/pae/ieee802_1x_kay.c
@@ -3384,7 +3384,9 @@ ieee802_1x_kay_create_mka(struct ieee802_1x_kay *kay, struct mka_key_name *ckn,
 	wpa_hexdump(MSG_DEBUG, "KaY: Participant created:",
 		    ckn->name, ckn->len);
 
-	usecs = os_random() % (MKA_HELLO_TIME * 1000);
+	if (os_get_random((u8 *) &usecs, sizeof(usecs)) < 0)
+		goto fail;
+	usecs = usecs % (MKA_HELLO_TIME * 1000);
 	eloop_register_timeout(0, usecs, ieee802_1x_participant_timer,
 			       participant, NULL);
 	participant->mka_life = MKA_LIFE_TIME / 1000 + time(NULL) +
-- 
2.5.0

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap

[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux