eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 7a9891dbef5b7b32426541cb2970997a6f5f02f9
parent 2c14e73f8271ec9cd8071667638940006d91934a
Author: James Prestwood <prestwoj@gmail.com>
Date:   Wed, 18 Sep 2019 09:02:56 -0700

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.

Diffstat:
Msrc/wsc.c | 43+++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/wsc.c b/src/wsc.c @@ -63,8 +63,12 @@ struct wsc { struct { char ssid[33]; enum security security; - uint8_t psk[32]; + union { + uint8_t psk[32]; + char passphrase[64]; + }; uint8_t addr[6]; + bool has_passphrase; } creds[3]; uint32_t n_creds; struct l_settings *eap_settings; @@ -132,9 +136,24 @@ static void wsc_try_credentials(struct wsc *wsc) if (!bss) continue; - if (wsc->creds[i].security == SECURITY_PSK && - !network_set_psk(network, wsc->creds[i].psk)) - continue; + if (wsc->creds[i].security == SECURITY_PSK) { + bool ret; + + /* + * 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, wsc->pending); @@ -315,18 +334,10 @@ static void wsc_credential_obtained(struct wsc *wsc, explicit_bzero(decoded, 32); l_free(decoded); } else { - const char *passphrase = - (const char *) cred->network_key; - /* - * wscutil should memset cred->network_key to 0 prior - * 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; - } + strncpy(wsc->creds[wsc->n_creds].passphrase, + (const char *) cred->network_key, + cred->network_key_len); + wsc->creds[wsc->n_creds].has_passphrase = true; } break;