From 6ec364cb867e8f706970260a519228068a74076b Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 25 Mar 2015 23:26:31 -0500 Subject: [PATCH] eapol: Add __eapol_set_gtk_install_func --- src/eapol.c | 21 +++++++++++++++++++++ src/eapol.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/src/eapol.c b/src/eapol.c index 1523283c..2a88288d 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -38,11 +38,13 @@ #include "crypto.h" #include "eapol.h" #include "ie.h" +#include "util.h" struct l_queue *state_machines; eapol_tx_packet_func_t tx_packet = NULL; eapol_get_nonce_func_t get_nonce = NULL; eapol_install_tk_func_t install_tk = NULL; +eapol_install_gtk_func_t install_gtk = NULL; enum eapol_protocol_version protocol_version = EAPOL_PROTOCOL_VERSION_2004; #define VERIFY_IS_ZERO(field) \ @@ -697,6 +699,7 @@ static void eapol_handle_ptk_3_of_4(uint32_t ifindex, const uint8_t *gtk; size_t gtk_len; const uint8_t *rsne; + uint8_t gtk_key_index; if (!eapol_verify_ptk_3_of_4(ek)) return; @@ -737,6 +740,15 @@ static void eapol_handle_ptk_3_of_4(uint32_t ifindex, if (!gtk) return; + if (gtk_len < 2) + return; + + gtk_key_index = util_bit_field(gtk[0], 0, 2); + /* TODO: Handle tx bit */ + + gtk += 2; + gtk_len -= 2; + step4 = eapol_create_ptk_4_of_4(protocol_version, ek->key_descriptor_version, sm->replay_counter); @@ -750,6 +762,10 @@ static void eapol_handle_ptk_3_of_4(uint32_t ifindex, if (install_tk) install_tk(sm->ifindex, sm->aa, ptk->tk, rsne, sm->user_data); + if (install_gtk) + install_gtk(sm->ifindex, gtk_key_index, gtk, gtk_len, + ek->key_rsc, 6, rsne, sm->user_data); + fail: l_free(step4); } @@ -876,6 +892,11 @@ void __eapol_set_install_tk_func(eapol_install_tk_func_t func) install_tk = func; } +void __eapol_set_install_gtk_func(eapol_install_gtk_func_t func) +{ + install_gtk = func; +} + struct l_io *eapol_open_pae(uint32_t index) { struct l_io *io; diff --git a/src/eapol.h b/src/eapol.h index 312cc8f8..ba04a9bb 100644 --- a/src/eapol.h +++ b/src/eapol.h @@ -102,6 +102,10 @@ typedef bool (*eapol_get_nonce_func_t)(uint8_t nonce[]); typedef void (*eapol_install_tk_func_t)(uint32_t ifindex, const uint8_t *aa, const uint8_t *tk, const uint8_t *rsn, void *user_data); +typedef void (*eapol_install_gtk_func_t)(uint32_t ifindex, uint8_t key_index, + const uint8_t *gtk, uint8_t gtk_len, + const uint8_t *rsc, uint8_t rsc_len, + const uint8_t *rsn, void *user_data); bool eapol_calculate_mic(const uint8_t *kck, const struct eapol_key *frame, uint8_t *mic); @@ -139,6 +143,7 @@ void __eapol_set_tx_packet_func(eapol_tx_packet_func_t func); void __eapol_set_get_nonce_func(eapol_get_nonce_func_t func); void __eapol_set_protocol_version(enum eapol_protocol_version version); void __eapol_set_install_tk_func(eapol_install_tk_func_t func); +void __eapol_set_install_gtk_func(eapol_install_gtk_func_t func); struct eapol_sm *eapol_sm_new(); void eapol_sm_free(struct eapol_sm *sm);