53 set_nonce(uint8_t *nonce,
55 const uint8_t *extended_source_address,
62 memcpy(nonce + 1, extended_source_address, 8);
63 nonce[9] = packetbuf_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3) >> 8;
64 nonce[10] = packetbuf_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3) & 0xff;
65 nonce[11] = packetbuf_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1) >> 8;
66 nonce[12] = packetbuf_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1) & 0xff;
67 nonce[13] = packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL);
74 ctr_step(
const uint8_t *extended_source_address,
76 uint8_t *m_and_result,
80 uint8_t a[AES_128_BLOCK_SIZE];
83 set_nonce(a, CCM_STAR_ENCRYPTION_FLAGS, extended_source_address, counter);
86 for(i = 0; (pos + i < m_len) && (i < AES_128_BLOCK_SIZE); i++) {
87 m_and_result[pos + i] ^= a[i];
92 mic(
const uint8_t *extended_source_address,
96 uint8_t x[AES_128_BLOCK_SIZE];
101 #if LLSEC802154_USES_ENCRYPTION
102 uint8_t shall_encrypt;
106 shall_encrypt = packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL) & (1 << 2);
115 CCM_STAR_AUTH_FLAGS(a_len, mic_len),
116 extended_source_address,
121 CCM_STAR_AUTH_FLAGS(a_len, mic_len),
122 extended_source_address,
130 for(i = 2; (i - 2 < a_len) && (i < AES_128_BLOCK_SIZE); i++) {
138 for(i = 0; (pos + i < a_len) && (i < AES_128_BLOCK_SIZE); i++) {
141 pos += AES_128_BLOCK_SIZE;
146 #if LLSEC802154_USES_ENCRYPTION
151 for(i = 0; (pos + i < m_len) && (i < AES_128_BLOCK_SIZE); i++) {
154 pos += AES_128_BLOCK_SIZE;
160 ctr_step(extended_source_address, 0, x, AES_128_BLOCK_SIZE, 0);
162 memcpy(result, x, mic_len);
166 ctr(
const uint8_t *extended_source_address)
179 ctr_step(extended_source_address, pos, m, m_len, counter++);
180 pos += AES_128_BLOCK_SIZE;
void(* ctr)(const uint8_t *extended_source_address)
XORs the frame in the packetbuf with the key stream.
Header file for the Rime buffer (packetbuf) management
Structure of CCM* drivers.
uint8_t packetbuf_hdrlen(void)
Get the length of the header in the packetbuf.
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
Common functionality of 802.15.4-compliant llsec_drivers.
void(* mic)(const uint8_t *extended_source_address, uint8_t *result, uint8_t mic_len)
Generates a MIC over the frame in the packetbuf.
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.