TSCH security: port to new ccm-star and llsec APIs

This commit is contained in:
Simon Duquennoy 2015-10-19 19:14:50 +02:00
parent 28e1cb38a2
commit 2ca7a1a79f
2 changed files with 3 additions and 27 deletions

View File

@ -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

View File

@ -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 {