Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 2710836

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
Enable security to wi-sun with test security key.
1 parent 8994bb2 commit 2710836

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

source/6LoWPAN/adaptation_interface.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#ifdef HAVE_RPL
4444
#include "RPL/rpl_data.h"
4545
#endif
46+
#include "6LoWPAN/ws/ws_common.h"
4647

4748
#define TRACE_GROUP "6lAd"
4849

@@ -650,7 +651,7 @@ buffer_t * lowpan_adaptation_data_process_tx_preprocess(protocol_interface_info_
650651

651652
if (!buf->link_specific.ieee802_15_4.requestAck ) {
652653
buf->link_specific.ieee802_15_4.key_id_mode = B_SECURITY_KEY_ID_MODE_DEFAULT;
653-
} else if (mle_entry && !mle_entry->thread_commission) {
654+
} else if (ws_info(cur) || (mle_entry && !mle_entry->thread_commission)) {
654655
buf->link_specific.ieee802_15_4.key_id_mode = B_SECURITY_KEY_ID_MODE_DEFAULT;
655656
} else {
656657
buf->link_specific.ieee802_15_4.key_id_mode = B_SECURITY_KEY_ID_IMPLICIT;

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,14 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
878878

879879
ws_bootstrap_configuration_reset(cur);
880880
addr_notification_register(ws_bootstrap_address_notification_cb);
881+
//Enable MAC Security by pass
882+
mlme_set_t set_req;
883+
bool state = true;
884+
set_req.attr = macAcceptByPassUnknowDevice;
885+
set_req.attr_index = 0;
886+
set_req.value_pointer = &state;
887+
set_req.value_size = sizeof(bool);
888+
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_req);
881889

882890
return 0;
883891

@@ -1288,6 +1296,19 @@ static bool ws_bootstrap_address_registration_ongoing(protocol_interface_info_en
12881296
return false;
12891297
}
12901298

1299+
static void ws_bootstrap_set_test_key(protocol_interface_info_entry_t *cur)
1300+
{
1301+
uint8_t key_material[16];
1302+
for (int i= 0; i< 16; i++) {
1303+
key_material[i] = 0xcf - i;
1304+
}
1305+
mac_helper_security_key_clean(cur);
1306+
mac_helper_default_security_level_set(cur, 5);
1307+
mac_helper_default_security_key_id_mode_set(cur, MAC_KEY_ID_MODE_IDX);
1308+
//Set Keys
1309+
mac_helper_security_default_key_set(cur, key_material, 1, MAC_KEY_ID_MODE_IDX);
1310+
}
1311+
12911312
static void ws_bootstrap_event_handler(arm_event_s *event)
12921313
{
12931314
ws_bootsrap_event_type_e event_type;
@@ -1319,6 +1340,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
13191340
ws_llc_set_gtkhash(cur, cur->ws_info->gtkhash);
13201341
cur->ws_info->pan_version_timer = PAN_VERSION_LIFETIME;
13211342
ws_bootstrap_fhss_activate(cur);
1343+
ws_bootstrap_set_test_key(cur);
13221344
ws_bootstrap_event_operation_start(cur);
13231345
break;
13241346
}
@@ -1331,6 +1353,8 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
13311353
case WS_AUTHENTICATION_START:
13321354
tr_info("authentication start");
13331355
trickle_stop(&cur->ws_info->trickle_pan_advertisement_solicit);
1356+
//Add Test ecurity key and security level's
1357+
ws_bootstrap_set_test_key(cur);
13341358
ws_bootstrap_event_configuration_start(cur);
13351359
break;
13361360
case WS_CONFIGURATION_START:

test/nanostack/unittest/6LoWPAN/adaptation_interface/test_adaptation_interface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ bool test_lowpan_adapatation_data_process_tx_preprocess()
161161
protocol_interface_info_entry_t entry;
162162
arm_15_4_mac_parameters_t params;
163163
params.mac_next_key_index = 1;
164+
entry.ws_info = NULL;
164165
entry.mac_parameters = &params;
165166
entry.mac_api = &api;
166167
entry.id = 0;

0 commit comments

Comments
 (0)