aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/ap.c
diff options
context:
space:
mode:
authorNick Lowe <nick.lowe@lugatech.com>2016-02-09 14:47:47 (GMT)
committerJouni Malinen <j@w1.fi>2016-02-19 16:44:40 (GMT)
commit98a516eae8260e6fd5c48ddecf8d006285da7389 (patch)
treec4e476cd4f11428a490cbd55d709cf88aff7a702 /wpa_supplicant/ap.c
parentf441e5af777c01f8649374fe91ff135e080aa959 (diff)
downloadhostap-98a516eae8260e6fd5c48ddecf8d006285da7389.zip
hostap-98a516eae8260e6fd5c48ddecf8d006285da7389.tar.gz
hostap-98a516eae8260e6fd5c48ddecf8d006285da7389.tar.bz2
WPS: Use only os_get_random() for PIN generation
Remove the fallback dependency on os_random() when generating a WPS pin. This is exceptionally unlikely to ever be called as the call to os_get_random() is unlikely to fail. The intention is to facilitate future removal of os_random() as it uses a low quality PRNG. Signed-off-by: Nick Lowe <nick.lowe@lugatech.com>
Diffstat (limited to 'wpa_supplicant/ap.c')
-rw-r--r--wpa_supplicant/ap.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index 03c3fab..60f8c0d 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -915,7 +915,10 @@ int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
return -1;
if (pin == NULL) {
- unsigned int rpin = wps_generate_pin();
+ unsigned int rpin;
+
+ if (wps_generate_pin(&rpin) < 0)
+ return -1;
ret_len = os_snprintf(buf, buflen, "%08d", rpin);
if (os_snprintf_error(buflen, ret_len))
return -1;
@@ -981,7 +984,8 @@ const char * wpas_wps_ap_pin_random(struct wpa_supplicant *wpa_s, int timeout)
if (wpa_s->ap_iface == NULL)
return NULL;
hapd = wpa_s->ap_iface->bss[0];
- pin = wps_generate_pin();
+ if (wps_generate_pin(&pin) < 0)
+ return NULL;
os_snprintf(pin_txt, sizeof(pin_txt), "%08u", pin);
os_free(hapd->conf->ap_pin);
hapd->conf->ap_pin = os_strdup(pin_txt);