How to use cmox_aead_decrypt function with addData pointer = null and tag size = 0
Hi
My team developed Android app with following code to encrypt the message then send it to STM32WB55 device via BLE :
...
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey, "AES");
IvParameterSpec parameterSpec = new IvParameterSpec(iv);
Cipher cipher = Cipher.getInstance("AES/CCM/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, parameterSpec);
return cipher.doFinal(message);
This code has no tag/addData inputs.
First attempt:
I develop the following code to decrypt the encrypted message on STM32WB55 device with AddData/Tag variables filled 0 because I dont use them:
const uint8_t AddData[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const uint8_t Expected_Tag[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
cretval = cmox_aead_decrypt(CMOX_AES_CCM_DEC_ALGO, /* Use AES CBC algorithm */
blePkocEncryptedData, encryptedDataLen, /* Ciphertext to decrypt */
sizeof(Expected_Tag),
blePkocSharedKeyData, sizeof(blePkocSharedKeyData), /* AES key to use */
IV, sizeof(IV), /* Initialization vector */
AddData, sizeof(AddData),
blePkocDecryptedData, &computed_size); /* Data buffer to receive generated plaintext */
After executed this cmox_aead_decrypt() function, I got the result = CMOX_CIPHER_AUTH_FAIL.
Second attempt:
I develop the following code on STM32WB55 device with NULL to AddData/Tag variables because I dont use them:
cretval = cmox_aead_decrypt(CMOX_AES_CCM_DEC_ALGO, /* Use AES CBC algorithm */
blePkocEncryptedData, encryptedDataLen, /* Ciphertext to decrypt */
0,
blePkocSharedKeyData, sizeof(blePkocSharedKeyData), /* AES key to use */
IV, sizeof(IV), /* Initialization vector */
NULL, 0,
blePkocDecryptedData, &computed_size); /* Data buffer to receive generated plaintext */
After executed this cmox_aead_decrypt() function, I got the result = CMOX_CIPHER_ERR_BAD_PARAMETER.
How to use this function without tag/addData inputs ?
Thanks
Gregory Saint-Jean
