aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/wired.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2017-09-05 16:01:14 (GMT)
committerJouni Malinen <j@w1.fi>2017-09-05 16:05:15 (GMT)
commit6c29d95a9062f5c94c4fab3b0b29f4af34a085b0 (patch)
treec8b7d78c2fbad7b6e29c8dd707ad2e7986f0df6b /wlantest/wired.c
parent4675ba1d67a658b27361763287323423d0c5dfda (diff)
downloadhostap-6c29d95a9062f5c94c4fab3b0b29f4af34a085b0.zip
hostap-6c29d95a9062f5c94c4fab3b0b29f4af34a085b0.tar.gz
hostap-6c29d95a9062f5c94c4fab3b0b29f4af34a085b0.tar.bz2
wlantest: Support variable length PMK
This is needed to be able to handle key derivation for FILS authentication. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'wlantest/wired.c')
-rw-r--r--wlantest/wired.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/wlantest/wired.c b/wlantest/wired.c
index 77a395f..9267f97 100644
--- a/wlantest/wired.c
+++ b/wlantest/wired.c
@@ -87,16 +87,17 @@ static void process_radius_access_request(struct wlantest *wt, u32 dst,
}
-static void wlantest_add_pmk(struct wlantest *wt, const u8 *pmk)
+static void wlantest_add_pmk(struct wlantest *wt, const u8 *pmk, size_t pmk_len)
{
struct wlantest_pmk *p;
p = os_zalloc(sizeof(*p));
if (p == NULL)
return;
- os_memcpy(p->pmk, pmk, 32);
+ os_memcpy(p->pmk, pmk, pmk_len);
+ p->pmk_len = pmk_len;
dl_list_add(&wt->pmk, &p->list);
- wpa_hexdump(MSG_INFO, "Add PMK", pmk, 32);
+ wpa_hexdump(MSG_INFO, "Add PMK", pmk, pmk_len);
}
@@ -127,20 +128,25 @@ static void process_radius_access_accept(struct wlantest *wt, u32 dst, u32 src,
(u8 *) s->secret,
os_strlen(s->secret));
if (keys && keys->send && keys->recv) {
- u8 pmk[32];
+ u8 pmk[PMK_LEN_MAX];
+ size_t pmk_len, len2;
+
wpa_hexdump_key(MSG_DEBUG, "MS-MPPE-Send-Key",
keys->send, keys->send_len);
wpa_hexdump_key(MSG_DEBUG, "MS-MPPE-Recv-Key",
keys->recv, keys->recv_len);
- os_memcpy(pmk, keys->recv,
- keys->recv_len > 32 ? 32 : keys->recv_len);
- if (keys->recv_len < 32) {
- os_memcpy(pmk + keys->recv_len,
- keys->send,
- keys->recv_len + keys->send_len > 32
- ? 32 : 32 - keys->recv_len);
+ pmk_len = keys->recv_len;
+ if (pmk_len > PMK_LEN_MAX)
+ pmk_len = PMK_LEN_MAX;
+ os_memcpy(pmk, keys->recv, pmk_len);
+ if (pmk_len < PMK_LEN_MAX) {
+ len2 = keys->send_len;
+ if (pmk_len + len2 > PMK_LEN_MAX)
+ len2 = PMK_LEN_MAX - pmk_len;
+ os_memcpy(pmk + pmk_len, keys->send, len2);
+ pmk_len += len2;
}
- wlantest_add_pmk(wt, pmk);
+ wlantest_add_pmk(wt, pmk, pmk_len);
found = 1;
}