DPP: Share a helper function for PKEX final steps
Generate the PKEX bootstrapping information and release the PKEX session in a helper function that both the initiator and responder can use instead of maintaining this functionality separately in two places. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
a0604a4236
commit
de02986189
1 changed files with 32 additions and 38 deletions
|
@ -1537,6 +1537,35 @@ wpas_dpp_rx_pkex_exchange_resp(struct wpa_supplicant *wpa_s, const u8 *src,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct dpp_bootstrap_info *
|
||||||
|
wpas_dpp_pkex_finish(struct wpa_supplicant *wpa_s, const u8 *peer,
|
||||||
|
unsigned int freq)
|
||||||
|
{
|
||||||
|
struct dpp_pkex *pkex = wpa_s->dpp_pkex;
|
||||||
|
struct dpp_bootstrap_info *bi;
|
||||||
|
|
||||||
|
bi = os_zalloc(sizeof(*bi));
|
||||||
|
if (!bi)
|
||||||
|
return NULL;
|
||||||
|
bi->id = wpas_dpp_next_id(wpa_s);
|
||||||
|
bi->type = DPP_BOOTSTRAP_PKEX;
|
||||||
|
os_memcpy(bi->mac_addr, peer, ETH_ALEN);
|
||||||
|
bi->num_freq = 1;
|
||||||
|
bi->freq[0] = freq;
|
||||||
|
bi->curve = pkex->own_bi->curve;
|
||||||
|
bi->pubkey = pkex->peer_bootstrap_key;
|
||||||
|
pkex->peer_bootstrap_key = NULL;
|
||||||
|
dpp_pkex_free(pkex);
|
||||||
|
wpa_s->dpp_pkex = NULL;
|
||||||
|
if (dpp_bootstrap_key_hash(bi) < 0) {
|
||||||
|
dpp_bootstrap_info_free(bi);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
dl_list_add(&wpa_s->dpp_bootstrap, &bi->list);
|
||||||
|
return bi;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wpas_dpp_rx_pkex_commit_reveal_req(struct wpa_supplicant *wpa_s, const u8 *src,
|
wpas_dpp_rx_pkex_commit_reveal_req(struct wpa_supplicant *wpa_s, const u8 *src,
|
||||||
const u8 *hdr, const u8 *buf, size_t len,
|
const u8 *hdr, const u8 *buf, size_t len,
|
||||||
|
@ -1545,7 +1574,6 @@ wpas_dpp_rx_pkex_commit_reveal_req(struct wpa_supplicant *wpa_s, const u8 *src,
|
||||||
struct wpabuf *msg;
|
struct wpabuf *msg;
|
||||||
unsigned int wait_time;
|
unsigned int wait_time;
|
||||||
struct dpp_pkex *pkex = wpa_s->dpp_pkex;
|
struct dpp_pkex *pkex = wpa_s->dpp_pkex;
|
||||||
struct dpp_bootstrap_info *bi;
|
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "DPP: PKEX Commit-Reveal Request from " MACSTR,
|
wpa_printf(MSG_DEBUG, "DPP: PKEX Commit-Reveal Request from " MACSTR,
|
||||||
MAC2STR(src));
|
MAC2STR(src));
|
||||||
|
@ -1582,24 +1610,7 @@ wpas_dpp_rx_pkex_commit_reveal_req(struct wpa_supplicant *wpa_s, const u8 *src,
|
||||||
wait_time, wpas_dpp_tx_pkex_status, 0);
|
wait_time, wpas_dpp_tx_pkex_status, 0);
|
||||||
wpabuf_free(msg);
|
wpabuf_free(msg);
|
||||||
|
|
||||||
bi = os_zalloc(sizeof(*bi));
|
wpas_dpp_pkex_finish(wpa_s, src, freq);
|
||||||
if (!bi)
|
|
||||||
return;
|
|
||||||
bi->id = wpas_dpp_next_id(wpa_s);
|
|
||||||
bi->type = DPP_BOOTSTRAP_PKEX;
|
|
||||||
os_memcpy(bi->mac_addr, src, ETH_ALEN);
|
|
||||||
bi->num_freq = 1;
|
|
||||||
bi->freq[0] = freq;
|
|
||||||
bi->curve = pkex->own_bi->curve;
|
|
||||||
bi->pubkey = pkex->peer_bootstrap_key;
|
|
||||||
pkex->peer_bootstrap_key = NULL;
|
|
||||||
dpp_pkex_free(pkex);
|
|
||||||
wpa_s->dpp_pkex = NULL;
|
|
||||||
if (dpp_bootstrap_key_hash(bi) < 0) {
|
|
||||||
dpp_bootstrap_info_free(bi);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dl_list_add(&wpa_s->dpp_bootstrap, &bi->list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1609,7 +1620,7 @@ wpas_dpp_rx_pkex_commit_reveal_resp(struct wpa_supplicant *wpa_s, const u8 *src,
|
||||||
unsigned int freq)
|
unsigned int freq)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct dpp_bootstrap_info *bi, *own_bi;
|
struct dpp_bootstrap_info *bi;
|
||||||
struct dpp_pkex *pkex = wpa_s->dpp_pkex;
|
struct dpp_pkex *pkex = wpa_s->dpp_pkex;
|
||||||
char cmd[500];
|
char cmd[500];
|
||||||
|
|
||||||
|
@ -1627,26 +1638,9 @@ wpas_dpp_rx_pkex_commit_reveal_resp(struct wpa_supplicant *wpa_s, const u8 *src,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
own_bi = pkex->own_bi;
|
bi = wpas_dpp_pkex_finish(wpa_s, src, freq);
|
||||||
|
|
||||||
bi = os_zalloc(sizeof(*bi));
|
|
||||||
if (!bi)
|
if (!bi)
|
||||||
return;
|
return;
|
||||||
bi->id = wpas_dpp_next_id(wpa_s);
|
|
||||||
bi->type = DPP_BOOTSTRAP_PKEX;
|
|
||||||
os_memcpy(bi->mac_addr, src, ETH_ALEN);
|
|
||||||
bi->num_freq = 1;
|
|
||||||
bi->freq[0] = freq;
|
|
||||||
bi->curve = own_bi->curve;
|
|
||||||
bi->pubkey = pkex->peer_bootstrap_key;
|
|
||||||
pkex->peer_bootstrap_key = NULL;
|
|
||||||
dpp_pkex_free(pkex);
|
|
||||||
wpa_s->dpp_pkex = NULL;
|
|
||||||
if (dpp_bootstrap_key_hash(bi) < 0) {
|
|
||||||
dpp_bootstrap_info_free(bi);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dl_list_add(&wpa_s->dpp_bootstrap, &bi->list);
|
|
||||||
|
|
||||||
os_snprintf(cmd, sizeof(cmd), " peer=%u %s",
|
os_snprintf(cmd, sizeof(cmd), " peer=%u %s",
|
||||||
bi->id,
|
bi->id,
|
||||||
|
|
Loading…
Reference in a new issue