From 762fb4f06610817f2b0e1ddccb85928be3b090ba Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 13 Nov 2017 12:47:30 +0200 Subject: [PATCH] DPP: Testing capability to send unexpected Authentication Response This is for protocol testing to check what happens if the Responser receives an unexpected Authentication Response instead of Authentication Confirm. Signed-off-by: Jouni Malinen --- src/common/dpp.c | 14 ++++++++++++++ src/common/dpp.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/common/dpp.c b/src/common/dpp.c index e2a6ffd7f..38ce4a587 100644 --- a/src/common/dpp.c +++ b/src/common/dpp.c @@ -2388,6 +2388,8 @@ static int dpp_auth_build_resp_ok(struct dpp_authentication *auth) enum dpp_status_error status = DPP_STATUS_OK; wpa_printf(MSG_DEBUG, "DPP: Build Authentication Response"); + if (!auth->own_bi) + return -1; nonce_len = auth->curve->nonce_len; if (random_get_bytes(auth->r_nonce, nonce_len)) { @@ -2514,6 +2516,8 @@ static int dpp_auth_build_resp_status(struct dpp_authentication *auth, struct wpabuf *msg; const u8 *r_pubkey_hash, *i_pubkey_hash, *i_nonce; + if (!auth->own_bi) + return -1; wpa_printf(MSG_DEBUG, "DPP: Build Authentication Response"); r_pubkey_hash = auth->own_bi->pubkey_hash; @@ -3369,6 +3373,16 @@ dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr, bin_clear_free(unwrapped, unwrapped_len); bin_clear_free(unwrapped2, unwrapped2_len); +#ifdef CONFIG_TESTING_OPTIONS + if (dpp_test == DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF) { + wpa_printf(MSG_INFO, + "DPP: TESTING - Authentication Response in place of Confirm"); + if (dpp_auth_build_resp_ok(auth) < 0) + return NULL; + return wpabuf_dup(auth->resp_msg); + } +#endif /* CONFIG_TESTING_OPTIONS */ + return dpp_auth_build_conf(auth, DPP_STATUS_OK); fail: diff --git a/src/common/dpp.h b/src/common/dpp.h index 6c2805838..c288a5021 100644 --- a/src/common/dpp.h +++ b/src/common/dpp.h @@ -292,6 +292,7 @@ enum dpp_test_behavior { DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62, DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63, DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64, + DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65, }; extern enum dpp_test_behavior dpp_test;