From 2ca7a1a79ff1c6e5c29064c3143df9043baf64df Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 19 Oct 2015 19:14:50 +0200 Subject: [PATCH] TSCH security: port to new ccm-star and llsec APIs --- core/net/mac/tsch/tsch-security.c | 28 ++-------------------------- core/net/mac/tsch/tsch.c | 2 +- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/core/net/mac/tsch/tsch-security.c b/core/net/mac/tsch/tsch-security.c index 936a55194..e7439c519 100644 --- a/core/net/mac/tsch/tsch-security.c +++ b/core/net/mac/tsch/tsch-security.c @@ -70,30 +70,6 @@ static aes_key keys[] = { }; #define N_KEYS (sizeof(keys) / sizeof(aes_key)) -/*---------------------------------------------------------------------------*/ -static void -aead(const uint8_t *nonce, - uint8_t *m, uint8_t m_len, - const uint8_t *a, uint8_t a_len, - uint8_t *result, uint8_t mic_len, - int forward) -{ - if(!forward) { - /* decrypt */ - CCM_STAR.ctr(m, m_len, nonce); - } - CCM_STAR.mic( - (const uint8_t *)m, m_len, - nonce, - a, a_len, - result, - mic_len); - - if(forward) { - /* encrypt */ - CCM_STAR.ctr(m, m_len, nonce); - } -} /*---------------------------------------------------------------------------*/ static void tsch_security_init_nonce(uint8_t *nonce, @@ -213,7 +189,7 @@ tsch_security_secure_frame(uint8_t *hdr, uint8_t *outbuf, CCM_STAR.set_key(keys[key_index - 1]); - aead(nonce, + CCM_STAR.aead(nonce, outbuf + a_len, m_len, outbuf, a_len, outbuf + hdrlen + datalen, mic_len, 1 @@ -271,7 +247,7 @@ tsch_security_parse_frame(const uint8_t *hdr, int hdrlen, int datalen, CCM_STAR.set_key(keys[key_index - 1]); - aead(nonce, + CCM_STAR.aead(nonce, (uint8_t *)hdr + a_len, m_len, (uint8_t *)hdr, a_len, generated_mic, mic_len, 0 diff --git a/core/net/mac/tsch/tsch.c b/core/net/mac/tsch/tsch.c index 50a375595..1a943bbf0 100644 --- a/core/net/mac/tsch/tsch.c +++ b/core/net/mac/tsch/tsch.c @@ -915,7 +915,7 @@ send_packet(mac_callback_t sent, void *ptr) packet_count_before = tsch_queue_packet_count(addr); - if((hdr_len = NETSTACK_FRAMER.create_and_secure()) < 0) { + if((hdr_len = NETSTACK_FRAMER.create()) < 0) { PRINTF("TSCH:! can't send packet due to framer error\n"); ret = MAC_TX_ERR; } else {