fix interfaccia
This commit is contained in:
@@ -11,6 +11,17 @@
|
||||
* + CRYP IRQ handler management
|
||||
* + Peripheral State functions
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
@verbatim
|
||||
==============================================================================
|
||||
##### How to use this driver #####
|
||||
@@ -283,17 +294,6 @@
|
||||
|
||||
@endverbatim
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
@@ -1209,7 +1209,7 @@ HAL_StatusTypeDef HAL_CRYP_Encrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, u
|
||||
|
||||
/* Check input buffer size */
|
||||
assert_param(IS_CRYP_BUFFERSIZE(algo_assert, hcryp->Init.DataWidthUnit, Size));
|
||||
#endif
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
if (hcryp->State == HAL_CRYP_STATE_READY)
|
||||
{
|
||||
@@ -1309,7 +1309,7 @@ HAL_StatusTypeDef HAL_CRYP_Decrypt(CRYP_HandleTypeDef *hcryp, uint32_t *Input, u
|
||||
|
||||
/* Check input buffer size */
|
||||
assert_param(IS_CRYP_BUFFERSIZE(algo_assert, hcryp->Init.DataWidthUnit, Size));
|
||||
#endif
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
if (hcryp->State == HAL_CRYP_STATE_READY)
|
||||
{
|
||||
@@ -1408,7 +1408,7 @@ HAL_StatusTypeDef HAL_CRYP_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input
|
||||
|
||||
/* Check input buffer size */
|
||||
assert_param(IS_CRYP_BUFFERSIZE(algo_assert, hcryp->Init.DataWidthUnit, Size));
|
||||
#endif
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
if (hcryp->State == HAL_CRYP_STATE_READY)
|
||||
{
|
||||
@@ -1518,7 +1518,7 @@ HAL_StatusTypeDef HAL_CRYP_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint32_t *Input
|
||||
|
||||
/* Check input buffer size */
|
||||
assert_param(IS_CRYP_BUFFERSIZE(algo_assert, hcryp->Init.DataWidthUnit, Size));
|
||||
#endif
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
if (hcryp->State == HAL_CRYP_STATE_READY)
|
||||
{
|
||||
@@ -1628,7 +1628,7 @@ HAL_StatusTypeDef HAL_CRYP_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Inpu
|
||||
|
||||
/* Check input buffer size */
|
||||
assert_param(IS_CRYP_BUFFERSIZE(algo_assert, hcryp->Init.DataWidthUnit, Size));
|
||||
#endif
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
if (hcryp->State == HAL_CRYP_STATE_READY)
|
||||
{
|
||||
@@ -1754,7 +1754,7 @@ HAL_StatusTypeDef HAL_CRYP_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint32_t *Inpu
|
||||
|
||||
/* Check input buffer size */
|
||||
assert_param(IS_CRYP_BUFFERSIZE(algo_assert, hcryp->Init.DataWidthUnit, Size));
|
||||
#endif
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
if (hcryp->State == HAL_CRYP_STATE_READY)
|
||||
{
|
||||
@@ -3939,6 +3939,11 @@ static HAL_StatusTypeDef CRYP_AESCCM_Process_IT(CRYP_HandleTypeDef *hcryp)
|
||||
uint32_t npblb;
|
||||
uint32_t mode;
|
||||
uint32_t DoKeyIVConfig = 1U; /* By default, carry out peripheral Key and IV configuration */
|
||||
uint32_t headersize_in_bytes;
|
||||
uint32_t tmp;
|
||||
uint32_t mask[12] = {0x0U, 0xFF000000U, 0xFFFF0000U, 0xFFFFFF00U, /* 32-bit data type */
|
||||
0x0U, 0x0000FF00U, 0x0000FFFFU, 0xFF00FFFFU, /* 16-bit data type */
|
||||
0x0U, 0x000000FFU, 0x0000FFFFU, 0x00FFFFFFU}; /* 8-bit data type */
|
||||
|
||||
#if (USE_HAL_CRYP_SUSPEND_RESUME == 1U)
|
||||
if ((hcryp->Phase == CRYP_PHASE_HEADER_SUSPENDED) || (hcryp->Phase == CRYP_PHASE_PAYLOAD_SUSPENDED))
|
||||
@@ -4028,7 +4033,16 @@ static HAL_StatusTypeDef CRYP_AESCCM_Process_IT(CRYP_HandleTypeDef *hcryp)
|
||||
/* Enable the CRYP peripheral */
|
||||
__HAL_CRYP_ENABLE(hcryp);
|
||||
|
||||
if (hcryp->Init.HeaderSize == 0U) /*header phase is skipped*/
|
||||
if (hcryp->Init.HeaderWidthUnit == CRYP_HEADERWIDTHUNIT_WORD)
|
||||
{
|
||||
headersize_in_bytes = hcryp->Init.HeaderSize * 4U;
|
||||
}
|
||||
else
|
||||
{
|
||||
headersize_in_bytes = hcryp->Init.HeaderSize;
|
||||
}
|
||||
|
||||
if (headersize_in_bytes == 0U) /* Header phase is skipped */
|
||||
{
|
||||
/* Set the phase */
|
||||
hcryp->Phase = CRYP_PHASE_PROCESS;
|
||||
@@ -4122,24 +4136,53 @@ static HAL_StatusTypeDef CRYP_AESCCM_Process_IT(CRYP_HandleTypeDef *hcryp)
|
||||
#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
|
||||
}
|
||||
}
|
||||
else if ((hcryp->Init.HeaderSize) < 4U) /*HeaderSize < 4 */
|
||||
/* Enter header data */
|
||||
/* Check first whether header length is small enough to enter the full header in one shot */
|
||||
else if (headersize_in_bytes <= 16U)
|
||||
{
|
||||
/* Last block optionally pad the data with zeros*/
|
||||
for (loopcounter = 0U; loopcounter < (hcryp->Init.HeaderSize % 4U); loopcounter++)
|
||||
for (loopcounter = 0U; (loopcounter < (headersize_in_bytes / 4U)); loopcounter++)
|
||||
{
|
||||
hcryp->Instance->DINR = *(uint32_t *)(hcryp->Init.Header + hcryp->CrypHeaderCount);
|
||||
hcryp->CrypHeaderCount++ ;
|
||||
}
|
||||
/* If the header size is a multiple of words */
|
||||
if ((headersize_in_bytes % 4U) == 0U)
|
||||
{
|
||||
/* Pad the data with zeros to have a complete block */
|
||||
while (loopcounter < 4U)
|
||||
{
|
||||
hcryp->Instance->DINR = 0x0U;
|
||||
loopcounter++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Enter last bytes, padded with zeros */
|
||||
tmp = *(uint32_t *)(hcryp->Init.Header + hcryp->CrypHeaderCount);
|
||||
tmp &= mask[(hcryp->Init.DataType * 2U) + (headersize_in_bytes % 4U)];
|
||||
hcryp->Instance->DINR = tmp;
|
||||
hcryp->CrypHeaderCount++;
|
||||
loopcounter++;
|
||||
/* Pad the data with zeros to have a complete block */
|
||||
while (loopcounter < 4U)
|
||||
{
|
||||
/* pad the data with zeros to have a complete block */
|
||||
hcryp->Instance->DINR = 0x0U;
|
||||
loopcounter++;
|
||||
}
|
||||
}
|
||||
/* Call Input transfer complete callback */
|
||||
#if (USE_HAL_CRYP_REGISTER_CALLBACKS == 1U)
|
||||
/*Call registered Input complete callback*/
|
||||
hcryp->InCpltCallback(hcryp);
|
||||
#else
|
||||
/*Call legacy weak Input complete callback*/
|
||||
HAL_CRYP_InCpltCallback(hcryp);
|
||||
#endif /* USE_HAL_CRYP_REGISTER_CALLBACKS */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write the input block in the IN FIFO */
|
||||
/* Write the first input header block in the Input FIFO,
|
||||
the following header data will be fed after interrupt occurrence */
|
||||
hcryp->Instance->DINR = *(uint32_t *)(hcryp->Init.Header + hcryp->CrypHeaderCount);
|
||||
hcryp->CrypHeaderCount++;
|
||||
hcryp->Instance->DINR = *(uint32_t *)(hcryp->Init.Header + hcryp->CrypHeaderCount);
|
||||
@@ -4148,9 +4191,8 @@ static HAL_StatusTypeDef CRYP_AESCCM_Process_IT(CRYP_HandleTypeDef *hcryp)
|
||||
hcryp->CrypHeaderCount++;
|
||||
hcryp->Instance->DINR = *(uint32_t *)(hcryp->Init.Header + hcryp->CrypHeaderCount);
|
||||
hcryp->CrypHeaderCount++;
|
||||
}
|
||||
|
||||
} /* end of if (DoKeyIVConfig == 1U) */
|
||||
}/* if (hcryp->Init.HeaderSize == 0U) */ /* Header phase is skipped*/
|
||||
} /* end of if (dokeyivconfig == 1U) */
|
||||
else /* Key and IV have already been configured,
|
||||
header has already been processed;
|
||||
only process here message payload */
|
||||
@@ -5548,4 +5590,3 @@ static void CRYP_PhaseProcessingResume(CRYP_HandleTypeDef *hcryp)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
Reference in New Issue
Block a user