diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c index e4eb1e944..32885ea7d 100644 --- a/src/ap/dpp_hostapd.c +++ b/src/ap/dpp_hostapd.c @@ -1056,6 +1056,21 @@ static void hostapd_dpp_rx_auth_req(struct hostapd_data *hapd, const u8 *src, return; } + if (own_bi->type == DPP_BOOTSTRAP_PKEX) { + if (!peer_bi || peer_bi->type != DPP_BOOTSTRAP_PKEX) { + wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_FAIL + "No matching peer bootstrapping key found for PKEX - ignore message"); + return; + } + + if (os_memcmp(peer_bi->pubkey_hash, own_bi->peer_pubkey_hash, + SHA256_MAC_LEN) != 0) { + wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_FAIL + "Mismatching peer PKEX bootstrapping key - ignore message"); + return; + } + } + if (hapd->dpp_auth) { wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_FAIL "Already in DPP authentication exchange - ignore new one"); diff --git a/src/common/dpp.h b/src/common/dpp.h index b2129fccf..d5f1f58e8 100644 --- a/src/common/dpp.h +++ b/src/common/dpp.h @@ -186,6 +186,9 @@ struct dpp_bootstrap_info { int nfc_negotiated; /* whether this has been used in NFC negotiated * connection handover */ char *configurator_params; + u8 peer_pubkey_hash[SHA256_MAC_LEN]; /* for enforcing a specific + * peer bootstrapping key with + * PKEX */ }; #define PKEX_COUNTER_T_LIMIT 5 diff --git a/src/common/dpp_pkex.c b/src/common/dpp_pkex.c index ff650cf0e..dca0d8d39 100644 --- a/src/common/dpp_pkex.c +++ b/src/common/dpp_pkex.c @@ -1363,6 +1363,8 @@ dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer, dpp_bootstrap_info_free(bi); return NULL; } + os_memcpy(pkex->own_bi->peer_pubkey_hash, bi->pubkey_hash, + SHA256_MAC_LEN); dpp_pkex_free(pkex); dl_list_add(&dpp->bootstrap, &bi->list); return bi; diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c index 4965418b4..fa636fca0 100644 --- a/wpa_supplicant/dpp_supplicant.c +++ b/wpa_supplicant/dpp_supplicant.c @@ -1153,6 +1153,21 @@ static void wpas_dpp_rx_auth_req(struct wpa_supplicant *wpa_s, const u8 *src, return; } + if (own_bi->type == DPP_BOOTSTRAP_PKEX) { + if (!peer_bi || peer_bi->type != DPP_BOOTSTRAP_PKEX) { + wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_FAIL + "No matching peer bootstrapping key found for PKEX - ignore message"); + return; + } + + if (os_memcmp(peer_bi->pubkey_hash, own_bi->peer_pubkey_hash, + SHA256_MAC_LEN) != 0) { + wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_FAIL + "Mismatching peer PKEX bootstrapping key - ignore message"); + return; + } + } + if (wpa_s->dpp_auth) { wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_FAIL "Already in DPP authentication exchange - ignore new one");