tests: EAPOL-Key fuzzing tool
Add test-eapol program that can be used for fuzzing the EAPOL-Key Supplicant and Authenticator implementations. This tool can write Supplicant or Authenticator messages into a file as an initialization step and for the fuzzing step, that file (with potential modifications) can be used to replace the internally generated message contents. The TEST_FUZZ=y build parameter is used to make a special build where a hardcoded random number generator and hardcoded timestamp are used to force deterministic behavior for the EAPOL-Key operations. This will also make the implementation ignore Key MIC and AES keywrap errors to allow processing of modified messages to continue further. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
02a0a23939
commit
525923b1d7
4 changed files with 709 additions and 0 deletions
|
@ -1852,7 +1852,15 @@ static int wpa_supplicant_verify_eapol_key_mic(struct wpa_sm *sm,
|
|||
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
|
||||
"WPA: Invalid EAPOL-Key MIC "
|
||||
"when using TPTK - ignoring TPTK");
|
||||
#ifdef TEST_FUZZ
|
||||
wpa_printf(MSG_INFO,
|
||||
"TEST: Ignore Key MIC failure for fuzz testing");
|
||||
goto continue_fuzz;
|
||||
#endif /* TEST_FUZZ */
|
||||
} else {
|
||||
#ifdef TEST_FUZZ
|
||||
continue_fuzz:
|
||||
#endif /* TEST_FUZZ */
|
||||
ok = 1;
|
||||
sm->tptk_set = 0;
|
||||
sm->ptk_set = 1;
|
||||
|
@ -1878,8 +1886,16 @@ static int wpa_supplicant_verify_eapol_key_mic(struct wpa_sm *sm,
|
|||
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
|
||||
"WPA: Invalid EAPOL-Key MIC - "
|
||||
"dropping packet");
|
||||
#ifdef TEST_FUZZ
|
||||
wpa_printf(MSG_INFO,
|
||||
"TEST: Ignore Key MIC failure for fuzz testing");
|
||||
goto continue_fuzz2;
|
||||
#endif /* TEST_FUZZ */
|
||||
return -1;
|
||||
}
|
||||
#ifdef TEST_FUZZ
|
||||
continue_fuzz2:
|
||||
#endif /* TEST_FUZZ */
|
||||
ok = 1;
|
||||
}
|
||||
|
||||
|
@ -1954,14 +1970,25 @@ static int wpa_supplicant_decrypt_key_data(struct wpa_sm *sm,
|
|||
"WPA: No memory for AES-UNWRAP buffer");
|
||||
return -1;
|
||||
}
|
||||
#ifdef TEST_FUZZ
|
||||
os_memset(buf, 0x11, *key_data_len);
|
||||
#endif /* TEST_FUZZ */
|
||||
if (aes_unwrap(sm->ptk.kek, sm->ptk.kek_len, *key_data_len / 8,
|
||||
key_data, buf)) {
|
||||
#ifdef TEST_FUZZ
|
||||
wpa_printf(MSG_INFO,
|
||||
"TEST: Ignore AES unwrap failure for fuzz testing");
|
||||
goto continue_fuzz;
|
||||
#endif /* TEST_FUZZ */
|
||||
bin_clear_free(buf, *key_data_len);
|
||||
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
|
||||
"WPA: AES unwrap failed - "
|
||||
"could not decrypt EAPOL-Key key data");
|
||||
return -1;
|
||||
}
|
||||
#ifdef TEST_FUZZ
|
||||
continue_fuzz:
|
||||
#endif /* TEST_FUZZ */
|
||||
os_memcpy(key_data, buf, *key_data_len);
|
||||
bin_clear_free(buf, *key_data_len);
|
||||
WPA_PUT_BE16(((u8 *) (key + 1)) + mic_len, *key_data_len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue