GD32W51x User Manual
957
set 1 to start the calculation of the digest of the last block.
Data Padding Example: The input message is “HAU”, which ASCII hexadecimal code is:
484155
Then the VBL bits in the HAU_CFG register is set as decimal 24 because of the valid bit
length. A “1” is added at bit location 24 then, and several “0” are padded so that the result
modulo 512 is 448, the hexadecimal result is as follows:
48415580 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000
After that, a 64-bit length information of the input message is padded, which hexadecimal
value is 18, and the final result will be:
48415580 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000018
28.4.2.
Digest computing
After data padding, for each block calculation of HAU, 512 bits are written into the HAU core
by DMA or CPU. To start the processing of the HAU core, the peripheral must obtain the
information as to whether the HAU_DI register contains the last bits of the message or not.
This can be confirmed with the status of the input FIFO and the HAU_DI register.
When DMA is used to transfer data:
The status of the block transfer is automatically interpreted with the information from the DMA
controller. And padding and digest computation are performed automatically as if CALEN bit
in the HAU_CFG register is set as 1.
Note:
If hash message is large files and multiple DMA transfers are needed, then MDS bit
should be set as 1. And the VBL bits need to be set before the transfer. The CALEN bit is not
set automatically after an intermediate DMA transfer completed. Only when the last DMA
transfer is processing, the MDS bit is cleared so that the CALEN bit is automatically set after
data transferring.
Otherwise, the MDS bit is set as 0. And the CALEN bit is set automatically after a DMA
transfer. Also, VBL bits need to set before the DMA transfer.
When CPU is used to transfer data without DMA: