I am trying to test the AES crypto module. Are there any examples available.
I am trying with the below code. It is returning with -1 error code.
CryptoCC32XX_Handle cryptoHandle;
CryptoCC32XX_EncryptParams AESparams;
uint8_t Plane_text[] = {0x4c,0x61,0x64,0x69,0x65,0x73,0x20,0x61,0x6e,0x64,0x20,0x47,0x65,0x6e,0x74,0x20};
uint32_t Plane_text_Len = 16;
uint8_t Encrypted_text[16];
uint32_t Encrypted_text_Len = 16;
uint8_t AESKey[] = {0x4c,0x61,0x64,0x69,0x65,0x73,0x20,0x61,0x6e,0x64,0x20,0x47,0x65,0x6e,0x74,0x20,0x4c,0x61,0x64,0x69,0x65,0x73,0x20,0x61,0x6e,0x64,0x20,0x47,0x65,0x6e,0x74,0x20};
// Initialize Crypto module
CryptoCC32XX_init();
cryptoHandle = CryptoCC32XX_open(Board_CRYPTO0, CryptoCC32XX_AES);
if (cryptoHandle == NULL)
{
return;
}
AESparams.aes.pKey = (uint8_t *)AESKey;
AESparams.aes.keySize = CryptoCC32XX_AES_KEY_SIZE_256BIT;
int32_t error = CryptoCC32XX_encrypt(cryptoHandle, CryptoCC32XX_AES_ECB, Plane_text, Plane_text_Len, Encrypted_text, &Encrypted_text_Len, &AESparams);
if(CryptoCC32XX_STATUS_SUCCESS != error)
{
consoleString("\n\rAES FAILED");
}
else
{
consoleString("\n\r Encrypted Data: 0x");
for(count=0;count<Encrypted_text_Len;count++)
{
consolePrintf("%02x ",*(Encrypted_text+count));
}
}