GD32W51x User Manual
958
The intermediate block computing can be started when HAU_DI is filled with another
new word of the next block
The last block computing can be started when CALEN bit in the HAU_CFG register is 1.
28.4.3.
Hash mode
The hash mode is selected when the HMS bit in the HAU_CTL register is set as 0. And when
the START bit in the HAU_CTL register is 1, SHA-1, SHA-224, SHA-256 and MD5 mode
computation is chosen by the ALGM bits.
After a message block of 512 bit has been received through the HAU_DI register and the
input FIFO, the processor starts the calculation with the information from DMA or the status
of the CALEN bit.
The results can be finally read from the HAU_DO0..7 registers.
28.4.4.
HMAC mode
HMAC mode is used for message authentication with a unique key chosen by the user. More
information about the HMAC specifications please refer to “HMAC: keyed-hashing for
message authentication, H. Krawczyk, M. Bellare, R. Canetti, February
1997”.
The HMAC algorithm can be represented as:
HMAC(input) = HASH[((key | opad) XOR 0x5c) | HASH(((key | ipad) XOR 0x36) | input)]
where ipad and opad are used to extend the key to 512 bits with several “0” and | is the
concatenation operator.
There are four different phases in the HMAC mode:
1.
Configure the HMS bit in the HAU_CTL register as 1 and set the ALGM bit s as the
desired algorithm. If the key size is longer than 64 bytes, then the KLM bit in the
HAU_CTL register should also be set. After that, start the HAU core by set the START
bit.
2.
The key is used as the input message to complete the calculation in HASH mode.
3.
The new key used for the inner hush function is elaborated when the last word is
accessed and computation has started.
4.
After the first hash round, HAU core starts to receive the key for the outer hash function,
usually, the outer hash function uses the same new key as the inner hash function. And
when the last word of the key is entered and computation starts, the results are available
in the HAU_DO registers.