From 0579e304e4afebe6203582d1e1f8578a0eed211d Mon Sep 17 00:00:00 2001 From: kkrentz Date: Thu, 9 Oct 2014 02:34:51 -0700 Subject: [PATCH] llsec: Renamed ccm to ccm_star & Renamed llsec regression test --- core/net/llsec/{ccm.c => ccm-star.c} | 10 +++---- core/net/llsec/{ccm.h => ccm-star.h} | 26 +++++++++---------- core/net/llsec/noncoresec/noncoresec.c | 10 +++---- .../encryption/Makefile | 0 .../encryption/project-conf.h | 0 .../encryption/tests.c | 14 +++++----- .../verification/Makefile | 0 .../verification/project-conf.h | 0 .../verification/tests.c | 10 +++---- .../01-ccm-star.csc} | 6 ++--- .../{18-llsec => 19-llsec}/Makefile | 0 11 files changed, 38 insertions(+), 38 deletions(-) rename core/net/llsec/{ccm.c => ccm-star.c} (95%) rename core/net/llsec/{ccm.h => ccm-star.h} (84%) rename examples/llsec/{ccm-tests => ccm-star-tests}/encryption/Makefile (100%) rename examples/llsec/{ccm-tests => ccm-star-tests}/encryption/project-conf.h (100%) rename examples/llsec/{ccm-tests => ccm-star-tests}/encryption/tests.c (92%) rename examples/llsec/{ccm-tests => ccm-star-tests}/verification/Makefile (100%) rename examples/llsec/{ccm-tests => ccm-star-tests}/verification/project-conf.h (100%) rename examples/llsec/{ccm-tests => ccm-star-tests}/verification/tests.c (94%) rename regression-tests/{18-llsec/01-ccm-tests.csc => 19-llsec/01-ccm-star.csc} (96%) rename regression-tests/{18-llsec => 19-llsec}/Makefile (100%) diff --git a/core/net/llsec/ccm.c b/core/net/llsec/ccm-star.c similarity index 95% rename from core/net/llsec/ccm.c rename to core/net/llsec/ccm-star.c index afae5ed25..42e220761 100644 --- a/core/net/llsec/ccm.c +++ b/core/net/llsec/ccm-star.c @@ -42,7 +42,7 @@ * Konrad Krentz */ -#include "net/llsec/ccm.h" +#include "net/llsec/ccm-star.h" #include "net/llsec/llsec802154.h" #include "net/packetbuf.h" #include "lib/aes-128.h" @@ -80,7 +80,7 @@ ctr_step(const uint8_t *extended_source_address, uint8_t a[AES_128_BLOCK_SIZE]; uint8_t i; - set_nonce(a, CCM_ENCRYPTION_FLAGS, extended_source_address, counter); + set_nonce(a, CCM_STAR_ENCRYPTION_FLAGS, extended_source_address, counter); AES_128.encrypt(a); for(i = 0; (pos + i < m_len) && (i < AES_128_BLOCK_SIZE); i++) { @@ -112,13 +112,13 @@ mic(const uint8_t *extended_source_address, m_len = 0; } set_nonce(x, - CCM_AUTH_FLAGS(a_len, mic_len), + CCM_STAR_AUTH_FLAGS(a_len, mic_len), extended_source_address, m_len); #else /* LLSEC802154_USES_ENCRYPTION */ a_len = packetbuf_totlen(); set_nonce(x, - CCM_AUTH_FLAGS(a_len, mic_len), + CCM_STAR_AUTH_FLAGS(a_len, mic_len), extended_source_address, 0); #endif /* LLSEC802154_USES_ENCRYPTION */ @@ -181,7 +181,7 @@ ctr(const uint8_t *extended_source_address) } } /*---------------------------------------------------------------------------*/ -const struct ccm_driver ccm_driver = { +const struct ccm_star_driver ccm_star_driver = { mic, ctr }; diff --git a/core/net/llsec/ccm.h b/core/net/llsec/ccm-star.h similarity index 84% rename from core/net/llsec/ccm.h rename to core/net/llsec/ccm-star.h index cd4eca8f1..fd413c33e 100644 --- a/core/net/llsec/ccm.h +++ b/core/net/llsec/ccm-star.h @@ -42,26 +42,26 @@ * Konrad Krentz */ -#ifndef CCM_H_ -#define CCM_H_ +#ifndef CCM_STAR_H_ +#define CCM_STAR_H_ #include "contiki.h" #include "net/mac/frame802154.h" /* see RFC 3610 */ -#define CCM_AUTH_FLAGS(Adata, M) ((Adata ? (1 << 6) : 0) | (((M - 2) >> 1) << 3) | 1) -#define CCM_ENCRYPTION_FLAGS 1 +#define CCM_STAR_AUTH_FLAGS(Adata, M) ((Adata ? (1 << 6) : 0) | (((M - 2) >> 1) << 3) | 1) +#define CCM_STAR_ENCRYPTION_FLAGS 1 -#ifdef CCM_CONF -#define CCM CCM_CONF -#else /* CCM_CONF */ -#define CCM ccm_driver -#endif /* CCM_CONF */ +#ifdef CCM_STAR_CONF +#define CCM_STAR CCM_STAR_CONF +#else /* CCM_STAR_CONF */ +#define CCM_STAR ccm_star_driver +#endif /* CCM_STAR_CONF */ /** - * Structure of CCM drivers. + * Structure of CCM* drivers. */ -struct ccm_driver { +struct ccm_star_driver { /** * \brief Generates a MIC over the frame in the packetbuf. @@ -78,8 +78,8 @@ struct ccm_driver { void (* ctr)(const uint8_t *extended_source_address); }; -extern const struct ccm_driver CCM; +extern const struct ccm_star_driver CCM_STAR; -#endif /* CCM_H_ */ +#endif /* CCM_STAR_H_ */ /** @} */ diff --git a/core/net/llsec/noncoresec/noncoresec.c b/core/net/llsec/noncoresec/noncoresec.c index 1d0015645..853628e5c 100644 --- a/core/net/llsec/noncoresec/noncoresec.c +++ b/core/net/llsec/noncoresec/noncoresec.c @@ -45,7 +45,7 @@ #include "net/llsec/noncoresec/noncoresec.h" #include "net/llsec/anti-replay.h" #include "net/llsec/llsec802154.h" -#include "net/llsec/ccm.h" +#include "net/llsec/ccm-star.h" #include "net/mac/frame802154.h" #include "net/netstack.h" #include "net/packetbuf.h" @@ -116,9 +116,9 @@ on_frame_created(void) dataptr = packetbuf_dataptr(); data_len = packetbuf_datalen(); - CCM.mic(get_extended_address(&linkaddr_node_addr), dataptr + data_len, LLSEC802154_MIC_LENGTH); + CCM_STAR.mic(get_extended_address(&linkaddr_node_addr), dataptr + data_len, LLSEC802154_MIC_LENGTH); #if WITH_ENCRYPTION - CCM.ctr(get_extended_address(&linkaddr_node_addr)); + CCM_STAR.ctr(get_extended_address(&linkaddr_node_addr)); #endif /* WITH_ENCRYPTION */ packetbuf_set_datalen(data_len + LLSEC802154_MIC_LENGTH); @@ -146,9 +146,9 @@ input(void) packetbuf_set_datalen(packetbuf_datalen() - LLSEC802154_MIC_LENGTH); #if WITH_ENCRYPTION - CCM.ctr(get_extended_address(sender)); + CCM_STAR.ctr(get_extended_address(sender)); #endif /* WITH_ENCRYPTION */ - CCM.mic(get_extended_address(sender), generated_mic, LLSEC802154_MIC_LENGTH); + CCM_STAR.mic(get_extended_address(sender), generated_mic, LLSEC802154_MIC_LENGTH); received_mic = ((uint8_t *) packetbuf_dataptr()) + packetbuf_datalen(); if(memcmp(generated_mic, received_mic, LLSEC802154_MIC_LENGTH) != 0) { diff --git a/examples/llsec/ccm-tests/encryption/Makefile b/examples/llsec/ccm-star-tests/encryption/Makefile similarity index 100% rename from examples/llsec/ccm-tests/encryption/Makefile rename to examples/llsec/ccm-star-tests/encryption/Makefile diff --git a/examples/llsec/ccm-tests/encryption/project-conf.h b/examples/llsec/ccm-star-tests/encryption/project-conf.h similarity index 100% rename from examples/llsec/ccm-tests/encryption/project-conf.h rename to examples/llsec/ccm-star-tests/encryption/project-conf.h diff --git a/examples/llsec/ccm-tests/encryption/tests.c b/examples/llsec/ccm-star-tests/encryption/tests.c similarity index 92% rename from examples/llsec/ccm-tests/encryption/tests.c rename to examples/llsec/ccm-star-tests/encryption/tests.c index 6c9ca295f..99999f819 100644 --- a/examples/llsec/ccm-tests/encryption/tests.c +++ b/examples/llsec/ccm-star-tests/encryption/tests.c @@ -41,7 +41,7 @@ #include "net/packetbuf.h" #include "net/netstack.h" #include "net/llsec/llsec802154.h" -#include "net/llsec/ccm.h" +#include "net/llsec/ccm-star.h" #include "net/mac/frame802154.h" #include "lib/aes-128.h" #include @@ -87,7 +87,7 @@ test_sec_lvl_6() packetbuf_hdrreduce(29); AES_128.set_key(key); - CCM.mic(extended_source_address, mic, LLSEC802154_MIC_LENGTH); + CCM_STAR.mic(extended_source_address, mic, LLSEC802154_MIC_LENGTH); if(memcmp(mic, oracle, LLSEC802154_MIC_LENGTH) == 0) { printf("Success\n"); @@ -97,7 +97,7 @@ test_sec_lvl_6() printf("Testing encryption ... "); - CCM.ctr(extended_source_address); + CCM_STAR.ctr(extended_source_address); if(((uint8_t *) packetbuf_hdrptr())[29] == 0xD8) { printf("Success\n"); } else { @@ -105,7 +105,7 @@ test_sec_lvl_6() } printf("Testing decryption ... "); - CCM.ctr(extended_source_address); + CCM_STAR.ctr(extended_source_address); if(((uint8_t *) packetbuf_hdrptr())[29] == 0xCE) { printf("Success\n"); } else { @@ -113,10 +113,10 @@ test_sec_lvl_6() } } /*---------------------------------------------------------------------------*/ -PROCESS(ccm_encryption_tests_process, "CCM* encryption tests process"); -AUTOSTART_PROCESSES(&ccm_encryption_tests_process); +PROCESS(ccm_star_tests_process, "CCM* tests process"); +AUTOSTART_PROCESSES(&ccm_star_tests_process); /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(ccm_encryption_tests_process, ev, data) +PROCESS_THREAD(ccm_star_tests_process, ev, data) { PROCESS_BEGIN(); diff --git a/examples/llsec/ccm-tests/verification/Makefile b/examples/llsec/ccm-star-tests/verification/Makefile similarity index 100% rename from examples/llsec/ccm-tests/verification/Makefile rename to examples/llsec/ccm-star-tests/verification/Makefile diff --git a/examples/llsec/ccm-tests/verification/project-conf.h b/examples/llsec/ccm-star-tests/verification/project-conf.h similarity index 100% rename from examples/llsec/ccm-tests/verification/project-conf.h rename to examples/llsec/ccm-star-tests/verification/project-conf.h diff --git a/examples/llsec/ccm-tests/verification/tests.c b/examples/llsec/ccm-star-tests/verification/tests.c similarity index 94% rename from examples/llsec/ccm-tests/verification/tests.c rename to examples/llsec/ccm-star-tests/verification/tests.c index 2c9d6dbc9..86d5952fc 100644 --- a/examples/llsec/ccm-tests/verification/tests.c +++ b/examples/llsec/ccm-star-tests/verification/tests.c @@ -41,7 +41,7 @@ #include "net/packetbuf.h" #include "net/netstack.h" #include "net/llsec/llsec802154.h" -#include "net/llsec/ccm.h" +#include "net/llsec/ccm-star.h" #include "net/mac/frame802154.h" #include "lib/aes-128.h" #include @@ -113,7 +113,7 @@ test_sec_lvl_2() packetbuf_hdrreduce(18); AES_128.set_key(key); - CCM.mic(extended_source_address, mic, LLSEC802154_MIC_LENGTH); + CCM_STAR.mic(extended_source_address, mic, LLSEC802154_MIC_LENGTH); if(memcmp(mic, oracle, LLSEC802154_MIC_LENGTH) == 0) { printf("Success\n"); @@ -122,10 +122,10 @@ test_sec_lvl_2() } } /*---------------------------------------------------------------------------*/ -PROCESS(ccm_verification_tests_process, "CCM* verification tests process"); -AUTOSTART_PROCESSES(&ccm_verification_tests_process); +PROCESS(ccm_star_tests_process, "CCM* tests process"); +AUTOSTART_PROCESSES(&ccm_star_tests_process); /*---------------------------------------------------------------------------*/ -PROCESS_THREAD(ccm_verification_tests_process, ev, data) +PROCESS_THREAD(ccm_star_tests_process, ev, data) { PROCESS_BEGIN(); diff --git a/regression-tests/18-llsec/01-ccm-tests.csc b/regression-tests/19-llsec/01-ccm-star.csc similarity index 96% rename from regression-tests/18-llsec/01-ccm-tests.csc rename to regression-tests/19-llsec/01-ccm-star.csc index 0d0d8343a..75e25642b 100644 --- a/regression-tests/18-llsec/01-ccm-tests.csc +++ b/regression-tests/19-llsec/01-ccm-star.csc @@ -24,7 +24,7 @@ org.contikios.cooja.contikimote.ContikiMoteType mtype139 Verification - [CONTIKI_DIR]/examples/llsec/ccm-tests/verification/tests.c + [CONTIKI_DIR]/examples/llsec/ccm-star-tests/verification/tests.c make tests.cooja TARGET=cooja org.contikios.cooja.interfaces.Position org.contikios.cooja.interfaces.Battery @@ -49,7 +49,7 @@ org.contikios.cooja.contikimote.ContikiMoteType mtype792 Encryption - [CONTIKI_DIR]/examples/llsec/ccm-tests/encryption/tests.c + [CONTIKI_DIR]/examples/llsec/ccm-star-tests/encryption/tests.c make tests.cooja TARGET=cooja org.contikios.cooja.interfaces.Position org.contikios.cooja.interfaces.Battery @@ -153,7 +153,7 @@ org.contikios.cooja.plugins.Notes - A simple test script that runs the tests in examples/llsec/ccm-tests/ + A simple test script that runs the tests in examples/llsec/ccm-star-tests/ true 1240 diff --git a/regression-tests/18-llsec/Makefile b/regression-tests/19-llsec/Makefile similarity index 100% rename from regression-tests/18-llsec/Makefile rename to regression-tests/19-llsec/Makefile