Skip to content

Commit bbd6ee1

Browse files
Juha HeiskanenMika Leppänen
authored andcommitted
Integrate EAPOL new encode and decode functionality
1 parent 1802ee7 commit bbd6ee1

File tree

4 files changed

+32
-142
lines changed

4 files changed

+32
-142
lines changed

source/Security/eapol/eapol.c

Lines changed: 0 additions & 98 deletions
This file was deleted.

source/Security/eapol/eapol.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

source/Security/kmp/key_sec_prot.c

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
#include "fhss_config.h"
2525
#include "NWK_INTERFACE/Include/protocol.h"
2626
#include "6LoWPAN/ws/ws_config.h"
27-
#include "Security/eapol/eapol.h"
27+
#include "Security/PANA/pana_eap_header.h"
28+
#include "Security/eapol/eapol_helper.h"
2829
#include "Security/kmp/sec_prot.h"
30+
#include "common_functions.h"
2931

3032
#ifdef HAVE_WS
3133

@@ -81,17 +83,34 @@ static void key_sec_prot_delete(sec_prot_t *prot)
8183
static void key_sec_prot_create_request(sec_prot_t *prot, sec_prot_keys_t *sec_keys)
8284
{
8385
key_sec_prot_int_t *data = key_sec_prot_get(prot);
86+
(void) sec_keys;
8487

85-
eapol_decoded_t *eapol_decoded_data = 0; // In future fill with data that defines eapol message
86-
uint16_t eapol_pdu_size;
87-
eapol_pdu_t *eapol_pdu = ws_eapol_encode(eapol_decoded_data, sec_keys, &eapol_pdu_size);
88+
uint8_t kmpid_test[22];
89+
kmpid_test[0] = 0xdd;
90+
kmpid_test[1] = 20;
91+
common_write_24_bit(0x0C5A9E, &kmpid_test[2]);
92+
kmpid_test[5] = 1;
8893

89-
if (!eapol_pdu) {
90-
data->result = SEC_RESULT_ERR_NO_MEM;
91-
}
94+
eapol_pdu_t eapol_pdu;
95+
96+
uint16_t eapol_pdu_size = eapol_pdu_key_frame_init(&eapol_pdu, 22, kmpid_test);
97+
98+
uint8_t *eapol_decoded_data = ns_dyn_mem_temporary_alloc(eapol_pdu_size); // In future fill with data that defines eapol message
9299

93-
if (prot->send(prot, eapol_pdu, eapol_pdu_size) < 0) {
100+
101+
if (!eapol_decoded_data) {
94102
data->result = SEC_RESULT_ERR_NO_MEM;
103+
} else {
104+
//Test Data
105+
eapol_pdu.msg.key.key_information.install = true;
106+
eapol_pdu.msg.key.key_information.pairwise_key = true;
107+
eapol_pdu.msg.key.replay_counter = 10;
108+
eapol_pdu.msg.key.key_length = 32;
109+
eapol_write_pdu_frame(eapol_decoded_data, &eapol_pdu);
110+
111+
if (prot->send(prot, eapol_decoded_data, eapol_pdu_size) < 0) {
112+
data->result = SEC_RESULT_ERR_NO_MEM;
113+
}
95114
}
96115

97116
data->state = KEY_CREATE_REQ;
@@ -108,17 +127,15 @@ static void key_sec_prot_create_response(sec_prot_t *prot, sec_prot_result_e res
108127

109128
static int8_t key_sec_prot_receive(sec_prot_t *prot, void *pdu, uint16_t size)
110129
{
111-
eapol_decoded_t *eapol_decoded_data = ws_eapol_decode(pdu, prot->sec_keys,
112-
size);
113-
114-
ns_dyn_mem_free(pdu);
115-
130+
eapol_pdu_t eapol_pdu;
116131
// Decoding is successful
117-
if (eapol_decoded_data) {
132+
if (eapol_parse_pdu_header(pdu, size, &eapol_pdu)) {
133+
ns_dyn_mem_free(pdu);
118134
prot->create_ind(prot);
119135
return 0;
120136
} else {
121137
// No error handling yet, indicate just that ready to be deleted
138+
ns_dyn_mem_free(pdu);
122139
prot->finished(prot);
123140
return -1;
124141
}

sources.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ SRCS += \
9393
source/RPL/rpl_mrhof.c \
9494
source/RPL/rpl_policy.c \
9595
source/Security/Common/security_lib.c \
96-
source/Security/eapol/eapol.c \
96+
source/Security/eapol/eapol_helper.c \
9797
source/Security/kmp/key_sec_prot.c \
9898
source/Security/kmp/kmp_api.c \
9999
source/Security/kmp/kmp_addr.c \

0 commit comments

Comments
 (0)