From 804fc268af6513706a210edc1eeeb8238bcedb00 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 27 Mar 2020 17:14:06 +0200 Subject: [PATCH] DPP: Allow per-peer configurator parameters to be set This is a more convenient way of addressing cases where a Configurator/Controller may store a large number of peer bootstrapping information instances and may need to manage different configuration parameters for each peer while operating as the Responder. Signed-off-by: Jouni Malinen --- src/common/dpp.c | 11 ++++++++++- src/common/dpp.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/common/dpp.c b/src/common/dpp.c index 57afbd578..7f0f0b6ea 100644 --- a/src/common/dpp.c +++ b/src/common/dpp.c @@ -894,6 +894,7 @@ void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info) os_free(info->chan); os_free(info->pk); EVP_PKEY_free(info->pubkey); + str_clear_free(info->configurator_params); os_free(info); } @@ -2370,6 +2371,9 @@ struct dpp_authentication * dpp_auth_init(struct dpp_global *dpp, void *msg_ctx, auth = dpp_alloc_auth(dpp, msg_ctx); if (!auth) return NULL; + if (peer_bi->configurator_params && + dpp_set_configurator(auth, peer_bi->configurator_params) < 0) + goto fail; auth->initiator = 1; auth->waiting_auth_resp = 1; auth->allowed_roles = dpp_allowed_roles; @@ -3306,6 +3310,9 @@ dpp_auth_req_rx(struct dpp_global *dpp, void *msg_ctx, u8 dpp_allowed_roles, auth = dpp_alloc_auth(dpp, msg_ctx); if (!auth) goto fail; + if (peer_bi && peer_bi->configurator_params && + dpp_set_configurator(auth, peer_bi->configurator_params) < 0) + goto fail; auth->peer_bi = peer_bi; auth->own_bi = own_bi; auth->curve = own_bi->curve; @@ -4683,8 +4690,10 @@ int dpp_set_configurator(struct dpp_authentication *auth, const char *cmd) char *tmp = NULL; int ret = -1; - if (!cmd) + if (!cmd || auth->configurator_set) return 0; + auth->configurator_set = 1; + if (cmd[0] != ' ') { size_t len; diff --git a/src/common/dpp.h b/src/common/dpp.h index d6da0460b..0ec0024cd 100644 --- a/src/common/dpp.h +++ b/src/common/dpp.h @@ -126,6 +126,7 @@ struct dpp_bootstrap_info { const struct dpp_curve_params *curve; unsigned int pkex_t; /* number of failures before dpp_pkex * instantiation */ + char *configurator_params; }; #define PKEX_COUNTER_T_LIMIT 5 @@ -275,6 +276,7 @@ struct dpp_authentication { int send_conn_status; int conn_status_requested; int akm_use_selector; + int configurator_set; #ifdef CONFIG_TESTING_OPTIONS char *config_obj_override; char *discovery_override;