mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-26 10:39:23 +01:00
wsc: store plain text passphrase if available
If the AP sent us the plain passphrase we can now store that rather than generating the PSK. This will allow WPA3 to work properly when WPA3 + WSC is implemented.
This commit is contained in:
parent
2c14e73f82
commit
7a9891dbef
43
src/wsc.c
43
src/wsc.c
@ -63,8 +63,12 @@ struct wsc {
|
|||||||
struct {
|
struct {
|
||||||
char ssid[33];
|
char ssid[33];
|
||||||
enum security security;
|
enum security security;
|
||||||
uint8_t psk[32];
|
union {
|
||||||
|
uint8_t psk[32];
|
||||||
|
char passphrase[64];
|
||||||
|
};
|
||||||
uint8_t addr[6];
|
uint8_t addr[6];
|
||||||
|
bool has_passphrase;
|
||||||
} creds[3];
|
} creds[3];
|
||||||
uint32_t n_creds;
|
uint32_t n_creds;
|
||||||
struct l_settings *eap_settings;
|
struct l_settings *eap_settings;
|
||||||
@ -132,9 +136,24 @@ static void wsc_try_credentials(struct wsc *wsc)
|
|||||||
if (!bss)
|
if (!bss)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (wsc->creds[i].security == SECURITY_PSK &&
|
if (wsc->creds[i].security == SECURITY_PSK) {
|
||||||
!network_set_psk(network, wsc->creds[i].psk))
|
bool ret;
|
||||||
continue;
|
|
||||||
|
/*
|
||||||
|
* Prefer setting passphrase, this will work for both
|
||||||
|
* WPA2 and WPA3 since the PSK can always be generated
|
||||||
|
* if needed
|
||||||
|
*/
|
||||||
|
if (wsc->creds[i].has_passphrase)
|
||||||
|
ret = network_set_passphrase(network,
|
||||||
|
wsc->creds[i].passphrase);
|
||||||
|
else
|
||||||
|
ret = network_set_psk(network,
|
||||||
|
wsc->creds[i].psk);
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
station_connect_network(wsc->station, network, bss,
|
station_connect_network(wsc->station, network, bss,
|
||||||
wsc->pending);
|
wsc->pending);
|
||||||
@ -315,18 +334,10 @@ static void wsc_credential_obtained(struct wsc *wsc,
|
|||||||
explicit_bzero(decoded, 32);
|
explicit_bzero(decoded, 32);
|
||||||
l_free(decoded);
|
l_free(decoded);
|
||||||
} else {
|
} else {
|
||||||
const char *passphrase =
|
strncpy(wsc->creds[wsc->n_creds].passphrase,
|
||||||
(const char *) cred->network_key;
|
(const char *) cred->network_key,
|
||||||
/*
|
cred->network_key_len);
|
||||||
* wscutil should memset cred->network_key to 0 prior
|
wsc->creds[wsc->n_creds].has_passphrase = true;
|
||||||
* to copying in the contents of the passphrase
|
|
||||||
*/
|
|
||||||
if (crypto_psk_from_passphrase(passphrase,
|
|
||||||
cred->ssid, cred->ssid_len,
|
|
||||||
wsc->creds[wsc->n_creds].psk) != 0) {
|
|
||||||
l_warn("Ignoring invalid passphrase");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user