3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-24 15:22:34 +01:00

eapol: Add __eapol_set_gtk_install_func

This commit is contained in:
Denis Kenzior 2015-03-25 23:26:31 -05:00
parent 75bacbb896
commit 6ec364cb86
2 changed files with 26 additions and 0 deletions

View File

@ -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;

View File

@ -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);