3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 18:49:43 +01:00

eapol: Add eapol_process_ptk_1_of_4

This commit is contained in:
Denis Kenzior 2014-12-27 22:31:03 -06:00
parent 7be2fe7cc8
commit 996e32bf1d
2 changed files with 59 additions and 0 deletions

View File

@ -29,6 +29,14 @@
#include "eapol.h"
#define VERIFY_IS_ZERO(field) \
do { \
unsigned int i; \
for (i = 0; i < sizeof(field); i++) \
if ((field)[i] != 0) \
return false; \
} while (false) \
bool eapol_verify(const uint8_t *data, size_t len)
{
struct eapol_key *ek;
@ -70,3 +78,51 @@ bool eapol_verify(const uint8_t *data, size_t len)
return true;
}
bool eapol_process_ptk_1_of_4(const uint8_t *data, size_t len,
uint8_t out_anonce[])
{
struct eapol_key *ek;
if (!eapol_verify(data, len))
return false;
ek = (struct eapol_key *) data;
/* Verify according to 802.11, Section 11.6.6.2 */
if (!ek->key_type)
return false;
if (ek->smk_message)
return false;
if (ek->install)
return false;
if (!ek->key_ack)
return false;
if (ek->key_mic)
return false;
if (ek->secure)
return false;
if (ek->error)
return false;
if (ek->request)
return false;
if (ek->encrypted_key_data)
return false;
VERIFY_IS_ZERO(ek->eapol_key_iv);
VERIFY_IS_ZERO(ek->key_rsc);
VERIFY_IS_ZERO(ek->reserved);
VERIFY_IS_ZERO(ek->key_mic_data);
memcpy(out_anonce, ek->key_nonce, sizeof(ek->key_nonce));
return true;
}

View File

@ -94,3 +94,6 @@ struct eapol_key {
} __attribute__ ((packed));
bool eapol_verify(const uint8_t *data, size_t len);
bool eapol_process_ptk_1_of_4(const uint8_t *data, size_t len,
uint8_t out_anonce[]);