]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Extend protocol testing to allow exchange termination
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 1 Dec 2017 23:04:42 +0000 (01:04 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 2 Dec 2017 10:00:44 +0000 (12:00 +0200)
This extends dpp_test functionality to allow DPP exchanges to be stopped
when receiving a specified message.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/common/dpp.c
src/common/dpp.h

index e3c2774f6ebbf12b632b87739c672fa153a158b8..b056ed0434b6a50a9fa82dbb246d3918cdd28705 100644 (file)
@@ -2830,6 +2830,14 @@ dpp_auth_req_rx(void *msg_ctx, u8 dpp_allowed_roles, int qr_mutual,
                i_bootstrap_len, channel_len;
        struct dpp_authentication *auth = NULL;
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (dpp_test == DPP_TEST_STOP_AT_AUTH_REQ) {
+               wpa_printf(MSG_INFO,
+                          "DPP: TESTING - stop at Authentication Request");
+               return NULL;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        wrapped_data = dpp_get_attr(attr_start, attr_len, DPP_ATTR_WRAPPED_DATA,
                                    &wrapped_data_len);
        if (!wrapped_data || wrapped_data_len < AES_BLOCK_SIZE) {
@@ -3378,6 +3386,14 @@ dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
        u8 r_auth2[DPP_MAX_HASH_LEN];
        u8 role;
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (dpp_test == DPP_TEST_STOP_AT_AUTH_RESP) {
+               wpa_printf(MSG_INFO,
+                          "DPP: TESTING - stop at Authentication Response");
+               return NULL;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        if (!auth->initiator) {
                dpp_auth_fail(auth, "Unexpected Authentication Response");
                return NULL;
@@ -3755,6 +3771,14 @@ int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
        size_t unwrapped_len = 0;
        u8 i_auth2[DPP_MAX_HASH_LEN];
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (dpp_test == DPP_TEST_STOP_AT_AUTH_CONF) {
+               wpa_printf(MSG_INFO,
+                          "DPP: TESTING - stop at Authentication Confirm");
+               return -1;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        if (auth->initiator) {
                dpp_auth_fail(auth, "Unexpected Authentication Confirm");
                return -1;
@@ -4404,6 +4428,14 @@ dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
        struct json_token *root = NULL, *token;
        int ap;
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (dpp_test == DPP_TEST_STOP_AT_CONF_REQ) {
+               wpa_printf(MSG_INFO,
+                          "DPP: TESTING - stop at Config Request");
+               return NULL;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        if (dpp_check_attrs(attr_start, attr_len) < 0) {
                dpp_auth_fail(auth, "Invalid attribute in config request");
                return NULL;
@@ -6843,6 +6875,13 @@ struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
                return NULL;
 
 #ifdef CONFIG_TESTING_OPTIONS
+       if (dpp_test == DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP) {
+               wpa_printf(MSG_INFO,
+                          "DPP: TESTING - stop at PKEX Exchange Response");
+               pkex->failed = 1;
+               return NULL;
+       }
+
        if (!is_zero_ether_addr(dpp_pkex_peer_mac_override)) {
                wpa_printf(MSG_INFO, "DPP: TESTING - peer_mac override " MACSTR,
                           MAC2STR(dpp_pkex_peer_mac_override));
@@ -7159,6 +7198,15 @@ struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
        struct wpabuf *B_pub = NULL;
        u8 u[DPP_MAX_HASH_LEN], v[DPP_MAX_HASH_LEN];
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (dpp_test == DPP_TEST_STOP_AT_PKEX_CR_REQ) {
+               wpa_printf(MSG_INFO,
+                          "DPP: TESTING - stop at PKEX CR Request");
+               pkex->failed = 1;
+               return NULL;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        if (!pkex->exchange_done || pkex->failed ||
            pkex->t >= PKEX_COUNTER_T_LIMIT || pkex->initiator)
                goto fail;
@@ -7336,6 +7384,15 @@ int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
        EVP_PKEY_CTX *ctx = NULL;
        struct wpabuf *B_pub = NULL, *X_pub = NULL, *Y_pub = NULL;
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (dpp_test == DPP_TEST_STOP_AT_PKEX_CR_RESP) {
+               wpa_printf(MSG_INFO,
+                          "DPP: TESTING - stop at PKEX CR Response");
+               pkex->failed = 1;
+               goto fail;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        if (!pkex->exchange_done || pkex->failed ||
            pkex->t >= PKEX_COUNTER_T_LIMIT || !pkex->initiator)
                goto fail;
index 31176edfa55b13c26e3a46bfd2c0f77da95769e1..a23f3db3f3c997ebd42262e019c5e48d48626902 100644 (file)
@@ -325,6 +325,13 @@ enum dpp_test_behavior {
        DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
        DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
        DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
+       DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84,
+       DPP_TEST_STOP_AT_PKEX_CR_REQ = 85,
+       DPP_TEST_STOP_AT_PKEX_CR_RESP = 86,
+       DPP_TEST_STOP_AT_AUTH_REQ = 87,
+       DPP_TEST_STOP_AT_AUTH_RESP = 88,
+       DPP_TEST_STOP_AT_AUTH_CONF = 89,
+       DPP_TEST_STOP_AT_CONF_REQ = 90,
 };
 
 extern enum dpp_test_behavior dpp_test;