2
* WPA Supplicant - IEEE 802.11r - Fast BSS Transition
3
* Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation.
9
* Alternatively, this software may be distributed under the terms of BSD
12
* See README and COPYING for more details.
22
#include "ieee802_11_defs.h"
24
#ifdef CONFIG_IEEE80211R
26
int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr,
27
const struct wpa_eapol_key *key,
30
u8 pmk_r1_name[WPA_PMK_NAME_LEN];
31
u8 ptk_name[WPA_PMK_NAME_LEN];
32
const u8 *anonce = key->key_nonce;
34
if (sm->xxkey_len == 0) {
35
wpa_printf(MSG_DEBUG, "FT: XXKey not available for key "
40
wpa_derive_pmk_r0(sm->xxkey, sm->xxkey_len, sm->ssid,
41
sm->ssid_len, sm->mobility_domain,
42
sm->r0kh_id, sm->r0kh_id_len, sm->own_addr,
43
sm->pmk_r0, sm->pmk_r0_name);
44
wpa_hexdump_key(MSG_DEBUG, "FT: PMK-R0", sm->pmk_r0, PMK_LEN);
45
wpa_hexdump(MSG_DEBUG, "FT: PMKR0Name",
46
sm->pmk_r0_name, WPA_PMK_NAME_LEN);
47
wpa_derive_pmk_r1(sm->pmk_r0, sm->pmk_r0_name, sm->r1kh_id,
48
sm->own_addr, sm->pmk_r1, pmk_r1_name);
49
wpa_hexdump_key(MSG_DEBUG, "FT: PMK-R1", sm->pmk_r1, PMK_LEN);
50
wpa_hexdump(MSG_DEBUG, "FT: PMKR1Name", pmk_r1_name, WPA_PMK_NAME_LEN);
51
wpa_pmk_r1_to_ptk(sm->pmk_r1, sm->snonce, anonce, sm->own_addr,
52
sm->bssid, pmk_r1_name,
53
(u8 *) ptk, sizeof(*ptk), ptk_name);
54
wpa_hexdump_key(MSG_DEBUG, "FT: PTK", (u8 *) ptk, sizeof(*ptk));
55
wpa_hexdump(MSG_DEBUG, "FT: PTKName", ptk_name, WPA_PMK_NAME_LEN);
62
* wpa_sm_set_ft_params - Set FT (IEEE 802.11r) parameters
63
* @sm: Pointer to WPA state machine data from wpa_sm_init()
64
* @mobility_domain: Mobility domain identifier (2 octets)
65
* @r0kh_id: PMK-R0 key holder identity (1-48 octets)
66
* @r0kh_id_len: R0KH-ID length (1-48)
67
* @r1kh_id: PMK-R1 key holder identity (16 octets)
68
* Returns: 0 on success, -1 on failure
70
int wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *mobility_domain,
71
const u8 *r0kh_id, size_t r0kh_id_len,
74
if (sm && mobility_domain) {
75
wpa_hexdump(MSG_DEBUG, "FT: Mobility domain",
76
mobility_domain, MOBILITY_DOMAIN_ID_LEN);
77
os_memcpy(sm->mobility_domain, mobility_domain,
78
MOBILITY_DOMAIN_ID_LEN);
80
os_memset(sm->mobility_domain, 0, MOBILITY_DOMAIN_ID_LEN);
83
if (r0kh_id_len > FT_R0KH_ID_MAX_LEN)
85
wpa_hexdump(MSG_DEBUG, "FT: R0KH-ID", r0kh_id, r0kh_id_len);
86
os_memcpy(sm->r0kh_id, r0kh_id, r0kh_id_len);
87
sm->r0kh_id_len = r0kh_id_len;
89
/* FIX: When should R0KH-ID be cleared? We need to keep the
90
* old R0KH-ID in order to be able to use this during FT. */
92
* os_memset(sm->r0kh_id, 0, FT_R0KH_ID_LEN);
93
* sm->r0kh_id_len = 0;
98
wpa_hexdump(MSG_DEBUG, "FT: R1KH-ID", r1kh_id, FT_R1KH_ID_LEN);
99
os_memcpy(sm->r1kh_id, r1kh_id, FT_R1KH_ID_LEN);
101
os_memset(sm->r1kh_id, 0, FT_R1KH_ID_LEN);
108
* wpa_ft_gen_req_ies - Generate FT (IEEE 802.11r) IEs for Auth Request
109
* @sm: Pointer to WPA state machine data from wpa_sm_init()
110
* @len: Buffer for returning the length of the IEs
111
* @anonce: ANonce or %NULL if not yet available
112
* @pmk_name: PMKR0Name or PMKR1Name to be added into the RSN IE PMKID List
113
* @kck: 128-bit KCK for MIC or %NULL if no MIC is used
114
* @target_ap: Target AP address
115
* Returns: Pointer to buffer with IEs or %NULL on failure
117
* Caller is responsible for freeing the returned buffer with os_free();
119
static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len,
120
const u8 *anonce, const u8 *pmk_name,
121
const u8 *kck, const u8 *target_ap)
124
u8 *buf, *pos, *ftie_len;
125
struct rsn_mdie *mdie;
126
struct rsn_ftie *ftie;
127
struct rsn_ie_hdr *rsnie;
130
sm->ft_completed = 0;
132
buf_len = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) +
133
2 + sm->r0kh_id_len + 100;
134
buf = os_zalloc(buf_len);
139
/* RSNIE[PMKR0Name] */
140
rsnie = (struct rsn_ie_hdr *) pos;
141
rsnie->elem_id = WLAN_EID_RSN;
142
WPA_PUT_LE16(rsnie->version, RSN_VERSION);
143
pos = (u8 *) (rsnie + 1);
145
/* Group Suite Selector */
146
if (sm->group_cipher == WPA_CIPHER_CCMP)
147
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP);
148
else if (sm->group_cipher == WPA_CIPHER_TKIP)
149
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_TKIP);
151
wpa_printf(MSG_WARNING, "FT: Invalid group cipher (%d)",
156
pos += RSN_SELECTOR_LEN;
158
/* Pairwise Suite Count */
159
WPA_PUT_LE16(pos, 1);
162
/* Pairwise Suite List */
163
if (sm->pairwise_cipher == WPA_CIPHER_CCMP)
164
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP);
165
else if (sm->pairwise_cipher == WPA_CIPHER_TKIP)
166
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_TKIP);
168
wpa_printf(MSG_WARNING, "FT: Invalid pairwise cipher (%d)",
169
sm->pairwise_cipher);
173
pos += RSN_SELECTOR_LEN;
175
/* Authenticated Key Management Suite Count */
176
WPA_PUT_LE16(pos, 1);
179
/* Authenticated Key Management Suite List */
180
if (sm->key_mgmt == WPA_KEY_MGMT_FT_IEEE8021X)
181
RSN_SELECTOR_PUT(pos, RSN_AUTH_KEY_MGMT_FT_802_1X);
182
else if (sm->key_mgmt == WPA_KEY_MGMT_FT_PSK)
183
RSN_SELECTOR_PUT(pos, RSN_AUTH_KEY_MGMT_FT_PSK);
185
wpa_printf(MSG_WARNING, "FT: Invalid key management type (%d)",
190
pos += RSN_SELECTOR_LEN;
192
/* RSN Capabilities */
194
#ifdef CONFIG_IEEE80211W
195
if (sm->mgmt_group_cipher == WPA_CIPHER_AES_128_CMAC)
196
capab |= WPA_CAPABILITY_MGMT_FRAME_PROTECTION;
197
#endif /* CONFIG_IEEE80211W */
198
WPA_PUT_LE16(pos, capab);
202
WPA_PUT_LE16(pos, 1);
205
/* PMKID List [PMKR0Name/PMKR1Name] */
206
os_memcpy(pos, pmk_name, WPA_PMK_NAME_LEN);
207
pos += WPA_PMK_NAME_LEN;
209
#ifdef CONFIG_IEEE80211W
210
if (sm->mgmt_group_cipher == WPA_CIPHER_AES_128_CMAC) {
211
/* Management Group Cipher Suite */
212
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_AES_128_CMAC);
213
pos += RSN_SELECTOR_LEN;
215
#endif /* CONFIG_IEEE80211W */
217
rsnie->len = (pos - (u8 *) rsnie) - 2;
220
*pos++ = WLAN_EID_MOBILITY_DOMAIN;
221
*pos++ = sizeof(*mdie);
222
mdie = (struct rsn_mdie *) pos;
223
pos += sizeof(*mdie);
224
os_memcpy(mdie->mobility_domain, sm->mobility_domain,
225
MOBILITY_DOMAIN_ID_LEN);
226
mdie->ft_capab = 0; /* FIX: copy from the target AP's MDIE */
228
/* FTIE[SNonce, R0KH-ID] */
229
*pos++ = WLAN_EID_FAST_BSS_TRANSITION;
231
ftie = (struct rsn_ftie *) pos;
232
pos += sizeof(*ftie);
233
os_memcpy(ftie->snonce, sm->snonce, WPA_NONCE_LEN);
235
os_memcpy(ftie->anonce, anonce, WPA_NONCE_LEN);
236
/* R0KH-ID sub-element */
237
*pos++ = FTIE_SUBELEM_R0KH_ID;
238
*pos++ = sm->r0kh_id_len;
239
os_memcpy(pos, sm->r0kh_id, sm->r0kh_id_len);
240
pos += sm->r0kh_id_len;
241
*ftie_len = pos - ftie_len - 1;
245
* IEEE 802.11r/D9.0, 11A.8.4
246
* MIC shall be calculated over:
247
* non-AP STA MAC address
248
* Target AP MAC address
249
* Transaction seq number (5 for ReassocReq, 3 otherwise)
252
* FTIE (with MIC field set to 0)
253
* RIC-Request (if present)
255
ftie->mic_control[1] = 3; /* Information element count */
256
if (wpa_ft_mic(kck, sm->own_addr, target_ap, 5,
257
((u8 *) mdie) - 2, 2 + sizeof(*mdie),
258
((u8 *) ftie) - 2, 2 + *ftie_len,
259
(u8 *) rsnie, 2 + rsnie->len, NULL, 0,
261
wpa_printf(MSG_INFO, "FT: Failed to calculate MIC");
291
static int wpa_ft_parse_ftie(const u8 *ie, size_t ie_len,
292
struct wpa_ft_ies *parse)
297
parse->ftie_len = ie_len;
299
pos = ie + sizeof(struct rsn_ftie);
302
while (pos + 2 <= end && pos + 2 + pos[1] <= end) {
304
case FTIE_SUBELEM_R1KH_ID:
305
if (pos[1] != FT_R1KH_ID_LEN) {
306
wpa_printf(MSG_DEBUG, "FT: Invalid R1KH-ID "
307
"length in FTIE: %d", pos[1]);
310
parse->r1kh_id = pos + 2;
312
case FTIE_SUBELEM_GTK:
313
parse->gtk = pos + 2;
314
parse->gtk_len = pos[1];
316
case FTIE_SUBELEM_R0KH_ID:
317
if (pos[1] < 1 || pos[1] > FT_R0KH_ID_MAX_LEN) {
318
wpa_printf(MSG_DEBUG, "FT: Invalid R0KH-ID "
319
"length in FTIE: %d", pos[1]);
322
parse->r0kh_id = pos + 2;
323
parse->r0kh_id_len = pos[1];
334
static int wpa_ft_parse_ies(const u8 *ies, size_t ies_len,
335
struct wpa_ft_ies *parse)
338
struct wpa_ie_data data;
341
os_memset(parse, 0, sizeof(*parse));
347
while (pos + 2 <= end && pos + 2 + pos[1] <= end) {
350
parse->rsn = pos + 2;
351
parse->rsn_len = pos[1];
352
ret = wpa_parse_wpa_ie_rsn(parse->rsn - 2,
356
wpa_printf(MSG_DEBUG, "FT: Failed to parse "
360
if (data.num_pmkid == 1 && data.pmkid)
361
parse->rsn_pmkid = data.pmkid;
363
case WLAN_EID_MOBILITY_DOMAIN:
364
parse->mdie = pos + 2;
365
parse->mdie_len = pos[1];
367
case WLAN_EID_FAST_BSS_TRANSITION:
368
if (wpa_ft_parse_ftie(pos + 2, pos[1], parse) < 0)
371
case WLAN_EID_TIMEOUT_INTERVAL:
372
parse->tie = pos + 2;
373
parse->tie_len = pos[1];
384
static int wpa_ft_install_ptk(struct wpa_sm *sm, const u8 *bssid)
388
u8 null_rsc[6] = { 0, 0, 0, 0, 0, 0 };
390
wpa_printf(MSG_DEBUG, "FT: Installing PTK to the driver.");
392
switch (sm->pairwise_cipher) {
393
case WPA_CIPHER_CCMP:
397
case WPA_CIPHER_TKIP:
402
wpa_printf(MSG_WARNING, "FT: Unsupported pairwise cipher %d",
403
sm->pairwise_cipher);
407
if (wpa_sm_set_key(sm, alg, bssid, 0, 1, null_rsc,
408
sizeof(null_rsc), (u8 *) sm->ptk.tk1, keylen) < 0) {
409
wpa_printf(MSG_WARNING, "FT: Failed to set PTK to the driver");
418
* wpa_ft_prepare_auth_request - Generate over-the-air auth request
419
* @sm: Pointer to WPA state machine data from wpa_sm_init()
420
* Returns: 0 on success, -1 on failure
422
int wpa_ft_prepare_auth_request(struct wpa_sm *sm)
427
/* Generate a new SNonce */
428
if (os_get_random(sm->snonce, WPA_NONCE_LEN)) {
429
wpa_printf(MSG_INFO, "FT: Failed to generate a new SNonce");
433
ft_ies = wpa_ft_gen_req_ies(sm, &ft_ies_len, NULL, sm->pmk_r0_name,
436
wpa_sm_update_ft_ies(sm, sm->mobility_domain,
445
int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
446
int ft_action, const u8 *target_ap)
450
struct wpa_ft_ies parse;
451
struct rsn_mdie *mdie;
452
struct rsn_ftie *ftie;
453
u8 ptk_name[WPA_PMK_NAME_LEN];
457
wpa_hexdump(MSG_DEBUG, "FT: Response IEs", ies, ies_len);
460
if (!sm->over_the_ds_in_progress) {
461
wpa_printf(MSG_DEBUG, "FT: No over-the-DS in progress "
462
"- drop FT Action Response");
466
if (os_memcmp(target_ap, sm->target_ap, ETH_ALEN) != 0) {
467
wpa_printf(MSG_DEBUG, "FT: No over-the-DS in progress "
468
"with this Target AP - drop FT Action "
474
if (sm->key_mgmt != WPA_KEY_MGMT_FT_IEEE8021X &&
475
sm->key_mgmt != WPA_KEY_MGMT_FT_PSK) {
476
wpa_printf(MSG_DEBUG, "FT: Reject FT IEs since FT is not "
477
"enabled for this connection");
481
if (wpa_ft_parse_ies(ies, ies_len, &parse) < 0) {
482
wpa_printf(MSG_DEBUG, "FT: Failed to parse IEs");
486
mdie = (struct rsn_mdie *) parse.mdie;
487
if (mdie == NULL || parse.mdie_len < sizeof(*mdie) ||
488
os_memcmp(mdie->mobility_domain, sm->mobility_domain,
489
MOBILITY_DOMAIN_ID_LEN) != 0) {
490
wpa_printf(MSG_DEBUG, "FT: Invalid MDIE");
494
ftie = (struct rsn_ftie *) parse.ftie;
495
if (ftie == NULL || parse.ftie_len < sizeof(*ftie)) {
496
wpa_printf(MSG_DEBUG, "FT: Invalid FTIE");
500
if (parse.r0kh_id == NULL) {
501
wpa_printf(MSG_DEBUG, "FT: No R0KH-ID subelem in FTIE");
505
if (parse.r0kh_id_len != sm->r0kh_id_len ||
506
os_memcmp(parse.r0kh_id, sm->r0kh_id, parse.r0kh_id_len) != 0) {
507
wpa_printf(MSG_DEBUG, "FT: R0KH-ID in FTIE did not match with "
508
"the current R0KH-ID");
509
wpa_hexdump(MSG_DEBUG, "FT: R0KH-ID in FTIE",
510
parse.r0kh_id, parse.r0kh_id_len);
511
wpa_hexdump(MSG_DEBUG, "FT: The current R0KH-ID",
512
sm->r0kh_id, sm->r0kh_id_len);
516
if (parse.r1kh_id == NULL) {
517
wpa_printf(MSG_DEBUG, "FT: No R1KH-ID subelem in FTIE");
521
if (parse.rsn_pmkid == NULL ||
522
os_memcmp(parse.rsn_pmkid, sm->pmk_r0_name, WPA_PMK_NAME_LEN)) {
523
wpa_printf(MSG_DEBUG, "FT: No matching PMKR0Name (PMKID) in "
528
os_memcpy(sm->r1kh_id, parse.r1kh_id, FT_R1KH_ID_LEN);
529
wpa_hexdump(MSG_DEBUG, "FT: R1KH-ID", sm->r1kh_id, FT_R1KH_ID_LEN);
530
wpa_hexdump(MSG_DEBUG, "FT: SNonce", sm->snonce, WPA_NONCE_LEN);
531
wpa_hexdump(MSG_DEBUG, "FT: ANonce", ftie->anonce, WPA_NONCE_LEN);
532
wpa_derive_pmk_r1(sm->pmk_r0, sm->pmk_r0_name, sm->r1kh_id,
533
sm->own_addr, sm->pmk_r1, sm->pmk_r1_name);
534
wpa_hexdump_key(MSG_DEBUG, "FT: PMK-R1", sm->pmk_r1, PMK_LEN);
535
wpa_hexdump(MSG_DEBUG, "FT: PMKR1Name",
536
sm->pmk_r1_name, WPA_PMK_NAME_LEN);
538
bssid = ft_action ? sm->target_ap : sm->bssid;
539
wpa_pmk_r1_to_ptk(sm->pmk_r1, sm->snonce, ftie->anonce, sm->own_addr,
540
bssid, sm->pmk_r1_name,
541
(u8 *) &sm->ptk, sizeof(sm->ptk), ptk_name);
542
wpa_hexdump_key(MSG_DEBUG, "FT: PTK",
543
(u8 *) &sm->ptk, sizeof(sm->ptk));
544
wpa_hexdump(MSG_DEBUG, "FT: PTKName", ptk_name, WPA_PMK_NAME_LEN);
546
ft_ies = wpa_ft_gen_req_ies(sm, &ft_ies_len, ftie->anonce,
547
sm->pmk_r1_name, sm->ptk.kck, bssid);
549
wpa_sm_update_ft_ies(sm, sm->mobility_domain,
554
ret = wpa_ft_install_ptk(sm, bssid);
557
sm->ft_completed = 1;
559
/* TODO: trigger re-association to the Target AP;
560
* MLME is now doing this automatically, but it should
561
* really be done only if we get here successfully. */
562
os_memcpy(sm->bssid, target_ap, ETH_ALEN);
570
int wpa_ft_is_completed(struct wpa_sm *sm)
575
if (sm->key_mgmt != WPA_KEY_MGMT_FT_IEEE8021X &&
576
sm->key_mgmt != WPA_KEY_MGMT_FT_PSK)
579
return sm->ft_completed;
583
int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
586
struct wpa_ft_ies parse;
587
struct rsn_mdie *mdie;
588
struct rsn_ftie *ftie;
589
size_t count, gtk_len, keylen, rsc_len;
595
wpa_hexdump(MSG_DEBUG, "FT: Response IEs", ies, ies_len);
597
if (sm->key_mgmt != WPA_KEY_MGMT_FT_IEEE8021X &&
598
sm->key_mgmt != WPA_KEY_MGMT_FT_PSK) {
599
wpa_printf(MSG_DEBUG, "FT: Reject FT IEs since FT is not "
600
"enabled for this connection");
604
if (wpa_ft_parse_ies(ies, ies_len, &parse) < 0) {
605
wpa_printf(MSG_DEBUG, "FT: Failed to parse IEs");
609
mdie = (struct rsn_mdie *) parse.mdie;
610
if (mdie == NULL || parse.mdie_len < sizeof(*mdie) ||
611
os_memcmp(mdie->mobility_domain, sm->mobility_domain,
612
MOBILITY_DOMAIN_ID_LEN) != 0) {
613
wpa_printf(MSG_DEBUG, "FT: Invalid MDIE");
617
ftie = (struct rsn_ftie *) parse.ftie;
618
if (ftie == NULL || parse.ftie_len < sizeof(*ftie)) {
619
wpa_printf(MSG_DEBUG, "FT: Invalid FTIE");
623
if (parse.r0kh_id == NULL) {
624
wpa_printf(MSG_DEBUG, "FT: No R0KH-ID subelem in FTIE");
628
if (parse.r0kh_id_len != sm->r0kh_id_len ||
629
os_memcmp(parse.r0kh_id, sm->r0kh_id, parse.r0kh_id_len) != 0) {
630
wpa_printf(MSG_DEBUG, "FT: R0KH-ID in FTIE did not match with "
631
"the current R0KH-ID");
632
wpa_hexdump(MSG_DEBUG, "FT: R0KH-ID in FTIE",
633
parse.r0kh_id, parse.r0kh_id_len);
634
wpa_hexdump(MSG_DEBUG, "FT: The current R0KH-ID",
635
sm->r0kh_id, sm->r0kh_id_len);
639
if (parse.r1kh_id == NULL) {
640
wpa_printf(MSG_DEBUG, "FT: No R1KH-ID subelem in FTIE");
644
if (os_memcmp(parse.r1kh_id, sm->r1kh_id, FT_R1KH_ID_LEN) != 0) {
645
wpa_printf(MSG_DEBUG, "FT: Unknown R1KH-ID used in "
650
if (parse.rsn_pmkid == NULL ||
651
os_memcmp(parse.rsn_pmkid, sm->pmk_r1_name, WPA_PMK_NAME_LEN)) {
652
wpa_printf(MSG_DEBUG, "FT: No matching PMKR1Name (PMKID) in "
653
"RSNIE (pmkid=%d)", !!parse.rsn_pmkid);
661
if (ftie->mic_control[1] != count) {
662
wpa_printf(MSG_DEBUG, "FT: Unexpected IE count in FTIE (%d)",
663
ftie->mic_control[1]);
667
if (wpa_ft_mic(sm->ptk.kck, sm->own_addr, sm->bssid, 6,
668
parse.mdie - 2, parse.mdie_len + 2,
669
parse.ftie - 2, parse.ftie_len + 2,
670
parse.rsn - 2, parse.rsn_len + 2, NULL, 0,
672
wpa_printf(MSG_DEBUG, "FT: Failed to calculate MIC");
676
if (os_memcmp(mic, ftie->mic, 16) != 0) {
677
wpa_printf(MSG_DEBUG, "FT: Invalid MIC in FTIE");
678
wpa_hexdump(MSG_MSGDUMP, "FT: Received MIC", ftie->mic, 16);
679
wpa_hexdump(MSG_MSGDUMP, "FT: Calculated MIC", mic, 16);
683
if (parse.gtk == NULL) {
684
wpa_printf(MSG_DEBUG, "FT: No GTK included in FTIE");
688
wpa_hexdump_key(MSG_DEBUG, "FT: Received GTK in Reassoc Resp",
689
parse.gtk, parse.gtk_len);
691
if (parse.gtk_len < 10 + 24 || (parse.gtk_len - 10) % 8 ||
692
parse.gtk_len - 18 > sizeof(gtk)) {
693
wpa_printf(MSG_DEBUG, "FT: Invalid GTK sub-elem "
694
"length %lu", (unsigned long) parse.gtk_len);
697
gtk_len = parse.gtk_len - 18;
698
if (aes_unwrap(sm->ptk.kek, gtk_len / 8, parse.gtk + 10, gtk)) {
699
wpa_printf(MSG_WARNING, "FT: AES unwrap failed - could not "
704
switch (sm->group_cipher) {
705
case WPA_CIPHER_CCMP:
710
case WPA_CIPHER_TKIP:
715
case WPA_CIPHER_WEP104:
720
case WPA_CIPHER_WEP40:
726
wpa_printf(MSG_WARNING, "WPA: Unsupported Group Cipher %d",
731
if (gtk_len < keylen) {
732
wpa_printf(MSG_DEBUG, "FT: Too short GTK in FTIE");
736
/* Key Info[1] | Key Length[1] | RSC[8] | Key[5..32]. */
738
keyidx = parse.gtk[0] & 0x03;
740
if (parse.gtk[1] != keylen) {
741
wpa_printf(MSG_DEBUG, "FT: GTK length mismatch: received %d "
743
parse.gtk[1], (unsigned long) keylen);
747
wpa_hexdump_key(MSG_DEBUG, "FT: GTK from Reassoc Resp", gtk, keylen);
748
if (wpa_sm_set_key(sm, alg, (u8 *) "\xff\xff\xff\xff\xff\xff",
749
keyidx, 0, parse.gtk + 2, rsc_len, gtk, keylen) < 0)
751
wpa_printf(MSG_WARNING, "WPA: Failed to set GTK to the "
761
* wpa_ft_start_over_ds - Generate over-the-DS auth request
762
* @sm: Pointer to WPA state machine data from wpa_sm_init()
763
* Returns: 0 on success, -1 on failure
765
int wpa_ft_start_over_ds(struct wpa_sm *sm, const u8 *target_ap)
770
wpa_printf(MSG_DEBUG, "FT: Request over-the-DS with " MACSTR,
773
/* Generate a new SNonce */
774
if (os_get_random(sm->snonce, WPA_NONCE_LEN)) {
775
wpa_printf(MSG_INFO, "FT: Failed to generate a new SNonce");
779
ft_ies = wpa_ft_gen_req_ies(sm, &ft_ies_len, NULL, sm->pmk_r0_name,
782
sm->over_the_ds_in_progress = 1;
783
os_memcpy(sm->target_ap, target_ap, ETH_ALEN);
784
wpa_sm_send_ft_action(sm, 1, target_ap, ft_ies, ft_ies_len);
791
#endif /* CONFIG_IEEE80211R */