]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Allow 3rd party information to be added into config object
authorJouni Malinen <quic_jouni@quicinc.com>
Sat, 16 Jul 2022 09:42:03 +0000 (12:42 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 16 Jul 2022 14:22:23 +0000 (17:22 +0300)
This allows the DPP Configuration Object from a Configurator to be
extended with 3rd party information. This information can be provided as
a part of the existing configuration specification mechanisms with the
new extra_name=<string> and extra_value=<hexdump encoded JSON>.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/common/dpp.c
src/common/dpp.h

index 4ef736c0e5bcab736d5e62b5eeccd85109fd6214..f8532fa9fbf20b7efdb9d054281e4f369e68fdf6 100644 (file)
@@ -1152,6 +1152,8 @@ void dpp_configuration_free(struct dpp_configuration *conf)
        str_clear_free(conf->passphrase);
        os_free(conf->group_id);
        os_free(conf->csrattrs);
+       os_free(conf->extra_name);
+       os_free(conf->extra_value);
        bin_clear_free(conf, sizeof(*conf));
 }
 
@@ -1278,6 +1280,29 @@ static int dpp_configuration_parse_helper(struct dpp_authentication *auth,
                os_memcpy(conf->csrattrs, pos, len);
        }
 
+       pos = os_strstr(cmd, " conf_extra_name=");
+       if (pos) {
+               pos += 17;
+               end = os_strchr(pos, ' ');
+               len = end ? (size_t) (end - pos) : os_strlen(pos);
+               conf->extra_name = os_zalloc(len + 1);
+               if (!conf->extra_name)
+                       goto fail;
+               os_memcpy(conf->extra_name, pos, len);
+       }
+
+       pos = os_strstr(cmd, " conf_extra_value=");
+       if (pos) {
+               pos += 18;
+               end = os_strchr(pos, ' ');
+               len = end ? (size_t) (end - pos) : os_strlen(pos);
+               len /= 2;
+               conf->extra_value = os_zalloc(len + 1);
+               if (!conf->extra_value ||
+                   hexstr2bin(pos, (u8 *) conf->extra_value, len) < 0)
+                       goto fail;
+       }
+
        if (!dpp_configuration_valid(conf))
                goto fail;
 
@@ -1733,6 +1758,9 @@ skip_groups:
                        tailroom += os_strlen(auth->trusted_eap_server_name);
                tailroom += 1000;
        }
+       if (conf->extra_name && conf->extra_value)
+               tailroom += 10 + os_strlen(conf->extra_name) +
+                       os_strlen(conf->extra_value);
        buf = dpp_build_conf_start(auth, conf, tailroom);
        if (!buf)
                goto fail;
@@ -1793,6 +1821,11 @@ skip_groups:
 #endif /* CONFIG_DPP2 */
 
        json_end_object(buf);
+       if (conf->extra_name && conf->extra_value) {
+               json_value_sep(buf);
+               wpabuf_printf(buf, "\"%s\":%s", conf->extra_name,
+                             conf->extra_value);
+       }
        json_end_object(buf);
 
        wpa_hexdump_ascii_key(MSG_DEBUG, "DPP: Configuration Object",
@@ -1830,8 +1863,12 @@ dpp_build_conf_obj_legacy(struct dpp_authentication *auth,
 {
        struct wpabuf *buf;
        const char *akm_str;
+       size_t len = 1000;
 
-       buf = dpp_build_conf_start(auth, conf, 1000);
+       if (conf->extra_name && conf->extra_value)
+               len += 10 + os_strlen(conf->extra_name) +
+                       os_strlen(conf->extra_value);
+       buf = dpp_build_conf_start(auth, conf, len);
        if (!buf)
                return NULL;
 
@@ -1844,6 +1881,11 @@ dpp_build_conf_obj_legacy(struct dpp_authentication *auth,
        json_value_sep(buf);
        dpp_build_legacy_cred_params(buf, conf);
        json_end_object(buf);
+       if (conf->extra_name && conf->extra_value) {
+               json_value_sep(buf);
+               wpabuf_printf(buf, "\"%s\":%s", conf->extra_name,
+                             conf->extra_value);
+       }
        json_end_object(buf);
 
        wpa_hexdump_ascii_key(MSG_DEBUG, "DPP: Configuration Object (legacy)",
index af03413139f8f9ad78b63c544624f6ac0f68e162..bcafcdf0bb54f2e07121c4ecf8faa1bbf7e49518 100644 (file)
@@ -257,6 +257,8 @@ struct dpp_configuration {
        int psk_set;
 
        char *csrattrs;
+       char *extra_name;
+       char *extra_value;
 };
 
 struct dpp_asymmetric_key {