aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lowe <nick.lowe@lugatech.com>2016-02-09 14:43:21 (GMT)
committerJouni Malinen <j@w1.fi>2016-02-19 16:44:40 (GMT)
commitf441e5af777c01f8649374fe91ff135e080aa959 (patch)
treeac00c423780b07e8326325097563e4aa6eee8650
parent20c48fd99b1458db6ab61d4ec46aed2a824b257f (diff)
downloadhostap-f441e5af777c01f8649374fe91ff135e080aa959.zip
hostap-f441e5af777c01f8649374fe91ff135e080aa959.tar.gz
hostap-f441e5af777c01f8649374fe91ff135e080aa959.tar.bz2
Use os_get_random() for Shared Key authentication challenge
Do not use the system clock or os_random() that uses a low quality PRNG as part of the pseudo-random challenge in auth_shared_key(). The construction can be improved upon by replacing it with a call to os_get_random(), which uses a high quality PRNG. Signed-off-by: Nick Lowe <nick.lowe@lugatech.com>
-rw-r--r--src/ap/ieee802_11.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index f3d8968..ca3065b 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -207,16 +207,17 @@ static u16 auth_shared_key(struct hostapd_data *hapd, struct sta_info *sta,
if (!sta->challenge) {
/* Generate a pseudo-random challenge */
u8 key[8];
- struct os_time now;
- int r;
+
sta->challenge = os_zalloc(WLAN_AUTH_CHALLENGE_LEN);
if (sta->challenge == NULL)
return WLAN_STATUS_UNSPECIFIED_FAILURE;
- os_get_time(&now);
- r = os_random();
- os_memcpy(key, &now.sec, 4);
- os_memcpy(key + 4, &r, 4);
+ if (os_get_random(key, sizeof(key)) < 0) {
+ os_free(sta->challenge);
+ sta->challenge = NULL;
+ return WLAN_STATUS_UNSPECIFIED_FAILURE;
+ }
+
rc4_skip(key, sizeof(key), 0,
sta->challenge, WLAN_AUTH_CHALLENGE_LEN);
}