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

eapol: Add eapol_verify

This commit is contained in:
Denis Kenzior 2014-12-24 13:43:59 -06:00
parent 19fa80cb11
commit 5da6ca89e4
2 changed files with 34 additions and 0 deletions

View File

@ -29,3 +29,35 @@
#include "eapol.h"
bool eapol_verify(const uint8_t *data, size_t len)
{
struct eapol_key *ek;
uint16_t key_data_len;
if (len < sizeof(struct eapol_key))
return false;
ek = (struct eapol_key *) data;
if (ek->protocol_version != EAPOL_PROTOCOL_VERSION_2001 &&
ek->protocol_version != EAPOL_PROTOCOL_VERSION_2004)
return false;
if (ek->packet_type != 3)
return false;
switch (ek->descriptor_type) {
case EAPOL_DESCRIPTOR_TYPE_RC4:
case EAPOL_DESCRIPTOR_TYPE_80211:
case EAPOL_DESCRIPTOR_TYPE_WPA:
break;
default:
return false;
}
key_data_len = L_BE16_TO_CPU(ek->key_data_len);
if (len < sizeof(struct eapol_key) + key_data_len)
return false;
return true;
}

View File

@ -92,3 +92,5 @@ struct eapol_key {
__be16 key_data_len;
uint8_t key_data[0];
} __attribute__ ((packed));
bool eapol_verify(const uint8_t *data, size_t len);