From 54fa4f29c75b5a3dc21bfb5c1639fdfa61f2018a Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 24 Feb 2015 11:09:42 -0600 Subject: [PATCH] eapol: Add get_nonce func and setter --- src/eapol.c | 8 ++++++++ src/eapol.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/eapol.c b/src/eapol.c index 50af90f5..8bf6556c 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -32,6 +32,7 @@ #include "eapol.h" struct l_hashmap *state_machines; +eapol_get_nonce_func_t get_nonce = NULL; enum eapol_protocol_version protocol_version = EAPOL_PROTOCOL_VERSION_2004; #define VERIFY_IS_ZERO(field) \ @@ -481,6 +482,12 @@ void eapol_sm_set_own_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie, sm->own_rsn = l_memdup(rsn_ie, len); } + +void __eapol_set_get_nonce_func(eapol_get_nonce_func_t func) +{ + get_nonce = func; +} + bool eapol_init() { state_machines = l_hashmap_new(); @@ -492,6 +499,7 @@ bool eapol_init() bool eapol_exit() { l_hashmap_destroy(state_machines, eapol_sm_destroy); + get_nonce = NULL; return true; } diff --git a/src/eapol.h b/src/eapol.h index 26fff9c8..2ba5a702 100644 --- a/src/eapol.h +++ b/src/eapol.h @@ -95,6 +95,8 @@ struct eapol_key { uint8_t key_data[0]; } __attribute__ ((packed)); +typedef bool (*eapol_get_nonce_func_t)(uint8_t nonce[]); + bool eapol_calculate_mic(const uint8_t *kck, const struct eapol_key *frame, uint8_t *mic); bool eapol_verify_mic(const uint8_t *kck, const struct eapol_key *frame); @@ -122,6 +124,8 @@ struct eapol_key *eapol_create_ptk_4_of_4( enum eapol_key_descriptor_version version, uint64_t key_replay_counter); +void __eapol_set_get_nonce_func(eapol_get_nonce_func_t func); + struct eapol_sm *eapol_sm_new(); void eapol_sm_free(struct eapol_sm *sm);