This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

AES CCM encryption with Android decryption failing

I have encrypted 12 bytes on the nrf51 and sent this + 4 byte MIC across to an Android device.

However, when I try to decrypt on Android using a Cipher with "AES/CCM/NoPadding" transformation and "BC" provider, I get a BadPaddingException which states that the "mac check failed".

I am using the same 8 byte initialisation vector on both ends.

I have got this working with ECB, however, as documented, I cannot decrypt ECB on nrf51 which is what I would like to do - android device responding with encrypted string.

Has anyone got this successfully working? Is CCM (with nrf51 compatibility) supported in Android?

Also, we found that the java Cipher has a MAC/MIC size of 8 rather than 4 bytes like nrf51 is generating. Is there any way to change this? I believe this is causing the issue.

Related