FT: FTE generation for SHA384-based AKM on STA

The MIC field is now a variable length field, so make FTE generation in
wpa_supplicant aware of the two different field lengths.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2018-06-04 15:16:54 +03:00
parent 9a33737a0b
commit 06f1286607

View file

@ -155,9 +155,8 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len,
const u8 *ap_mdie) const u8 *ap_mdie)
{ {
size_t buf_len; size_t buf_len;
u8 *buf, *pos, *ftie_len, *ftie_pos; u8 *buf, *pos, *ftie_len, *ftie_pos, *fte_mic, *elem_count;
struct rsn_mdie *mdie; struct rsn_mdie *mdie;
struct rsn_ftie *ftie;
struct rsn_ie_hdr *rsnie; struct rsn_ie_hdr *rsnie;
u16 capab; u16 capab;
int mdie_len; int mdie_len;
@ -165,7 +164,8 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len,
sm->ft_completed = 0; sm->ft_completed = 0;
sm->ft_reassoc_completed = 0; sm->ft_reassoc_completed = 0;
buf_len = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) + buf_len = 2 + sizeof(struct rsn_mdie) + 2 +
sizeof(struct rsn_ftie_sha384) +
2 + sm->r0kh_id_len + ric_ies_len + 100; 2 + sm->r0kh_id_len + ric_ies_len + 100;
buf = os_zalloc(buf_len); buf = os_zalloc(buf_len);
if (buf == NULL) if (buf == NULL)
@ -273,11 +273,27 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len,
ftie_pos = pos; ftie_pos = pos;
*pos++ = WLAN_EID_FAST_BSS_TRANSITION; *pos++ = WLAN_EID_FAST_BSS_TRANSITION;
ftie_len = pos++; ftie_len = pos++;
ftie = (struct rsn_ftie *) pos; if (wpa_key_mgmt_sha384(sm->key_mgmt)) {
struct rsn_ftie_sha384 *ftie;
ftie = (struct rsn_ftie_sha384 *) pos;
fte_mic = ftie->mic;
elem_count = &ftie->mic_control[1];
pos += sizeof(*ftie); pos += sizeof(*ftie);
os_memcpy(ftie->snonce, sm->snonce, WPA_NONCE_LEN); os_memcpy(ftie->snonce, sm->snonce, WPA_NONCE_LEN);
if (anonce) if (anonce)
os_memcpy(ftie->anonce, anonce, WPA_NONCE_LEN); os_memcpy(ftie->anonce, anonce, WPA_NONCE_LEN);
} else {
struct rsn_ftie *ftie;
ftie = (struct rsn_ftie *) pos;
fte_mic = ftie->mic;
elem_count = &ftie->mic_control[1];
pos += sizeof(*ftie);
os_memcpy(ftie->snonce, sm->snonce, WPA_NONCE_LEN);
if (anonce)
os_memcpy(ftie->anonce, anonce, WPA_NONCE_LEN);
}
if (kck) { if (kck) {
/* R1KH-ID sub-element in third FT message */ /* R1KH-ID sub-element in third FT message */
*pos++ = FTIE_SUBELEM_R1KH_ID; *pos++ = FTIE_SUBELEM_R1KH_ID;
@ -311,13 +327,12 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len,
* RIC-Request (if present) * RIC-Request (if present)
*/ */
/* Information element count */ /* Information element count */
ftie->mic_control[1] = 3 + ieee802_11_ie_count(ric_ies, *elem_count = 3 + ieee802_11_ie_count(ric_ies, ric_ies_len);
ric_ies_len);
if (wpa_ft_mic(kck, kck_len, sm->own_addr, target_ap, 5, if (wpa_ft_mic(kck, kck_len, sm->own_addr, target_ap, 5,
((u8 *) mdie) - 2, 2 + sizeof(*mdie), ((u8 *) mdie) - 2, 2 + sizeof(*mdie),
ftie_pos, 2 + *ftie_len, ftie_pos, 2 + *ftie_len,
(u8 *) rsnie, 2 + rsnie->len, ric_ies, (u8 *) rsnie, 2 + rsnie->len, ric_ies,
ric_ies_len, ftie->mic) < 0) { ric_ies_len, fte_mic) < 0) {
wpa_printf(MSG_INFO, "FT: Failed to calculate MIC"); wpa_printf(MSG_INFO, "FT: Failed to calculate MIC");
os_free(buf); os_free(buf);
return NULL; return NULL;