24
24
#include "fhss_config.h"
25
25
#include "NWK_INTERFACE/Include/protocol.h"
26
26
#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"
28
29
#include "Security/kmp/sec_prot.h"
30
+ #include "common_functions.h"
29
31
30
32
#ifdef HAVE_WS
31
33
@@ -81,17 +83,34 @@ static void key_sec_prot_delete(sec_prot_t *prot)
81
83
static void key_sec_prot_create_request (sec_prot_t * prot , sec_prot_keys_t * sec_keys )
82
84
{
83
85
key_sec_prot_int_t * data = key_sec_prot_get (prot );
86
+ (void ) sec_keys ;
84
87
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 ;
88
93
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
92
99
93
- if (prot -> send (prot , eapol_pdu , eapol_pdu_size ) < 0 ) {
100
+
101
+ if (!eapol_decoded_data ) {
94
102
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
+ }
95
114
}
96
115
97
116
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
108
127
109
128
static int8_t key_sec_prot_receive (sec_prot_t * prot , void * pdu , uint16_t size )
110
129
{
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 ;
116
131
// Decoding is successful
117
- if (eapol_decoded_data ) {
132
+ if (eapol_parse_pdu_header (pdu , size , & eapol_pdu )) {
133
+ ns_dyn_mem_free (pdu );
118
134
prot -> create_ind (prot );
119
135
return 0 ;
120
136
} else {
121
137
// No error handling yet, indicate just that ready to be deleted
138
+ ns_dyn_mem_free (pdu );
122
139
prot -> finished (prot );
123
140
return -1 ;
124
141
}
0 commit comments