30
30
#include "Security/kmp/kmp_addr.h"
31
31
#include "Security/kmp/kmp_api.h"
32
32
#include "Security/kmp/kmp_socket_if.h"
33
- #include "Security/kmp/sec_prot .h"
34
- #include "Security/kmp /key_sec_prot.h"
35
- #include "Security/kmp /eap_tls_sec_prot.h"
36
- #include "Security/kmp /fwh_sec_prot.h"
37
- #include "Security/kmp /gkh_sec_prot.h"
33
+ #include "Security/protocols/sec_prot_keys .h"
34
+ #include "Security/protocols/key_sec_prot /key_sec_prot.h"
35
+ #include "Security/protocols/eap_tls_sec_prot /eap_tls_sec_prot.h"
36
+ #include "Security/protocols /fwh_sec_prot/auth_fwh_sec_prot .h"
37
+ #include "Security/protocols/gkh_sec_prot /gkh_sec_prot.h"
38
38
#include "6LoWPAN/ws/ws_pae_controller.h"
39
39
#include "6LoWPAN/ws/ws_pae_auth.h"
40
40
#include "6LoWPAN/ws/ws_pae_lib.h"
@@ -58,6 +58,7 @@ typedef struct {
58
58
supp_list_t inactive_supp_list ; /**< List of inactive supplicants */
59
59
int8_t tasklet_id ; /**< Tasklet identifier */
60
60
arm_event_storage_t * timer ; /**< Timer */
61
+ sec_prot_gtk_keys_t * gtks ; /**< GTKs */
61
62
} pae_auth_data_t ;
62
63
63
64
static pae_auth_data_t * auth_data ;
@@ -68,13 +69,14 @@ static int8_t ws_pae_auth_timer_if_start(kmp_api_t *kmp);
68
69
static int8_t ws_pae_auth_timer_if_stop (kmp_api_t * kmp );
69
70
static int8_t ws_pae_auth_timer_start (void );
70
71
static int8_t ws_pae_auth_timer_stop (void );
72
+ static void ws_pae_auth_kmp_service_addr_get (kmp_api_t * kmp , kmp_addr_t * local_addr , kmp_addr_t * remote_addr );
71
73
static kmp_api_t * ws_pae_auth_kmp_incoming_ind (kmp_service_t * service , kmp_type_e type , const kmp_addr_t * addr );
72
74
static void ws_pae_auth_kmp_api_create_confirm (kmp_api_t * kmp , kmp_result_e result );
73
75
static void ws_pae_auth_kmp_api_create_indication (kmp_api_t * kmp , kmp_type_e type , kmp_addr_t * addr );
74
76
static void ws_pae_auth_kmp_api_finished_indication (kmp_api_t * kmp , kmp_result_e result , kmp_sec_keys_t * sec_keys );
75
77
static void ws_pae_auth_kmp_api_finished (kmp_api_t * kmp );
76
78
77
- int8_t ws_pae_auth_init (protocol_interface_info_entry_t * interface_ptr )
79
+ int8_t ws_pae_auth_init (protocol_interface_info_entry_t * interface_ptr , sec_prot_gtk_keys_t * gtks )
78
80
{
79
81
if (auth_data ) {
80
82
return 0 ;
@@ -95,6 +97,8 @@ int8_t ws_pae_auth_init(protocol_interface_info_entry_t *interface_ptr)
95
97
return -1 ;
96
98
}
97
99
100
+ auth_data -> gtks = gtks ;
101
+
98
102
if (kmp_service_init () < 0 ) {
99
103
return -1 ;
100
104
}
@@ -104,7 +108,7 @@ int8_t ws_pae_auth_init(protocol_interface_info_entry_t *interface_ptr)
104
108
return -1 ;
105
109
}
106
110
107
- if (kmp_service_cb_register (auth_data -> kmp_service , ws_pae_auth_kmp_incoming_ind )) {
111
+ if (kmp_service_cb_register (auth_data -> kmp_service , ws_pae_auth_kmp_incoming_ind , ws_pae_auth_kmp_service_addr_get )) {
108
112
return -1 ;
109
113
}
110
114
@@ -128,7 +132,7 @@ int8_t ws_pae_auth_init(protocol_interface_info_entry_t *interface_ptr)
128
132
return -1 ;
129
133
}
130
134
131
- if (fwh_auth_sec_prot_register (auth_data -> kmp_service ) < 0 ) {
135
+ if (auth_fwh_sec_prot_register (auth_data -> kmp_service ) < 0 ) {
132
136
return -1 ;
133
137
}
134
138
@@ -241,6 +245,27 @@ static int8_t ws_pae_auth_timer_stop(void)
241
245
return 0 ;
242
246
}
243
247
248
+ static void ws_pae_auth_kmp_service_addr_get (kmp_api_t * kmp , kmp_addr_t * local_addr , kmp_addr_t * remote_addr )
249
+ {
250
+ #if 0
251
+ // Get own EUI-64
252
+ link_layer_address_s mac_params ;
253
+ if (arm_nwk_mac_address_read (auth_data -> interface_ptr -> id , & mac_params ) >= 0 ) {
254
+ kmp_address_eui_64_set (local_addr , mac_params .mac_long );
255
+ }
256
+ #endif
257
+
258
+ // For now fixed since not yet support for EA-IE in supplicants
259
+ uint8_t addr [8 ] = {0x01 ,0x02 ,0x03 ,0x04 ,0x05 ,0x06 ,0x07 ,0x08 };
260
+ kmp_address_eui_64_set (local_addr , addr );
261
+
262
+ // Get supplicant address
263
+ supp_entry_t * entry = kmp_api_data_get (kmp );
264
+ if (entry && entry -> addr ) {
265
+ kmp_address_copy (remote_addr , entry -> addr );
266
+ }
267
+ }
268
+
244
269
static kmp_api_t * ws_pae_auth_kmp_incoming_ind (kmp_service_t * service , kmp_type_e type , const kmp_addr_t * addr )
245
270
{
246
271
// Find supplicant from list of active supplicants
@@ -261,6 +286,10 @@ static kmp_api_t *ws_pae_auth_kmp_incoming_ind(kmp_service_t *service, kmp_type_
261
286
if (!supp_entry ) {
262
287
return 0 ;
263
288
}
289
+ sec_prot_keys_init (& supp_entry -> sec_keys , auth_data -> gtks );
290
+ } else {
291
+ // Updates relay address
292
+ kmp_address_copy (supp_entry -> addr , addr );
264
293
}
265
294
266
295
// Increases waiting time for supplicant authentication
@@ -272,16 +301,20 @@ static kmp_api_t *ws_pae_auth_kmp_incoming_ind(kmp_service_t *service, kmp_type_
272
301
return kmp ;
273
302
}
274
303
275
- // For further study: make needed validations here
276
-
277
304
// Create a new KMP for initial eapol-key
278
305
kmp = kmp_api_create (service , type + IEEE_802_1X_INITIAL_KEY );
279
- kmp_api_data_set (kmp , supp_entry );
280
306
281
307
if (!kmp ) {
282
308
return 0 ;
283
309
}
284
310
311
+ kmp_api_data_set (kmp , supp_entry );
312
+ // Sets address to KMP
313
+ kmp_api_addr_set (kmp , supp_entry -> addr );
314
+
315
+ // Sets security keys to KMP
316
+ kmp_api_sec_keys_set (kmp , & supp_entry -> sec_keys );
317
+
285
318
if (ws_pae_lib_kmp_list_add (& supp_entry -> kmp_list , kmp ) == NULL ) {
286
319
kmp_api_delete (kmp );
287
320
return 0 ;
@@ -293,6 +326,11 @@ static kmp_api_t *ws_pae_auth_kmp_incoming_ind(kmp_service_t *service, kmp_type_
293
326
ws_pae_auth_kmp_api_finished_indication ,
294
327
ws_pae_auth_kmp_api_finished );
295
328
329
+ if (kmp_api_start (kmp ) < 0 ) {
330
+ ws_pae_lib_kmp_list_delete (& supp_entry -> kmp_list , kmp );
331
+ return 0 ;
332
+ }
333
+
296
334
return kmp ;
297
335
}
298
336
@@ -336,10 +374,14 @@ static void ws_pae_auth_kmp_api_finished_indication(kmp_api_t *kmp, kmp_result_e
336
374
} else if (type == IEEE_802_1X_MKA ) {
337
375
// After EAP-TLS start 4WH towards supplicant
338
376
type = IEEE_802_11_4WH ;
377
+ // Insert GTK0
378
+ supp_entry -> sec_keys .gtk_set_index = 0 ;
339
379
tr_debug ("PAE start 4WH, eui-64: %s" , trace_array (kmp_address_eui_64_get (supp_entry -> addr ), 8 ));
340
380
} else if (type == IEEE_802_11_4WH ) {
341
381
// After 4WH start GKH towards supplicant
342
382
type = IEEE_802_11_GKH ;
383
+ // Insert GTK1
384
+ supp_entry -> sec_keys .gtk_set_index = 1 ;
343
385
tr_debug ("PAE start GKH, eui-64: %s" , trace_array (kmp_address_eui_64_get (supp_entry -> addr ), 8 ));
344
386
} else if (type == IEEE_802_11_GKH ) {
345
387
tr_debug ("PAE authenticated, eui-64: %s" , trace_array (kmp_address_eui_64_get (supp_entry -> addr ), 8 ));
@@ -369,7 +411,12 @@ static void ws_pae_auth_kmp_api_finished_indication(kmp_api_t *kmp, kmp_result_e
369
411
ws_pae_auth_kmp_api_finished_indication ,
370
412
ws_pae_auth_kmp_api_finished );
371
413
372
- kmp_api_create_request (new_kmp , type , supp_entry -> addr , NULL );
414
+ if (kmp_api_start (kmp ) < 0 ) {
415
+ ws_pae_lib_kmp_list_delete (& supp_entry -> kmp_list , kmp );
416
+ return ;
417
+ }
418
+
419
+ kmp_api_create_request (new_kmp , type , supp_entry -> addr , & supp_entry -> sec_keys );
373
420
}
374
421
375
422
static void ws_pae_auth_kmp_api_finished (kmp_api_t * kmp )
0 commit comments