DPP2: Add parsing of ssid64/ssid_charset in Config Object
The discovery object is now allowed to use either the UTF-8 encoded string ssid or base64url encoded ssid64. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
590bc64d65
commit
57a63b1318
2 changed files with 41 additions and 14 deletions
|
@ -6128,6 +6128,7 @@ static int dpp_parse_conf_obj(struct dpp_authentication *auth,
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
struct json_token *root, *token, *discovery, *cred;
|
struct json_token *root, *token, *discovery, *cred;
|
||||||
struct dpp_config_obj *conf;
|
struct dpp_config_obj *conf;
|
||||||
|
struct wpabuf *ssid64 = NULL;
|
||||||
|
|
||||||
root = json_parse((const char *) conf_obj, conf_obj_len);
|
root = json_parse((const char *) conf_obj, conf_obj_len);
|
||||||
if (!root)
|
if (!root)
|
||||||
|
@ -6155,28 +6156,52 @@ static int dpp_parse_conf_obj(struct dpp_authentication *auth,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssid64 = json_get_member_base64url(discovery, "ssid64");
|
||||||
|
if (ssid64) {
|
||||||
|
wpa_hexdump_ascii(MSG_DEBUG, "DPP: discovery::ssid64",
|
||||||
|
wpabuf_head(ssid64), wpabuf_len(ssid64));
|
||||||
|
if (wpabuf_len(ssid64) > SSID_MAX_LEN) {
|
||||||
|
dpp_auth_fail(auth, "Too long discovery::ssid64 value");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
token = json_get_member(discovery, "ssid");
|
token = json_get_member(discovery, "ssid");
|
||||||
if (!token || token->type != JSON_STRING) {
|
if (!token || token->type != JSON_STRING) {
|
||||||
dpp_auth_fail(auth, "No discovery::ssid string value found");
|
dpp_auth_fail(auth,
|
||||||
|
"No discovery::ssid string value found");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
wpa_hexdump_ascii(MSG_DEBUG, "DPP: discovery::ssid",
|
wpa_hexdump_ascii(MSG_DEBUG, "DPP: discovery::ssid",
|
||||||
token->string, os_strlen(token->string));
|
token->string, os_strlen(token->string));
|
||||||
if (os_strlen(token->string) > SSID_MAX_LEN) {
|
if (os_strlen(token->string) > SSID_MAX_LEN) {
|
||||||
dpp_auth_fail(auth, "Too long discovery::ssid string value");
|
dpp_auth_fail(auth,
|
||||||
|
"Too long discovery::ssid string value");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (auth->num_conf_obj == DPP_MAX_CONF_OBJ) {
|
if (auth->num_conf_obj == DPP_MAX_CONF_OBJ) {
|
||||||
wpa_printf(MSG_DEBUG,
|
wpa_printf(MSG_DEBUG,
|
||||||
"DPP: No room for this many Config Objects - ignore this one");
|
"DPP: No room for this many Config Objects - ignore this one");
|
||||||
json_free(root);
|
ret = 0;
|
||||||
return 0;
|
goto fail;
|
||||||
}
|
}
|
||||||
conf = &auth->conf_obj[auth->num_conf_obj++];
|
conf = &auth->conf_obj[auth->num_conf_obj++];
|
||||||
|
|
||||||
|
if (ssid64) {
|
||||||
|
conf->ssid_len = wpabuf_len(ssid64);
|
||||||
|
os_memcpy(conf->ssid, wpabuf_head(ssid64), conf->ssid_len);
|
||||||
|
} else {
|
||||||
conf->ssid_len = os_strlen(token->string);
|
conf->ssid_len = os_strlen(token->string);
|
||||||
os_memcpy(conf->ssid, token->string, conf->ssid_len);
|
os_memcpy(conf->ssid, token->string, conf->ssid_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
token = json_get_member(discovery, "ssid_charset");
|
||||||
|
if (token && token->type == JSON_NUMBER) {
|
||||||
|
conf->ssid_charset = token->number;
|
||||||
|
wpa_printf(MSG_DEBUG, "DPP: ssid_charset=%d",
|
||||||
|
conf->ssid_charset);
|
||||||
|
}
|
||||||
|
|
||||||
cred = json_get_member(root, "cred");
|
cred = json_get_member(root, "cred");
|
||||||
if (!cred || cred->type != JSON_OBJECT) {
|
if (!cred || cred->type != JSON_OBJECT) {
|
||||||
|
@ -6207,6 +6232,7 @@ static int dpp_parse_conf_obj(struct dpp_authentication *auth,
|
||||||
wpa_printf(MSG_DEBUG, "DPP: JSON parsing completed successfully");
|
wpa_printf(MSG_DEBUG, "DPP: JSON parsing completed successfully");
|
||||||
ret = 0;
|
ret = 0;
|
||||||
fail:
|
fail:
|
||||||
|
wpabuf_free(ssid64);
|
||||||
json_free(root);
|
json_free(root);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,6 +247,7 @@ struct dpp_authentication {
|
||||||
char *connector; /* received signedConnector */
|
char *connector; /* received signedConnector */
|
||||||
u8 ssid[SSID_MAX_LEN];
|
u8 ssid[SSID_MAX_LEN];
|
||||||
u8 ssid_len;
|
u8 ssid_len;
|
||||||
|
int ssid_charset;
|
||||||
char passphrase[64];
|
char passphrase[64];
|
||||||
u8 psk[PMK_LEN];
|
u8 psk[PMK_LEN];
|
||||||
int psk_set;
|
int psk_set;
|
||||||
|
|
Loading…
Reference in a new issue