handshake: add setter for PMKID

SAE generates the PMKID during the authentication process, rather than
generating it on-the-fly using the PMK. For this reason SAE needs to be
able to set the PMKID once its generated. A new flag was also added
(has_pmkid) which signifies if the PMKID was set or if it should be
generated.
This commit is contained in:
James Prestwood 2018-08-07 14:29:10 -07:00 committed by Denis Kenzior
parent 0b452b9200
commit f68cca43da
2 changed files with 15 additions and 1 deletions

View File

@ -387,10 +387,22 @@ void handshake_state_override_pairwise_cipher(struct handshake_state *s,
s->pairwise_cipher = pairwise;
}
void handshake_state_set_pmkid(struct handshake_state *s, const uint8_t *pmkid)
{
memcpy(s->pmkid, pmkid, 16);
s->have_pmkid = true;
}
bool handshake_state_get_pmkid(struct handshake_state *s, uint8_t *out_pmkid)
{
bool use_sha256;
/* SAE exports pmkid */
if (s->have_pmkid) {
memcpy(out_pmkid, s->pmkid, 16);
return true;
}
if (!s->have_pmk)
return false;

View File

@ -93,6 +93,7 @@ struct handshake_state {
uint8_t pmk_r0_name[16];
uint8_t pmk_r1[32];
uint8_t pmk_r1_name[16];
uint8_t pmkid[16];
struct l_settings *settings_8021x;
bool have_snonce : 1;
bool ptk_complete : 1;
@ -100,6 +101,7 @@ struct handshake_state {
bool have_pmk : 1;
bool mfp : 1;
bool have_anonce : 1;
bool have_pmkid : 1;
uint8_t ssid[32];
size_t ssid_len;
char *passphrase;
@ -152,7 +154,7 @@ void handshake_state_new_snonce(struct handshake_state *s);
void handshake_state_new_anonce(struct handshake_state *s);
void handshake_state_set_anonce(struct handshake_state *s,
const uint8_t *anonce);
void handshake_state_set_pmkid(struct handshake_state *s, const uint8_t *pmkid);
bool handshake_state_derive_ptk(struct handshake_state *s);
const struct crypto_ptk *handshake_state_get_ptk(struct handshake_state *s);
void handshake_state_install_ptk(struct handshake_state *s);