AES256 GCM Output incorrect on STM32WB55
Good afternoon,
I am trying to encrypt some data using the AES peripheral and compare the results to the same operation in python and .NET.
The cipher text output from the operation on the STM32 is different than that of the other two languages.
The code I am testing is
/**
* @brief AES1 Initialization Function
* @PAram None
* @retval None
*/
static void MX_AES1_Init(void)
{
/* USER CODE BEGIN AES1_Init 0 */
uint8_t key[32] = {0};
uint8_t iv[12] = {0};
/* USER CODE END AES1_Init 0 */
/* USER CODE BEGIN AES1_Init 1 */
/* USER CODE END AES1_Init 1 */
hcryp1.Instance = AES1;
hcryp1.Init.DataType = CRYP_DATATYPE_8B;
hcryp1.Init.KeySize = CRYP_KEYSIZE_256B;
hcryp1.Init.pKey = (uint32_t *)key;
hcryp1.Init.pInitVect = (uint32_t *)iv;
hcryp1.Init.Algorithm = CRYP_AES_GCM_GMAC;
hcryp1.Init.Header = (uint32_t *)HeaderAES1;
hcryp1.Init.HeaderSize = 1;
hcryp1.Init.DataWidthUnit = CRYP_DATAWIDTHUNIT_BYTE;
hcryp1.Init.KeyIVConfigSkip = CRYP_KEYIVCONFIG_ONCE;
if (HAL_CRYP_Init(&hcryp1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN AES1_Init 2 */
uint8_t plainText[12] = {72,101,108,108,111,32,87,111,114,108,100,49};
uint8_t cipherText[50] = {0};
HAL_StatusTypeDef status = HAL_CRYP_Encrypt(&hcryp1, (uint32_t*)plainText, 12, (uint32_t*)cipherText, HAL_MAX_DELAY);
if (status != HAL_OK){
}
/* USER CODE END AES1_Init 2 */
}
The output cipher text is

In comparison, the output from the .NET operation is

and python is

What have I missed in using the AES peripheral on the device?
Thank you in advance
