From 21f835e6406425267f5a677107f7dcf31862e4a0 Mon Sep 17 00:00:00 2001 From: Sachin Shelke Date: Mon, 2 Mar 2020 05:18:41 +0530 Subject: [PATCH] SAE: Allow SAE-only network profile with sae_password to be written The commit a34ca59e (SAE: Allow SAE password to be configured separately (STA)) added sae_password configuration option. We should also consider sae_password in the wpa_config_write() function which stores the valid network block details to an external database. Fixes: a34ca59e4db0 ("SAE: Allow SAE password to be configured separately (STA)") Signed-off-by: Sachin Shelke Signed-off-by: Cathy Luo Signed-off-by: Ganapathi Bhat --- src/common/defs.h | 7 +++++++ wpa_supplicant/config_file.c | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/common/defs.h b/src/common/defs.h index 1e21ec2de..6358c3158 100644 --- a/src/common/defs.h +++ b/src/common/defs.h @@ -82,6 +82,13 @@ static inline int wpa_key_mgmt_wpa_ieee8021x(int akm) WPA_KEY_MGMT_FT_FILS_SHA384)); } +static inline int wpa_key_mgmt_wpa_psk_no_sae(int akm) +{ + return !!(akm & (WPA_KEY_MGMT_PSK | + WPA_KEY_MGMT_FT_PSK | + WPA_KEY_MGMT_PSK_SHA256)); +} + static inline int wpa_key_mgmt_wpa_psk(int akm) { return !!(akm & (WPA_KEY_MGMT_PSK | diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index d100d74cb..4c37b61a0 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -1642,8 +1642,11 @@ int wpa_config_write(const char *name, struct wpa_config *config) for (ssid = config->ssid; ssid; ssid = ssid->next) { if (ssid->key_mgmt == WPA_KEY_MGMT_WPS || ssid->temporary) continue; /* do not save temporary networks */ - if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt) && !ssid->psk_set && - !ssid->passphrase) + if (wpa_key_mgmt_wpa_psk_no_sae(ssid->key_mgmt) && + !ssid->psk_set && !ssid->passphrase) + continue; /* do not save invalid network */ + if (wpa_key_mgmt_sae(ssid->key_mgmt) && + !ssid->passphrase && !ssid->sae_password) continue; /* do not save invalid network */ fprintf(f, "\nnetwork={\n"); wpa_config_write_network(f, ssid);