@@ -1349,13 +1349,15 @@ static void HASH_DMAError(DMA_HandleTypeDef *hdma)
1349
1349
static HAL_StatusTypeDef HASH_WriteData (HASH_HandleTypeDef * hhash , uint8_t * pInBuffer , uint32_t Size )
1350
1350
{
1351
1351
uint32_t buffercounter ;
1352
- __IO uint32_t inputaddr = (uint32_t ) pInBuffer ;
1353
1352
1354
1353
for (buffercounter = 0 ; buffercounter < Size ; buffercounter += 4 )
1355
1354
{
1356
1355
/* Write input data 4 bytes at a time */
1357
- HASH -> DIN = * (uint32_t * )inputaddr ;
1358
- inputaddr += 4 ;
1356
+ uint32_t data = (uint32_t ) * pInBuffer ++ ;
1357
+ data |= (uint32_t ) * pInBuffer ++ << 8 ;
1358
+ data |= (uint32_t ) * pInBuffer ++ << 16 ;
1359
+ data |= (uint32_t ) * pInBuffer ++ << 24 ;
1360
+ HASH -> DIN = data ;
1359
1361
1360
1362
/* If the suspension flag has been raised and if the processing is not about
1361
1363
to end, suspend processing */
@@ -1373,14 +1375,14 @@ static HAL_StatusTypeDef HASH_WriteData(HASH_HandleTypeDef *hhash, uint8_t *pInB
1373
1375
if ((hhash -> Phase == HAL_HASH_PHASE_PROCESS ) || (hhash -> Phase == HAL_HASH_PHASE_HMAC_STEP_2 ))
1374
1376
{
1375
1377
/* Save current reading and writing locations of Input and Output buffers */
1376
- hhash -> pHashInBuffPtr = ( uint8_t * ) inputaddr ;
1378
+ hhash -> pHashInBuffPtr = pInBuffer ;
1377
1379
/* Save the number of bytes that remain to be processed at this point */
1378
1380
hhash -> HashInCount = Size - (buffercounter + 4 );
1379
1381
}
1380
1382
else if ((hhash -> Phase == HAL_HASH_PHASE_HMAC_STEP_1 ) || (hhash -> Phase == HAL_HASH_PHASE_HMAC_STEP_3 ))
1381
1383
{
1382
1384
/* Save current reading and writing locations of Input and Output buffers */
1383
- hhash -> pHashKeyBuffPtr = ( uint8_t * ) inputaddr ;
1385
+ hhash -> pHashKeyBuffPtr = pInBuffer ;
1384
1386
/* Save the number of bytes that remain to be processed at this point */
1385
1387
hhash -> HashKeyCount = Size - (buffercounter + 4 );
1386
1388
}
@@ -1686,15 +1688,21 @@ static uint32_t HASH_Write_Block_Data(HASH_HandleTypeDef *hhash)
1686
1688
(16 32-bit words, or 64 bytes are entered) */
1687
1689
for (buffercounter = 0 ; buffercounter < 64 ; buffercounter += 4 )
1688
1690
{
1689
- HASH -> DIN = * (uint32_t * )inputaddr ;
1690
- inputaddr += 4 ;
1691
+ uint32_t data = (uint32_t ) * (uint8_t * )inputaddr ++ ;
1692
+ data |= (uint32_t ) * (uint8_t * )inputaddr ++ << 8 ;
1693
+ data |= (uint32_t ) * (uint8_t * )inputaddr ++ << 16 ;
1694
+ data |= (uint32_t ) * (uint8_t * )inputaddr ++ << 24 ;
1695
+ HASH -> DIN = data ;
1691
1696
}
1692
1697
/* If this is the start of input data entering, an additional word
1693
1698
must be entered to start up the HASH processing */
1694
1699
if (hhash -> HashITCounter == 2 )
1695
1700
{
1696
- HASH -> DIN = * (uint32_t * )inputaddr ;
1697
- inputaddr += 4 ;
1701
+ uint32_t data = (uint32_t ) * (uint8_t * )inputaddr ++ ;
1702
+ data |= (uint32_t ) * (uint8_t * )inputaddr ++ << 8 ;
1703
+ data |= (uint32_t ) * (uint8_t * )inputaddr ++ << 16 ;
1704
+ data |= (uint32_t ) * (uint8_t * )inputaddr ++ << 24 ;
1705
+ HASH -> DIN = data ;
1698
1706
if (hhash -> HashInCount >= 68 )
1699
1707
{
1700
1708
/* There are still data waiting to be entered in the IP.
@@ -1733,8 +1741,11 @@ static uint32_t HASH_Write_Block_Data(HASH_HandleTypeDef *hhash)
1733
1741
/* Write the Input block in the Data IN register */
1734
1742
for (buffercounter = 0 ; buffercounter < (inputcounter + 3 )/4 ; buffercounter ++ )
1735
1743
{
1736
- HASH -> DIN = * (uint32_t * )inputaddr ;
1737
- inputaddr += 4 ;
1744
+ uint32_t data = (uint32_t ) * (uint8_t * )inputaddr ++ ;
1745
+ data |= (uint32_t ) * (uint8_t * )inputaddr ++ << 8 ;
1746
+ data |= (uint32_t ) * (uint8_t * )inputaddr ++ << 16 ;
1747
+ data |= (uint32_t ) * (uint8_t * )inputaddr ++ << 24 ;
1748
+ HASH -> DIN = data ;
1738
1749
}
1739
1750
/* Start the Digest calculation */
1740
1751
__HAL_HASH_START_DIGEST ();
0 commit comments