Hash processor (HASH)
RM0090
768/1731
DocID018909 Rev 11
The least significant bit of the message has to be at position 0 (right) in the first word
entered into the hash processor, the 32nd bit of the bit string has to be at position 0 in the
second word entered into the hash processor and so on.
25.3.3
Message digest computing
The HASH sequentially processes blocks of 512 bits when computing the message digest.
Thus, each time 16 × 32-bit words (= 512 bits) have been written by the DMA or the CPU,
into the hash processor, the HASH automatically starts computing the message digest. This
operation is known as a partial digest computation.
The message to be processed is entered into the peripheral by 32-bit words written into the
HASH_DIN register. The current contents of the HASH_DIN register are transferred to the
input FIFO (IN FIFO) each time the register is written with new data. HASH_DIN and the
input FIFO form a FIFO of a 17-word length (named the IN buffer).
The processing of a block can start only once the last value of the block has entered the IN
FIFO. The peripheral must get the information as to whether the HASH_DIN register
contains the last bits of the message or not. Two cases may occur:
•
When the DMA is not used:
–
In case of a partial digest computation, this is done by writing an additional word
into the HASH_DIN register (actually the first word of the next block). Then the
software must wait until the processor is ready again (when DINIS=1) before
writing new data into HASH_DIN.
–
In case of a final digest computation (last block entered), this is done by writing the
DCAL bit to 1.
•
When the DMA is used:
The contents of the HASH_DIN register are interpreted automatically with the
information sent by the DMA controller.
–
In case of a single DMA transfer: Multiple DMA transfer (MDMAT) bit should be
cleared on STM32F43xxx. When the last block has been transferred to the
HASH_DIN register via DMA channel, DCAL bit will be set to automatically to 1 in
the HASH_STR register in order to launch the final digest calculation.
–
In case of a multiple DMA transfer (available only on STM32F43xxx): Multiple
DMA transfer (MDMAT) bit should be set to 1 by software so DCAL bit does not
get set automatically by HW, in this case the final digest calculation for hash and
for each phases for HMAC (for more details about HMAC phases please refer to
HMAC operation section) will not be launched a the end of the DMA transfer
request, allowing the processor to receive a new DMA transfer. During the last
DMA transfer, Multiple DMA transfer (MDMAT) bit should be cleared by software in
order to set automatically DCAL bit at the end of the last bloc and lunch the final
digest.
–
The contents of the HASH_DIN register are interpreted automatically with the
information sent by the DMA controller.
This process —data en partial digest computation— continues until the last bits of
the original message are written to the HASH_DIN register. As the length (number of bits) of
a message can be any integer value, the last word written into the HASH processor may
have a valid number of bits between 1 and 32. This number of valid bits in the last word,
NBLW, has to be written into the HASH_STR register, so that message padding is correctly
performed before the final message digest computation.