3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

network: save passphrase in network

SAE needs access to the raw passphrase, not the PSK which network
saves. This changes saves the passphrase in network and handshake
objects, as well as adds getters to both objects so SAE can retrieve
the passphrase.
This commit is contained in:
James Prestwood 2018-08-07 14:29:06 -07:00 committed by Denis Kenzior
parent 7da345a9a5
commit 35278ae108
4 changed files with 22 additions and 0 deletions

View File

@ -78,6 +78,7 @@ void handshake_state_free(struct handshake_state *s)
l_free(s->own_ie);
l_free(s->mde);
l_free(s->fte);
l_free(s->passphrase);
memset(s, 0, sizeof(*s));
@ -228,6 +229,12 @@ void handshake_state_set_event_func(struct handshake_state *s,
s->user_data = user_data;
}
void handshake_state_set_passphrase(struct handshake_state *s,
const char *passphrase)
{
s->passphrase = l_strdup(passphrase);
}
void handshake_state_new_snonce(struct handshake_state *s)
{
get_nonce(s->snonce);

View File

@ -102,6 +102,7 @@ struct handshake_state {
bool have_anonce : 1;
uint8_t ssid[32];
size_t ssid_len;
char *passphrase;
uint8_t r0khid[48];
size_t r0khid_len;
uint8_t r1khid[6];
@ -144,6 +145,8 @@ void handshake_state_set_kh_ids(struct handshake_state *s,
void handshake_state_set_event_func(struct handshake_state *s,
handshake_event_func_t func,
void *user_data);
void handshake_state_set_passphrase(struct handshake_state *s,
const char *passphrase);
void handshake_state_new_snonce(struct handshake_state *s);
void handshake_state_new_anonce(struct handshake_state *s);

View File

@ -51,6 +51,7 @@ struct network {
struct device *device;
struct network_info *info;
unsigned char *psk;
char *passphrase;
unsigned int agent_request;
struct l_queue *bss_list;
struct l_settings *settings;
@ -81,6 +82,9 @@ static void network_settings_close(struct network *network)
l_free(network->psk);
network->psk = NULL;
l_free(network->passphrase);
network->passphrase = NULL;
l_settings_free(network->settings);
network->settings = NULL;
}
@ -317,6 +321,11 @@ const uint8_t *network_get_psk(const struct network *network)
return network->psk;
}
const char *network_get_passphrase(const struct network *network)
{
return network->passphrase;
}
struct l_queue *network_get_secrets(const struct network *network)
{
return network->secrets;
@ -625,6 +634,8 @@ static void passphrase_callback(enum agent_result result,
l_free(network->psk);
network->psk = l_malloc(32);
l_free(network->passphrase);
network->passphrase = l_strdup(passphrase);
if (crypto_psk_from_passphrase(passphrase,
(uint8_t *) network->info->ssid,

View File

@ -40,6 +40,7 @@ struct device *network_get_device(const struct network *network);
const char *network_get_path(const struct network *network);
enum security network_get_security(const struct network *network);
const uint8_t *network_get_psk(const struct network *network);
const char *network_get_passphrase(const struct network *network);
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);