[PATCH 08/10] Switch from using os_random() to using os_get_random(...) in wpa_supplicant_event_michael_mic_failure(...)

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

 



 Switch from using os_random() to using
 os_get_random(...) in wpa_supplicant_event_michael_mic_failure(...) 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>
---
 wpa_supplicant/events.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 2870e89..fabb8fd 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2622,13 +2622,10 @@
wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
              * the information on whether a frame resulted in a MIC
              * failure.
              */
-            u8 rval[4];
-            int sec;
+            int sec = 60;

-            if (os_get_random(rval, sizeof(rval)) < 0)
-                sec = os_random() % 60;
-            else
-                sec = WPA_GET_BE32(rval) % 60;
+            if (os_get_random(sec, sizeof(sec)) >= 0)
+                sec = sec % 60;
             wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error "
                 "report %d seconds", sec);
             wpa_s->pending_mic_error_report = 1;
@@ -2637,7 +2634,7 @@ wpa_supplicant_event_michael_mic_failure(struct
wpa_supplicant *wpa_s,
                 wpa_supplicant_delayed_mic_error_report,
                 wpa_s, NULL);
             eloop_register_timeout(
-                sec, os_random() % 1000000,
+                sec, 0,
                 wpa_supplicant_delayed_mic_error_report,
                 wpa_s, NULL);
         } else {
-- 
2.5.0
From 9f010b3701f80286bb2b32cba86ba55852c2bb53 Mon Sep 17 00:00:00 2001
From: Nick Lowe <nick.lowe@xxxxxxxxxxxx>
Date: Tue, 9 Feb 2016 16:17:16 +0000
Subject: [PATCH 08/10] Switch from using os_random() to using
 os_get_random(...) in wpa_supplicant_event_michael_mic_failure(...) 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>
---
 wpa_supplicant/events.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 2870e89..fabb8fd 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2622,13 +2622,10 @@ wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
 			 * the information on whether a frame resulted in a MIC
 			 * failure.
 			 */
-			u8 rval[4];
-			int sec;
+			int sec = 60;
 
-			if (os_get_random(rval, sizeof(rval)) < 0)
-				sec = os_random() % 60;
-			else
-				sec = WPA_GET_BE32(rval) % 60;
+			if (os_get_random(sec, sizeof(sec)) >= 0)
+				sec = sec % 60;
 			wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error "
 				"report %d seconds", sec);
 			wpa_s->pending_mic_error_report = 1;
@@ -2637,7 +2634,7 @@ wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
 				wpa_supplicant_delayed_mic_error_report,
 				wpa_s, NULL);
 			eloop_register_timeout(
-				sec, os_random() % 1000000,
+				sec, 0,
 				wpa_supplicant_delayed_mic_error_report,
 				wpa_s, NULL);
 		} else {
-- 
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