eapol: Add __eapol_set_gtk_install_func
This commit is contained in:
parent
75bacbb896
commit
6ec364cb86
21
src/eapol.c
21
src/eapol.c
|
@ -38,11 +38,13 @@
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
#include "eapol.h"
|
#include "eapol.h"
|
||||||
#include "ie.h"
|
#include "ie.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
struct l_queue *state_machines;
|
struct l_queue *state_machines;
|
||||||
eapol_tx_packet_func_t tx_packet = NULL;
|
eapol_tx_packet_func_t tx_packet = NULL;
|
||||||
eapol_get_nonce_func_t get_nonce = NULL;
|
eapol_get_nonce_func_t get_nonce = NULL;
|
||||||
eapol_install_tk_func_t install_tk = 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;
|
enum eapol_protocol_version protocol_version = EAPOL_PROTOCOL_VERSION_2004;
|
||||||
|
|
||||||
#define VERIFY_IS_ZERO(field) \
|
#define VERIFY_IS_ZERO(field) \
|
||||||
|
@ -697,6 +699,7 @@ static void eapol_handle_ptk_3_of_4(uint32_t ifindex,
|
||||||
const uint8_t *gtk;
|
const uint8_t *gtk;
|
||||||
size_t gtk_len;
|
size_t gtk_len;
|
||||||
const uint8_t *rsne;
|
const uint8_t *rsne;
|
||||||
|
uint8_t gtk_key_index;
|
||||||
|
|
||||||
if (!eapol_verify_ptk_3_of_4(ek))
|
if (!eapol_verify_ptk_3_of_4(ek))
|
||||||
return;
|
return;
|
||||||
|
@ -737,6 +740,15 @@ static void eapol_handle_ptk_3_of_4(uint32_t ifindex,
|
||||||
if (!gtk)
|
if (!gtk)
|
||||||
return;
|
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,
|
step4 = eapol_create_ptk_4_of_4(protocol_version,
|
||||||
ek->key_descriptor_version,
|
ek->key_descriptor_version,
|
||||||
sm->replay_counter);
|
sm->replay_counter);
|
||||||
|
@ -750,6 +762,10 @@ static void eapol_handle_ptk_3_of_4(uint32_t ifindex,
|
||||||
if (install_tk)
|
if (install_tk)
|
||||||
install_tk(sm->ifindex, sm->aa, ptk->tk, rsne, sm->user_data);
|
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:
|
fail:
|
||||||
l_free(step4);
|
l_free(step4);
|
||||||
}
|
}
|
||||||
|
@ -876,6 +892,11 @@ void __eapol_set_install_tk_func(eapol_install_tk_func_t func)
|
||||||
install_tk = 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 *eapol_open_pae(uint32_t index)
|
||||||
{
|
{
|
||||||
struct l_io *io;
|
struct l_io *io;
|
||||||
|
|
|
@ -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,
|
typedef void (*eapol_install_tk_func_t)(uint32_t ifindex, const uint8_t *aa,
|
||||||
const uint8_t *tk, const uint8_t *rsn,
|
const uint8_t *tk, const uint8_t *rsn,
|
||||||
void *user_data);
|
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,
|
bool eapol_calculate_mic(const uint8_t *kck, const struct eapol_key *frame,
|
||||||
uint8_t *mic);
|
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_get_nonce_func(eapol_get_nonce_func_t func);
|
||||||
void __eapol_set_protocol_version(enum eapol_protocol_version version);
|
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_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();
|
struct eapol_sm *eapol_sm_new();
|
||||||
void eapol_sm_free(struct eapol_sm *sm);
|
void eapol_sm_free(struct eapol_sm *sm);
|
||||||
|
|
Loading…
Reference in New Issue