3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 05:39:24 +01:00

hotspot: implement hotspot profile encryption

Using storage_decrypt() hotspot can also support profile encyption.
The hotspot consortium name is used as the 'ssid' since this stays
consistent between hotspot networks for any profile.
This commit is contained in:
James Prestwood 2022-02-03 08:43:09 -08:00 committed by Denis Kenzior
parent 01cd858760
commit 64f225df6e

View File

@ -95,12 +95,17 @@ static struct l_settings *hotspot_network_open(struct network_info *info)
settings = l_settings_new(); settings = l_settings_new();
if (!l_settings_load_from_file(settings, config->filename)) { if (!l_settings_load_from_file(settings, config->filename))
l_settings_free(settings); goto error;
return NULL;
} if (!storage_decrypt(settings, config->filename, config->name))
goto error;
return settings; return settings;
error:
l_settings_free(settings);
return NULL;
} }
static void hotspot_network_sync(struct network_info *info, static void hotspot_network_sync(struct network_info *info,
@ -111,7 +116,12 @@ static void hotspot_network_sync(struct network_info *info,
struct hs20_config *config = l_container_of(info, struct hs20_config, struct hs20_config *config = l_container_of(info, struct hs20_config,
super); super);
data = l_settings_to_data(settings, &length); data = __storage_encrypt(settings, config->name, &length);
if (!data) {
l_error("Unable to sync profile %s", config->filename);
return;
}
write_file(data, length, true, "%s", config->filename); write_file(data, length, true, "%s", config->filename);
l_free(data); l_free(data);
} }
@ -338,6 +348,11 @@ static struct hs20_config *hs20_config_new(struct l_settings *settings,
goto free_values; goto free_values;
} }
if (!storage_decrypt(settings, filename, name)) {
l_error("Could not open hotspot profile %s", filename);
goto free_values;
}
config = l_new(struct hs20_config, 1); config = l_new(struct hs20_config, 1);
if (hessid_str) { if (hessid_str) {