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

Nick Lowe nick.lowe at lugatech.com
Sun Feb 14 11:38:37 PST 2016


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


More information about the Hostap mailing list