FT: Reassociation Response frame validation for FT-SAE-EXT-KEY
Cover the variable length MIC field when validating the Reassociation Response frame. Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
parent
0f7253d35d
commit
eda4ba081c
1 changed files with 28 additions and 41 deletions
|
@ -1008,10 +1008,8 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
|
|||
u8 mic[WPA_EAPOL_KEY_MIC_MAX_LEN];
|
||||
const u8 *kck;
|
||||
size_t kck_len;
|
||||
int use_sha384 = wpa_key_mgmt_sha384(sm->key_mgmt);
|
||||
const u8 *anonce, *snonce, *fte_mic;
|
||||
u8 fte_elem_count;
|
||||
int own_rsnxe_used, rsnxe_used;
|
||||
int own_rsnxe_used;
|
||||
size_t mic_len;
|
||||
|
||||
wpa_hexdump(MSG_DEBUG, "FT: Response IEs", ies, ies_len);
|
||||
|
||||
|
@ -1040,49 +1038,37 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (use_sha384) {
|
||||
struct rsn_ftie_sha384 *ftie;
|
||||
if (sm->key_mgmt == WPA_KEY_MGMT_FT_SAE_EXT_KEY &&
|
||||
sm->pmk_r1_len == SHA512_MAC_LEN)
|
||||
mic_len = 32;
|
||||
else if ((sm->key_mgmt == WPA_KEY_MGMT_FT_SAE_EXT_KEY &&
|
||||
sm->pmk_r1_len == SHA384_MAC_LEN) ||
|
||||
wpa_key_mgmt_sha384(sm->key_mgmt))
|
||||
mic_len = 24;
|
||||
else
|
||||
mic_len = 16;
|
||||
|
||||
ftie = (struct rsn_ftie_sha384 *) parse.ftie;
|
||||
if (!ftie || parse.ftie_len < sizeof(*ftie)) {
|
||||
wpa_printf(MSG_DEBUG, "FT: Invalid FTIE");
|
||||
if (!parse.ftie || !parse.fte_anonce || !parse.fte_snonce ||
|
||||
parse.fte_mic_len != mic_len) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"FT: Invalid FTE (fte_mic_len=%zu mic_len=%zu)",
|
||||
parse.fte_mic_len, mic_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
anonce = ftie->anonce;
|
||||
snonce = ftie->snonce;
|
||||
rsnxe_used = ftie->mic_control[0] & 0x01;
|
||||
fte_elem_count = ftie->mic_control[1];
|
||||
fte_mic = ftie->mic;
|
||||
} else {
|
||||
struct rsn_ftie *ftie;
|
||||
|
||||
ftie = (struct rsn_ftie *) parse.ftie;
|
||||
if (!ftie || parse.ftie_len < sizeof(*ftie)) {
|
||||
wpa_printf(MSG_DEBUG, "FT: Invalid FTIE");
|
||||
return -1;
|
||||
}
|
||||
|
||||
anonce = ftie->anonce;
|
||||
snonce = ftie->snonce;
|
||||
rsnxe_used = ftie->mic_control[0] & 0x01;
|
||||
fte_elem_count = ftie->mic_control[1];
|
||||
fte_mic = ftie->mic;
|
||||
}
|
||||
|
||||
if (os_memcmp(snonce, sm->snonce, WPA_NONCE_LEN) != 0) {
|
||||
if (os_memcmp(parse.fte_snonce, sm->snonce, WPA_NONCE_LEN) != 0) {
|
||||
wpa_printf(MSG_DEBUG, "FT: SNonce mismatch in FTIE");
|
||||
wpa_hexdump(MSG_DEBUG, "FT: Received SNonce",
|
||||
snonce, WPA_NONCE_LEN);
|
||||
parse.fte_snonce, WPA_NONCE_LEN);
|
||||
wpa_hexdump(MSG_DEBUG, "FT: Expected SNonce",
|
||||
sm->snonce, WPA_NONCE_LEN);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (os_memcmp(anonce, sm->anonce, WPA_NONCE_LEN) != 0) {
|
||||
if (os_memcmp(parse.fte_anonce, sm->anonce, WPA_NONCE_LEN) != 0) {
|
||||
wpa_printf(MSG_DEBUG, "FT: ANonce mismatch in FTIE");
|
||||
wpa_hexdump(MSG_DEBUG, "FT: Received ANonce",
|
||||
anonce, WPA_NONCE_LEN);
|
||||
parse.fte_anonce, WPA_NONCE_LEN);
|
||||
wpa_hexdump(MSG_DEBUG, "FT: Expected ANonce",
|
||||
sm->anonce, WPA_NONCE_LEN);
|
||||
return -1;
|
||||
|
@ -1129,10 +1115,10 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
|
|||
count += ieee802_11_ie_count(parse.ric, parse.ric_len);
|
||||
if (parse.rsnxe)
|
||||
count++;
|
||||
if (fte_elem_count != count) {
|
||||
if (parse.fte_elem_count != count) {
|
||||
wpa_printf(MSG_DEBUG, "FT: Unexpected IE count in MIC "
|
||||
"Control: received %u expected %u",
|
||||
fte_elem_count, count);
|
||||
parse.fte_elem_count, count);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1156,14 +1142,15 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (os_memcmp_const(mic, fte_mic, 16) != 0) {
|
||||
if (os_memcmp_const(mic, parse.fte_mic, mic_len) != 0) {
|
||||
wpa_printf(MSG_DEBUG, "FT: Invalid MIC in FTIE");
|
||||
wpa_hexdump(MSG_MSGDUMP, "FT: Received MIC", fte_mic, 16);
|
||||
wpa_hexdump(MSG_MSGDUMP, "FT: Calculated MIC", mic, 16);
|
||||
wpa_hexdump(MSG_MSGDUMP, "FT: Received MIC",
|
||||
parse.fte_mic, mic_len);
|
||||
wpa_hexdump(MSG_MSGDUMP, "FT: Calculated MIC", mic, mic_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rsnxe_used && !sm->ap_rsnxe) {
|
||||
if (parse.fte_rsnxe_used && !sm->ap_rsnxe) {
|
||||
wpa_printf(MSG_INFO,
|
||||
"FT: FTE indicated that AP uses RSNXE, but RSNXE was not included in Beacon/Probe Response frames");
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue