mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 13:02:44 +01:00
network: add network_set_passphrase
This lets other modules (like WSC) to set a plain text passphrase as opposed to only allowing a PSK to be set. network_get_psk was also updated to generate a PSK on-the-fly if required. Since WPA3 requires the raw passphrase to work, it makes sense to just store the passphrase if we have it.
This commit is contained in:
parent
8be98d6149
commit
2c14e73f82
@ -250,6 +250,18 @@ enum security network_get_security(const struct network *network)
|
||||
|
||||
const uint8_t *network_get_psk(struct network *network)
|
||||
{
|
||||
if (network->psk)
|
||||
return network->psk;
|
||||
|
||||
if (!network->passphrase)
|
||||
return NULL;
|
||||
|
||||
network->psk = l_malloc(32);
|
||||
|
||||
crypto_psk_from_passphrase(network->passphrase,
|
||||
(unsigned char *)network->ssid,
|
||||
strlen(network->ssid), network->psk);
|
||||
|
||||
return network->psk;
|
||||
}
|
||||
|
||||
@ -258,6 +270,20 @@ const char *network_get_passphrase(const struct network *network)
|
||||
return network->passphrase;
|
||||
}
|
||||
|
||||
bool network_set_passphrase(struct network *network, const char *passphrase)
|
||||
{
|
||||
if (network_get_security(network) != SECURITY_PSK)
|
||||
return false;
|
||||
|
||||
if (!network_settings_load(network))
|
||||
network->settings = l_settings_new();
|
||||
|
||||
network_reset_passphrase(network);
|
||||
network->passphrase = l_strdup(passphrase);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct l_queue *network_get_secrets(const struct network *network)
|
||||
{
|
||||
return network->secrets;
|
||||
|
@ -41,6 +41,7 @@ const char *network_get_path(const struct network *network);
|
||||
enum security network_get_security(const struct network *network);
|
||||
const uint8_t *network_get_psk(struct network *network);
|
||||
const char *network_get_passphrase(const struct network *network);
|
||||
bool network_set_passphrase(struct network *network, const char *passphrase);
|
||||
struct l_queue *network_get_secrets(const struct network *network);
|
||||
int network_get_signal_strength(const struct network *network);
|
||||
struct l_settings *network_get_settings(const struct network *network);
|
||||
|
Loading…
Reference in New Issue
Block a user