DPP: Allow name and mudurl to be configured for Config Request

The new hostapd and wpa_supplicant configuration parameters dpp_name and
dpp_mud_url can now be used to set a specific name and MUD URL for the
Enrollee to use in the Configuration Request. dpp_name replaces the
previously hardcoded "Test" string (which is still the default if an
explicit configuration entry is not included). dpp_mud_url can
optionally be used to add a MUD URL to describe the Enrollee device.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2019-09-17 13:36:22 +03:00 committed by Jouni Malinen
parent 91a0703157
commit 5a5639b068
11 changed files with 127 additions and 41 deletions

View file

@ -2376,7 +2376,7 @@ static struct wpabuf * dpp_build_conf_req_attr(struct dpp_authentication *auth,
}
wpa_hexdump(MSG_DEBUG, "DPP: E-nonce", auth->e_nonce, nonce_len);
json_len = os_strlen(json);
wpa_hexdump_ascii(MSG_DEBUG, "DPP: configAttr JSON", json, json_len);
wpa_hexdump_ascii(MSG_DEBUG, "DPP: configRequest JSON", json, json_len);
/* { E-nonce, configAttrib }ke */
clear_len = 4 + nonce_len + 4 + json_len;
@ -2512,6 +2512,59 @@ struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
}
struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
const char *name, int netrole_ap,
const char *mud_url)
{
size_t len, nlen;
const char *tech = "infra";
const char *dpp_name;
char *nbuf;
struct wpabuf *buf, *json;
#ifdef CONFIG_TESTING_OPTIONS
if (dpp_test == DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ) {
static const char *bogus_tech = "knfra";
wpa_printf(MSG_INFO, "DPP: TESTING - invalid Config Attr");
tech = bogus_tech;
}
#endif /* CONFIG_TESTING_OPTIONS */
dpp_name = name ? name : "Test";
len = os_strlen(dpp_name);
nlen = len * 6 + 1;
nbuf = os_malloc(nlen);
if (!nbuf)
return NULL;
json_escape_string(nbuf, nlen, dpp_name, len);
len = 100 + os_strlen(nbuf);
if (mud_url && mud_url[0])
len += 10 + os_strlen(mud_url);
json = wpabuf_alloc(len);
if (!json) {
os_free(nbuf);
return NULL;
}
wpabuf_printf(json,
"{\"name\":\"%s\","
"\"wi-fi_tech\":\"%s\","
"\"netRole\":\"%s\"",
nbuf, tech, netrole_ap ? "ap" : "sta");
if (mud_url && mud_url[0])
wpabuf_printf(json, ",\"mudurl\":\"%s\"", mud_url);
wpabuf_put_str(json, "}");
os_free(nbuf);
buf = dpp_build_conf_req(auth, wpabuf_head(json));
wpabuf_free(json);
return buf;
}
static void dpp_auth_success(struct dpp_authentication *auth)
{
wpa_printf(MSG_DEBUG,
@ -5102,6 +5155,10 @@ dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
goto fail;
}
token = json_get_member(root, "mudurl");
if (token && token->type == JSON_STRING)
wpa_printf(MSG_DEBUG, "DPP: mudurl = '%s'", token->string);
resp = dpp_build_conf_resp(auth, e_nonce, e_nonce_len, ap);
fail:
@ -9194,23 +9251,9 @@ static void dpp_controller_start_gas_client(struct dpp_connection *conn)
{
struct dpp_authentication *auth = conn->auth;
struct wpabuf *buf;
char json[100];
int netrole_ap = 0; /* TODO: make this configurable */
os_snprintf(json, sizeof(json),
"{\"name\":\"Test\","
"\"wi-fi_tech\":\"infra\","
"\"netRole\":\"%s\"}",
netrole_ap ? "ap" : "sta");
#ifdef CONFIG_TESTING_OPTIONS
if (dpp_test == DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ) {
wpa_printf(MSG_INFO, "DPP: TESTING - invalid Config Attr");
json[29] = 'k'; /* replace "infra" with "knfra" */
}
#endif /* CONFIG_TESTING_OPTIONS */
wpa_printf(MSG_DEBUG, "DPP: GAS Config Attributes: %s", json);
buf = dpp_build_conf_req(auth, json);
buf = dpp_build_conf_req_helper(auth, "Test", netrole_ap, NULL);
if (!buf) {
wpa_printf(MSG_DEBUG,
"DPP: No configuration request data available");