mesh: AES-CCM: Fix output MIC with additional data
General MIC fix for AAD lengths up to 14 bytes.
This case doesn't concern the mesh stack because it uses 16 bytes.
@@ -258,7 +258,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
}
}
- for (i = 0; i < aad_len; i++, j++) {
+ for (; i < aad_len; i++, j++) {
pmsg[i] = Xn[i] ^ aad[j];
}
@@ -422,7 +422,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
}
}
- for (i = 0; i < aad_len; i++, j++) {
+ for (; i < aad_len; i++, j++) {
pmsg[i] = Xn[i] ^ aad[j];
}
