3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 23:09:34 +01:00

eapol: Tweak API

We need to extract quite a bit of information from the EAPoL frames, so
tweak the API to just verify that a frame is of a particular type
This commit is contained in:
Denis Kenzior 2015-02-13 16:08:33 -06:00
parent 7ffe465ab2
commit 54d4090542
2 changed files with 32 additions and 35 deletions

View File

@ -110,98 +110,94 @@ const struct eapol_key *eapol_key_validate(const uint8_t *frame, size_t len)
return ek; return ek;
} }
bool eapol_process_ptk_1_of_4(const uint8_t *frame, size_t len, const struct eapol_key *eapol_verify_ptk_1_of_4(const uint8_t *frame,
uint8_t out_anonce[]) size_t len)
{ {
const struct eapol_key *ek; const struct eapol_key *ek;
ek = eapol_key_validate(frame, len); ek = eapol_key_validate(frame, len);
if (!ek) if (!ek)
return false; return NULL;
/* Verify according to 802.11, Section 11.6.6.2 */ /* Verify according to 802.11, Section 11.6.6.2 */
if (!ek->key_type) if (!ek->key_type)
return false; return NULL;
if (ek->smk_message) if (ek->smk_message)
return false; return NULL;
if (ek->install) if (ek->install)
return false; return NULL;
if (!ek->key_ack) if (!ek->key_ack)
return false; return NULL;
if (ek->key_mic) if (ek->key_mic)
return false; return NULL;
if (ek->secure) if (ek->secure)
return false; return NULL;
if (ek->error) if (ek->error)
return false; return NULL;
if (ek->request) if (ek->request)
return false; return NULL;
if (ek->encrypted_key_data) if (ek->encrypted_key_data)
return false; return NULL;
VERIFY_IS_ZERO(ek->eapol_key_iv); VERIFY_IS_ZERO(ek->eapol_key_iv);
VERIFY_IS_ZERO(ek->key_rsc); VERIFY_IS_ZERO(ek->key_rsc);
VERIFY_IS_ZERO(ek->reserved); VERIFY_IS_ZERO(ek->reserved);
VERIFY_IS_ZERO(ek->key_mic_data); VERIFY_IS_ZERO(ek->key_mic_data);
memcpy(out_anonce, ek->key_nonce, sizeof(ek->key_nonce)); return ek;
return true;
} }
bool eapol_process_ptk_2_of_4(const uint8_t *frame, size_t len, const struct eapol_key *eapol_verify_ptk_2_of_4(const uint8_t *frame,
uint8_t out_snonce[]) size_t len)
{ {
const struct eapol_key *ek; const struct eapol_key *ek;
uint16_t key_len; uint16_t key_len;
ek = eapol_key_validate(frame, len); ek = eapol_key_validate(frame, len);
if (!ek) if (!ek)
return false; return NULL;
/* Verify according to 802.11, Section 11.6.6.2 */ /* Verify according to 802.11, Section 11.6.6.2 */
if (!ek->key_type) if (!ek->key_type)
return false; return NULL;
if (ek->smk_message) if (ek->smk_message)
return false; return NULL;
if (ek->install) if (ek->install)
return false; return NULL;
if (ek->key_ack) if (ek->key_ack)
return false; return NULL;
if (!ek->key_mic) if (!ek->key_mic)
return false; return NULL;
if (ek->secure) if (ek->secure)
return false; return NULL;
if (ek->error) if (ek->error)
return false; return NULL;
if (ek->request) if (ek->request)
return false; return NULL;
if (ek->encrypted_key_data) if (ek->encrypted_key_data)
return false; return NULL;
key_len = L_BE16_TO_CPU(ek->key_length); key_len = L_BE16_TO_CPU(ek->key_length);
if (key_len != 0) if (key_len != 0)
return false; return NULL;
memcpy(out_snonce, ek->key_nonce, sizeof(ek->key_nonce)); return ek;
return true;
} }
static struct eapol_key *eapol_create_common( static struct eapol_key *eapol_create_common(

View File

@ -98,10 +98,11 @@ bool eapol_calculate_mic(const uint8_t *kck, const struct eapol_key *frame,
const struct eapol_key *eapol_key_validate(const uint8_t *frame, size_t len); const struct eapol_key *eapol_key_validate(const uint8_t *frame, size_t len);
bool eapol_process_ptk_1_of_4(const uint8_t *frame, size_t len, const struct eapol_key *eapol_verify_ptk_1_of_4(const uint8_t *frame,
uint8_t out_anonce[]); size_t len);
bool eapol_process_ptk_2_of_4(const uint8_t *frame, size_t len, const struct eapol_key *eapol_verify_ptk_2_of_4(const uint8_t *frame,
uint8_t out_snonce[]); size_t len);
struct eapol_key *eapol_create_ptk_2_of_4( struct eapol_key *eapol_create_ptk_2_of_4(
enum eapol_protocol_version protocol, enum eapol_protocol_version protocol,
enum eapol_key_descriptor_version version, enum eapol_key_descriptor_version version,