Generate a random device identity key and save it to the config file.
Use the same identity key from config to derive DIRA for NAN SDF frames.
Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
os_free(config->dpp_mud_url);
os_free(config->dpp_extra_conf_req_name);
os_free(config->dpp_extra_conf_req_value);
+ wpabuf_free(config->dik);
os_free(config);
}
{ FUNC(p2p_device_persistent_mac_addr), 0 },
{ INT(p2p_interface_random_mac_addr), 0 },
{ INT(p2p_6ghz_disable), 0 },
+ { INT(dik_cipher), 0},
+ { BIN(dik), 0 },
#endif /* CONFIG_P2P */
{ FUNC(country), CFG_CHANGED_COUNTRY },
{ INT(bss_max_count), 0 },
int mld_force_single_link;
#endif /* CONFIG_TESTING_OPTIONS */
+
+ /* Cipher version type */
+ int dik_cipher;
+
+ /* DevIK */
+ struct wpabuf *dik;
};
#endif /* CONFIG_TESTING_OPTIONS */
if (config->ft_prepend_pmkid)
fprintf(f, "ft_prepend_pmkid=%d\n", config->ft_prepend_pmkid);
+ if (config->dik) {
+ fprintf(f, "dik_cipher=%d\n", config->dik_cipher);
+ write_global_bin(f, "dik", config->dik);
+ }
}
#endif /* CONFIG_NO_CONFIG_WRITE */
else
p2p.passphrase_len = 8;
+ if (wpa_s->conf->dik &&
+ wpabuf_len(wpa_s->conf->dik) <= DEVICE_IDENTITY_KEY_MAX_LEN) {
+ p2p.pairing_config.dik_cipher = wpa_s->conf->dik_cipher;
+ p2p.pairing_config.dik_len = wpabuf_len(wpa_s->conf->dik);
+ os_memcpy(p2p.pairing_config.dik_data,
+ wpabuf_head(wpa_s->conf->dik),
+ p2p.pairing_config.dik_len);
+ } else {
+ p2p.pairing_config.dik_cipher = DIRA_CIPHER_VERSION_128;
+ p2p.pairing_config.dik_len = DEVICE_IDENTITY_KEY_LEN;
+ if (os_get_random(p2p.pairing_config.dik_data,
+ p2p.pairing_config.dik_len) < 0)
+ return -1;
+
+ wpa_s->conf->dik =
+ wpabuf_alloc_copy(p2p.pairing_config.dik_data,
+ p2p.pairing_config.dik_len);
+ if (!wpa_s->conf->dik)
+ return -1;
+
+ wpa_s->conf->dik_cipher = p2p.pairing_config.dik_cipher;
+
+ if (wpa_s->conf->update_config &&
+ wpa_config_write(wpa_s->confname, wpa_s->conf))
+ wpa_printf(MSG_DEBUG,
+ "P2P: Failed to update configuration");
+ }
+
global->p2p = p2p_init(&p2p);
if (global->p2p == NULL)
return -1;