commit
d828557563
25 changed files with 167 additions and 146 deletions
|
@ -144,7 +144,7 @@ PROCESS_THREAD(node_process, ev, data)
|
|||
|
||||
/* Set node with ID == 1 as coordinator, convenient in Cooja. */
|
||||
if(node_id == 1) {
|
||||
if(LLSEC802154_CONF_SECURITY_LEVEL) {
|
||||
if(LLSEC802154_ENABLED) {
|
||||
node_role = role_6dr_sec;
|
||||
} else {
|
||||
node_role = role_6dr;
|
||||
|
@ -169,7 +169,7 @@ PROCESS_THREAD(node_process, ev, data)
|
|||
|| etimer_expired(&et));
|
||||
if(ev == sensors_event && data == &button_sensor && button_sensor.value(0) > 0) {
|
||||
node_role = (node_role + 1) % 3;
|
||||
if(LLSEC802154_CONF_SECURITY_LEVEL == 0 && node_role == role_6dr_sec) {
|
||||
if(LLSEC802154_ENABLED == 0 && node_role == role_6dr_sec) {
|
||||
node_role = (node_role + 1) % 3;
|
||||
}
|
||||
etimer_restart(&et);
|
||||
|
@ -182,7 +182,7 @@ PROCESS_THREAD(node_process, ev, data)
|
|||
printf("Init: node starting with role %s\n",
|
||||
node_role == role_6ln ? "6ln" : (node_role == role_6dr) ? "6dr" : "6dr-sec");
|
||||
|
||||
tsch_set_pan_secured(LLSEC802154_CONF_SECURITY_LEVEL && (node_role == role_6dr_sec));
|
||||
tsch_set_pan_secured(LLSEC802154_ENABLED && (node_role == role_6dr_sec));
|
||||
is_coordinator = node_role > role_6ln;
|
||||
|
||||
if(is_coordinator) {
|
||||
|
|
|
@ -100,8 +100,8 @@
|
|||
#if WITH_SECURITY
|
||||
|
||||
/* Enable security */
|
||||
#undef LLSEC802154_CONF_SECURITY_LEVEL
|
||||
#define LLSEC802154_CONF_SECURITY_LEVEL 1
|
||||
#undef LLSEC802154_CONF_ENABLED
|
||||
#define LLSEC802154_CONF_ENABLED 1
|
||||
/* TSCH uses explicit keys to identify k1 and k2 */
|
||||
#undef LLSEC802154_CONF_USES_EXPLICIT_KEYS
|
||||
#define LLSEC802154_CONF_USES_EXPLICIT_KEYS 1
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
|
||||
#if WITH_TSCH_SECURITY
|
||||
/* Set security level to the maximum, even if unused, to all crypto code */
|
||||
#define LLSEC802154_CONF_SECURITY_LEVEL 7
|
||||
#define LLSEC802154_CONF_ENABLED 1
|
||||
/* Attempt to associate from both secured and non-secured EBs */
|
||||
#define TSCH_CONF_JOIN_SECURED_ONLY 0
|
||||
/* We need explicit keys to identify k1 and k2 */
|
||||
|
|
|
@ -152,7 +152,7 @@ PROCESS_THREAD(node_process, ev, data)
|
|||
|
||||
/* Set node with ID == 1 as coordinator, handy in Cooja. */
|
||||
if(node_id == 1) {
|
||||
if(LLSEC802154_CONF_SECURITY_LEVEL) {
|
||||
if(LLSEC802154_ENABLED) {
|
||||
node_role = role_6dr_sec;
|
||||
} else {
|
||||
node_role = role_6dr;
|
||||
|
@ -165,7 +165,7 @@ PROCESS_THREAD(node_process, ev, data)
|
|||
node_role == role_6ln ? "6ln" : (node_role == role_6dr) ? "6dr" : "6dr-sec");
|
||||
|
||||
#if WITH_TSCH
|
||||
tsch_set_pan_secured(LLSEC802154_CONF_SECURITY_LEVEL && (node_role == role_6dr_sec));
|
||||
tsch_set_pan_secured(LLSEC802154_ENABLED && (node_role == role_6dr_sec));
|
||||
#endif /* WITH_TSCH */
|
||||
is_coordinator = node_role > role_6ln;
|
||||
|
||||
|
|
|
@ -37,4 +37,4 @@
|
|||
* Konrad Krentz <konrad.krentz@gmail.com>
|
||||
*/
|
||||
|
||||
#define LLSEC802154_CONF_SECURITY_LEVEL 6
|
||||
#define LLSEC802154_CONF_ENABLED 1
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SEC_LVL 6
|
||||
#define MIC_LEN LLSEC802154_MIC_LEN(6)
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Test vector C.2.1.2 from IEEE 802.15.4-2006 */
|
||||
static void
|
||||
|
@ -70,8 +73,8 @@ test_sec_lvl_6()
|
|||
/* Frame Counter */
|
||||
0x05 , 0x00 , 0x00 , 0x00 ,
|
||||
0x01 , 0xCE };
|
||||
uint8_t oracle[LLSEC802154_MIC_LENGTH] = { 0x4F , 0xDE , 0x52 , 0x90 ,
|
||||
0x61 , 0xF9 , 0xC6 , 0xF1 };
|
||||
uint8_t oracle[MIC_LEN] = { 0x4F , 0xDE , 0x52 , 0x90 ,
|
||||
0x61 , 0xF9 , 0xC6 , 0xF1 };
|
||||
uint8_t nonce[13];
|
||||
frame802154_frame_counter_t counter;
|
||||
|
||||
|
@ -84,7 +87,7 @@ test_sec_lvl_6()
|
|||
counter.u32 = 5;
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1, counter.u16[0]);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3, counter.u16[1]);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, LLSEC802154_SECURITY_LEVEL);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, SEC_LVL);
|
||||
packetbuf_hdrreduce(29);
|
||||
|
||||
CCM_STAR.set_key(key);
|
||||
|
@ -92,10 +95,10 @@ test_sec_lvl_6()
|
|||
CCM_STAR.aead(nonce,
|
||||
packetbuf_dataptr(), packetbuf_datalen(),
|
||||
packetbuf_hdrptr(), packetbuf_hdrlen(),
|
||||
((uint8_t *) packetbuf_hdrptr()) + 30, LLSEC802154_MIC_LENGTH,
|
||||
((uint8_t *) packetbuf_hdrptr()) + 30, MIC_LEN,
|
||||
1);
|
||||
|
||||
if(memcmp(((uint8_t *) packetbuf_hdrptr()) + 30, oracle, LLSEC802154_MIC_LENGTH) == 0) {
|
||||
if(memcmp(((uint8_t *) packetbuf_hdrptr()) + 30, oracle, MIC_LEN) == 0) {
|
||||
printf("Success\n");
|
||||
} else {
|
||||
printf("Failure\n");
|
||||
|
@ -115,7 +118,7 @@ test_sec_lvl_6()
|
|||
CCM_STAR.aead(nonce,
|
||||
packetbuf_dataptr(), packetbuf_datalen(),
|
||||
packetbuf_hdrptr(), packetbuf_hdrlen(),
|
||||
((uint8_t *) packetbuf_hdrptr()) + 30, LLSEC802154_MIC_LENGTH,
|
||||
((uint8_t *) packetbuf_hdrptr()) + 30, MIC_LEN,
|
||||
0);
|
||||
if(((uint8_t *) packetbuf_hdrptr())[29] == 0xCE) {
|
||||
printf("Success\n");
|
||||
|
|
|
@ -37,4 +37,4 @@
|
|||
* Konrad Krentz <konrad.krentz@gmail.com>
|
||||
*/
|
||||
|
||||
#define LLSEC802154_CONF_SECURITY_LEVEL 2
|
||||
#define LLSEC802154_CONF_ENABLED 1
|
||||
|
|
|
@ -48,6 +48,9 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SEC_LVL 2
|
||||
#define MIC_LEN LLSEC802154_MIC_LEN(2)
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Test vector C.1 from FIPS Pub 197 */
|
||||
static void
|
||||
|
@ -97,10 +100,10 @@ test_sec_lvl_2()
|
|||
0x05 , 0x00 , 0x00 , 0x00 ,
|
||||
/* Payload */
|
||||
0x55 , 0xCF , 0x00 , 0x00 , 0x51 , 0x52 , 0x53 , 0x54 };
|
||||
uint8_t oracle[LLSEC802154_MIC_LENGTH] = { 0x22 , 0x3B , 0xC1 , 0xEC ,
|
||||
0x84 , 0x1A , 0xB5 , 0x53 };
|
||||
uint8_t oracle[MIC_LEN] = { 0x22 , 0x3B , 0xC1 , 0xEC ,
|
||||
0x84 , 0x1A , 0xB5 , 0x53 };
|
||||
frame802154_frame_counter_t counter;
|
||||
uint8_t mic[LLSEC802154_MIC_LENGTH];
|
||||
uint8_t mic[MIC_LEN];
|
||||
uint8_t nonce[13];
|
||||
|
||||
printf("Testing verification ... ");
|
||||
|
@ -112,7 +115,7 @@ test_sec_lvl_2()
|
|||
counter.u32 = 5;
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1, counter.u16[0]);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3, counter.u16[1]);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, LLSEC802154_SECURITY_LEVEL);
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, SEC_LVL);
|
||||
packetbuf_hdrreduce(18);
|
||||
|
||||
CCM_STAR.set_key(key);
|
||||
|
@ -120,10 +123,10 @@ test_sec_lvl_2()
|
|||
CCM_STAR.aead(nonce,
|
||||
NULL, 0,
|
||||
packetbuf_hdrptr(), packetbuf_totlen(),
|
||||
((uint8_t *) packetbuf_dataptr()) + packetbuf_datalen(), LLSEC802154_MIC_LENGTH,
|
||||
((uint8_t *) packetbuf_dataptr()) + packetbuf_datalen(), MIC_LEN,
|
||||
1);
|
||||
|
||||
if(memcmp(((uint8_t *) packetbuf_dataptr()) + packetbuf_datalen(), oracle, LLSEC802154_MIC_LENGTH) == 0) {
|
||||
if(memcmp(((uint8_t *) packetbuf_dataptr()) + packetbuf_datalen(), oracle, MIC_LEN) == 0) {
|
||||
printf("Success\n");
|
||||
} else {
|
||||
printf("Failure\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue