Re: [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]

 



On Sun, Feb 14, 2016 at 07:40:25PM +0000, Nick Lowe wrote:
>  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.

> diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
> wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,

> -            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;

This would increase the old maximum value by one second in the unlikely
error case, but that sounds fine.

> @@ -2637,7 +2634,7 @@ wpa_supplicant_event_michael_mic_failure(struct
>              eloop_register_timeout(
> -                sec, os_random() % 1000000,
> +                sec, 0,
>                  wpa_supplicant_delayed_mic_error_report,

But this would drop the sub-second resolution completely. That does not
sound desirable. Maybe replace sec with msec 0..60000 and use msec /
1000 and msec % 1000 * 1000 as the arguments here?

-- 
Jouni Malinen                                            PGP id EFC895FA

_______________________________________________
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