CRYP_GCMCCM_SetHeaderPhase out bounds read in mask array #35
Labels
aes
Advanced Encryption Standard cryptographic core
bug
Something isn't working
cryp
Cryptographic processor
hal
HAL-LL driver-related issue or pull-request.
internal bug tracker
Issue confirmed and logged into the internal bug tracking system
There is an out of bounds read in CRYP_GCMCCM_SetHeaderPhase if any datatype other than CRYP_DATATYPE_32B is used.
https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/064b123f8fc187d468bb762cc150d198f873478d/Src/stm32f4xx_hal_cryp.c#L5732
The array mask is defined as
https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/064b123f8fc187d468bb762cc150d198f873478d/Src/stm32f4xx_hal_cryp.c#L5622-L5629
And the definition for the DataType field is:
https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/064b123f8fc187d468bb762cc150d198f873478d/Inc/stm32f4xx_hal_cryp.h#L49-L52
And the valid values for DataType:
https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/064b123f8fc187d468bb762cc150d198f873478d/Inc/stm32f4xx_hal_cryp.h#L271-L288
The code that causes the out of bounds read is only present if CRYP is defined so the defines that matter are:
https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/064b123f8fc187d468bb762cc150d198f873478d/Inc/stm32f4xx_hal_cryp.h#L275-L278
And finally the actual values from the lastet CMSIS
So hcryp->Init.DataType will either be:
0 (CRYP_DATATYPE_32B)
64 (CRYP_DATATYPE_16B)
128 (CRYP_DATATYPE_8B)
192 (CRYP_DATATYPE_1B)
So all values except CRYP_DATATYPE_32B will cause a read out of bounds in the mask array.
The text was updated successfully, but these errors were encountered: