HAL_HASH_PhaseTypeDef HASH_HandleTypeDef::Phase
HASH peripheral phase
DMA_HandleTypeDef* HASH_HandleTypeDef::hdmain
HASH In DMA handle parameters
HAL_LockTypeDef HASH_HandleTypeDef::Lock
HASH locking object
__IO HAL_HASH_StateTypeDef HASH_HandleTypeDef::State
HASH peripheral state
22.2 HASH Firmware driver API description
22.2.1 How to use this driver
The HASH HAL driver can be used as follows:
1. Initialize the HASH low level resources by implementing the HAL_HASH_MspInit():
a. Enable the HASH interface clock using __HAL_RCC_HASH_CLK_ENABLE()
b. In case of using processing APIs based on interrupts (e.g.
HAL_HMAC_SHA1_Start_IT())
Configure the HASH interrupt priority using HAL_NVIC_SetPriority()
Enable the HASH IRQ handler using HAL_NVIC_EnableIRQ()
In HASH IRQ handler, call HAL_HASH_IRQHandler()
c. In case of using DMA to control data transfer (e.g.
HAL_HMAC_SHA1_Start_DMA())
Enable the DMAx interface clock using __DMAx_CLK_ENABLE()
Configure and enable one DMA stream one for managing data transfer from
memory to peripheral (input stream). Managing data transfer from peripheral
to memory can be performed only using CPU
Associate the initialized DMA handle to the HASH DMA handle using
__HAL_LINKDMA()
Configure the priority and enable the NVIC for the transfer complete interrupt
on the DMA Stream using HAL_NVIC_SetPriority() and
HAL_NVIC_EnableIRQ()
2. Initialize the HASH HAL using HAL_HASH_Init(). This function configures mainly:
a. The data type: 1-bit, 8-bit, 16-bit and 32-bit.
b. For HMAC, the encryption key.
c. For HMAC, the key size used for encryption.
3. Three processing functions are available:
a. Polling mode: processing APIs are blocking functions i.e. they process the data
and wait till the digest computation is finished e.g. HAL_HASH_SHA1_Start()
b. Interrupt mode: encryption and decryption APIs are not blocking functions i.e.
they process the data under interrupt e.g. HAL_HASH_SHA1_Start_IT()
c. DMA mode: processing APIs are not blocking functions and the CPU is not used
for data transfer i.e. the data transfer is ensured by DMA e.g.
HAL_HASH_SHA1_Start_DMA()
4. When the processing function is called at first time after HAL_HASH_Init() the HASH
peripheral is initialized and processes the buffer in input. After that, the digest
computation is started. When processing multi-buffer use the accumulate function to
write the data in the peripheral without starting the digest computation. In last buffer
use the start function to input the last buffer ans start the digest computation.
a. e.g. HAL_HASH_SHA1_Accumulate() : write 1st data buffer in the peripheral
without starting the digest computation
b. write (n-1)th data buffer in the peripheral without starting the digest computation
c. HAL_HASH_SHA1_Start() : write (n)th data buffer in the peripheral and start the
digest computation