Hash processor (HASH)
RM0090
772/1731
DocID018909 Rev 11
Procedure where the data are loaded by software
The context can be saved only when no block is currently being processed. That is, you
must wait for DINIS = 1 (the last block has been processed and the input FIFO is empty) or
NBW
≠
0 (the FIFO is not full and no processing is ongoing).
•
Context saving:
Store the contents of the following registers into memory:
–
HASH_IMR
–
HASH_STR
–
HASH_CR
–
HASH_CSR0 to HASH_CSR50 on STM32F415/417xx, and HASH_CSR0 to
HASH_CSR53 on STM32F43xxx.
•
Context restoring:
The context can be restored when the high-priority task is complete. Please follow the
order of the sequence below.
a) Write the following registers with the values saved in memory: HASH_IMR,
HASH_STR and HASH_CR
b) Initialize the hash processor by setting the INIT bit in the HASH_CR register
c) Write the HASH_CSR0 to HASH_CSR50 (STM32F415/417xx), and HASH_CSR0
to HASH_CSR53 (STM32F43xxx) registers with the values saved in memory
You can now restart the processing from the point where it has been interrupted.
Procedure where the data are loaded by DMA
In this case it is not possible to predict if a DMA transfer is in progress or if the process is
ongoing. Thus, you must stop the DMA transfers, then wait until the HASH is ready in order
to interrupt the processing of a message.
•
Interrupting a processing:
–
Clear the DMAE bit to disable the DMA interface
–
Wait until the current DMA transfer is complete (wait for DMAES = 0 in the
HASH_SR register). Note that the block may or not have been totally transferred
to the HASH.
–
Disable the corresponding channel in the DMA controller
–
Wait until the hash processor is ready (no block is being processed), that is wait
for DINIS = 1
•
The context saving and context restoring phases are the same as above (see
Procedure where the data are loaded by software
).
Reconfigure the DMA controller so that it transfers the end of the message. You can now
restart the processing from the point where it was interrupted by setting the DMAE bit.
Note:
If context swapping does not involve HMAC operations, the HASH_CSR38 to
HASH_CSR50 (
STM32F415/417xx)
and HASH_CSR38 to HASH_CSR53 (
STM32F43xxx
)
registers do not have to be saved and restored.
If context swapping occurs between two blocks (the last block was completely processed
and the next block has not yet been pushed into the IN FIFO, NBW = 000 in the HASH_CR
register), the HASH_CSR22 to HASH_CSR37 registers do not have to be saved and
restored.