mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
eapol: Add eapol_calculate_mic
This commit is contained in:
parent
27d25efc0b
commit
096165d142
@ -67,6 +67,7 @@ monitor_iwmon_SOURCES = monitor/main.c linux/nl80211.h \
|
||||
src/ie.h src/ie.c \
|
||||
src/util.h src/util.c \
|
||||
src/sha1.h src/sha1.c \
|
||||
src/md5.h src/md5.c \
|
||||
src/eapol.h src/eapol.c
|
||||
monitor_iwmon_LDADD = ell/libell-internal.la
|
||||
|
||||
|
32
src/eapol.c
32
src/eapol.c
@ -27,6 +27,8 @@
|
||||
#include <string.h>
|
||||
#include <ell/ell.h>
|
||||
|
||||
#include "sha1.h"
|
||||
#include "md5.h"
|
||||
#include "eapol.h"
|
||||
|
||||
#define VERIFY_IS_ZERO(field) \
|
||||
@ -37,6 +39,36 @@
|
||||
return false; \
|
||||
} while (false) \
|
||||
|
||||
/*
|
||||
* MIC calculation depends on the selected hash function. The has function
|
||||
* is given in the EAPoL Key Descriptor Version field.
|
||||
*
|
||||
* The MIC length is always 16 bytes for currently known Key Descriptor
|
||||
* Versions.
|
||||
*
|
||||
* The input struct eapol_key *frame should have a zero-d MIC field
|
||||
*/
|
||||
bool eapol_calculate_mic(const uint8_t *kck, const struct eapol_key *frame,
|
||||
uint8_t *mic)
|
||||
{
|
||||
size_t frame_len = sizeof(struct eapol_key);
|
||||
|
||||
frame_len += L_BE16_TO_CPU(frame->key_data_len);
|
||||
|
||||
switch (frame->key_descriptor_version) {
|
||||
case EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4:
|
||||
return hmac_md5(kck, 16, (uint8_t *) frame, frame_len,
|
||||
mic, 16);
|
||||
case EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_SHA1_AES:
|
||||
return hmac_sha1(kck, 16, (uint8_t *) frame, frame_len,
|
||||
mic, 16);
|
||||
case EAPOL_KEY_DESCRIPTOR_VERSION_AES_128_CMAC_AES:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool eapol_verify(const uint8_t *data, size_t len)
|
||||
{
|
||||
struct eapol_key *ek;
|
||||
|
@ -93,6 +93,9 @@ struct eapol_key {
|
||||
uint8_t key_data[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
bool eapol_calculate_mic(const uint8_t *kck, const struct eapol_key *frame,
|
||||
uint8_t *mic);
|
||||
|
||||
bool eapol_verify(const uint8_t *data, size_t len);
|
||||
|
||||
bool eapol_process_ptk_1_of_4(const uint8_t *data, size_t len,
|
||||
|
Loading…
Reference in New Issue
Block a user