45 static tsReg128 current_key;
46 static int current_key_is_new = 1;
50 aead(
const uint8_t *nonce,
51 uint8_t *m, uint16_t m_len,
52 const uint8_t *a, uint16_t a_len,
53 uint8_t *result, uint8_t mic_len,
56 tsReg128 nonce_aligned;
57 memcpy(&nonce_aligned, nonce,
sizeof(nonce_aligned));
62 XCV_REG_AES_SET_MODE_CCM,
78 XCV_REG_AES_SET_MODE_CCM_D,
86 (uint8_t *)a + a_len + m_len,
92 memcpy(result, a + a_len + m_len, mic_len);
95 memcpy(result, a + a_len + m_len, mic_len);
101 current_key_is_new = 0;
105 set_key(
const uint8_t *key)
107 if(memcmp(¤t_key, key,
sizeof(current_key)) == 0) {
108 current_key_is_new = 0;
110 memcpy(¤t_key, key,
sizeof(current_key));
111 current_key_is_new = 1;
Structure of CCM* drivers.
void(* aead)(const uint8_t *nonce, uint8_t *m, uint16_t m_len, const uint8_t *a, uint16_t a_len, uint8_t *result, uint8_t mic_len, int forward)
Combines authentication and encryption.
void(* set_key)(const uint8_t *key)
Sets the key in use.