Hi,
I am working on CC26x2R1 BLE SoC. My use case is to decrypt the data with 128 bit. Key and IV length is 16 bytes and Input data is 24 bytes.
I am following these steps:
static uint8_t AES_Decrypt_Key(uint8_t const *inData, uint8_t *IV, uint8_t const *key,
uint8_t keylength, uint8_t *outData, uint8_t datalength)
{
if ((inData == NULL) || (IV == NULL) || (key == NULL) || (outData == NULL))
{
return INVALIDPARAMETER;
}
uint8_t ret_status = SUCCESS;
AESCBC_Handle aescbcHandle;
AESCBC_Params aescbcParams;
AESCBC_Operation operationOneStepDecrypt;
CryptoKey cryptoKey;
AESCBC_init();
AESCBC_Params_init(&aescbcParams);
// Open AESCCM_open
aescbcHandle = AESCBC_open(0, &aescbcParams);
if (!aescbcHandle)
{
return INVALIDPARAMETER;
}
// Initialize the key structure
CryptoKeyPlaintext_initKey(&cryptoKey, (uint8_t *) key, keylength);
/* Perform a single step decrypt operation of the cipher text */
AESCBC_Operation_init(&operationOneStepDecrypt);
operationOneStepDecrypt.key = &cryptoKey;
operationOneStepDecrypt.input = inData;
operationOneStepDecrypt.output = outData;
operationOneStepDecrypt.iv = IV;
operationOneStepDecrypt.inputLength = datalength;
operationOneStepDecrypt.ivInternallyGenerated = false;
uint8_t result = AESCBC_oneStepDecrypt(aescbcHandle, &operationOneStepDecrypt);
// uint8_t result = AESCBC_oneStepEncrypt(aescbcHandle, &operationOneStepDecrypt);
if (result != AESCBC_STATUS_SUCCESS)
{
ret_status = FAILURE;
}
AESCBC_close(aescbcHandle);
return ret_status;
}
I am passing these parameters but I am not getting correct data. Please suggest me If i am doing wrong?
For Example:
uint8_t EncryptedInputData[24] = {0x11,0x22,0x33,0x44,0x55,0x66,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11};
uint8_t DecryptedOutputData[16] = { 0 };
uint8_t key_128[16] = {0x11,0x22,0x33,0x44,0x55,0x66,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x11,0x11,0x11};
uint8_t IV_128[16] = {0x11,0x22,0x33,0x44,0x55,0x66,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x11,0x11,0x11};
AES_Decrypt_Key(EncryptedInputData, IV_128, key_128, sizeof(key_128), DecryptedOutputData, sizeof(DecryptedOutputData));
I have tried with online tools but Output data is not matched with this DecryptedOutputData.
Thanks in advance.