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

Nick Lowe nick.lowe at lugatech.com
Sun Feb 14 11:40:25 PST 2016


 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 at lugatech.com>
---
 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0008-Switch-from-using-os_random-to-using-os_get_random-..patch
Type: text/x-patch
Size: 1650 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/hostap/attachments/20160214/67c723ef/attachment.bin>


More information about the Hostap mailing list