DPP3: Allow external configuration to be specified on AP for PB

While the most likely production use case for DPP push button is to
provision the AP's current configuration, there might be some use cases
for providing different configuration. Add possibility for doing this by
extending the DPP_PUSH_BUTTON command to accept an optional set of
parameters similarly to the other DPP commands for the Configurator.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2022-07-08 00:12:07 +03:00 committed by Jouni Malinen
parent 8db786a43b
commit 7bbe859873
5 changed files with 30 additions and 4 deletions

View file

@ -3676,7 +3676,10 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
#endif /* CONFIG_DPP2 */
#ifdef CONFIG_DPP3
} else if (os_strcmp(buf, "DPP_PUSH_BUTTON") == 0) {
if (hostapd_dpp_push_button(hapd) < 0)
if (hostapd_dpp_push_button(hapd, NULL) < 0)
reply_len = -1;
} else if (os_strncmp(buf, "DPP_PUSH_BUTTON ", 16) == 0) {
if (hostapd_dpp_push_button(hapd, buf + 15) < 0)
reply_len = -1;
#endif /* CONFIG_DPP3 */
#endif /* CONFIG_DPP */

View file

@ -1509,7 +1509,7 @@ static int hostapd_cli_cmd_dpp_stop_chirp(struct wpa_ctrl *ctrl, int argc,
static int hostapd_cli_cmd_dpp_push_button(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
return wpa_ctrl_command(ctrl, "DPP_PUSH_BUTTON");
return hostapd_cli_cmd(ctrl, "DPP_PUSH_BUTTON", 1, argc, argv);
}
#endif /* CONFIG_DPP3 */
#endif /* CONFIG_DPP */

View file

@ -2348,6 +2348,18 @@ static void hostapd_dpp_pb_pkex_init(struct hostapd_data *hapd,
pkex->exch_req_wait_time = 2000;
pkex->exch_req_tries = 1;
if (ifaces->dpp_pb_cmd) {
/* Use the externally provided configuration */
os_free(hapd->dpp_pkex_auth_cmd);
hapd->dpp_pkex_auth_cmd = os_strdup(ifaces->dpp_pb_cmd);
if (!hapd->dpp_pkex_auth_cmd) {
hostapd_dpp_push_button_stop(hapd);
return;
}
return;
}
/* Build config based on the current AP configuration */
wpa_snprintf_hex(ssid_hex, sizeof(ssid_hex),
(const u8 *) hapd->conf->ssid.ssid,
hapd->conf->ssid.ssid_len);
@ -3487,7 +3499,7 @@ static void hostapd_dpp_push_button_expire(void *eloop_ctx, void *timeout_ctx)
}
int hostapd_dpp_push_button(struct hostapd_data *hapd)
int hostapd_dpp_push_button(struct hostapd_data *hapd, const char *cmd)
{
struct hapd_interfaces *ifaces = hapd->iface->interfaces;
@ -3496,6 +3508,13 @@ int hostapd_dpp_push_button(struct hostapd_data *hapd)
os_get_reltime(&ifaces->dpp_pb_time);
ifaces->dpp_pb_announce_time.sec = 0;
ifaces->dpp_pb_announce_time.usec = 0;
str_clear_free(ifaces->dpp_pb_cmd);
ifaces->dpp_pb_cmd = NULL;
if (cmd) {
ifaces->dpp_pb_cmd = os_strdup(cmd);
if (!ifaces->dpp_pb_cmd)
return -1;
}
eloop_register_timeout(100, 0, hostapd_dpp_push_button_expire,
hapd, NULL);
@ -3532,6 +3551,9 @@ void hostapd_dpp_push_button_stop(struct hostapd_data *hapd)
}
ifaces->dpp_pb_result_indicated = false;
str_clear_free(ifaces->dpp_pb_cmd);
ifaces->dpp_pb_cmd = NULL;
}
#endif /* CONFIG_DPP3 */

View file

@ -45,7 +45,7 @@ int hostapd_dpp_controller_start(struct hostapd_data *hapd, const char *cmd);
int hostapd_dpp_chirp(struct hostapd_data *hapd, const char *cmd);
void hostapd_dpp_chirp_stop(struct hostapd_data *hapd);
void hostapd_dpp_remove_bi(void *ctx, struct dpp_bootstrap_info *bi);
int hostapd_dpp_push_button(struct hostapd_data *hapd);
int hostapd_dpp_push_button(struct hostapd_data *hapd, const char *cmd);
void hostapd_dpp_push_button_stop(struct hostapd_data *hapd);
#endif /* DPP_HOSTAPD_H */

View file

@ -92,6 +92,7 @@ struct hapd_interfaces {
u8 dpp_pb_resp_hash[SHA256_MAC_LEN];
struct os_reltime dpp_pb_last_resp;
bool dpp_pb_result_indicated;
char *dpp_pb_cmd;
#endif /* CONFIG_DPP3 */
#endif /* CONFIG_DPP */