
DocID024597 Rev 5
857/1830
RM0351
Hash processor (HASH)
875
29.3.5
Message digest computing
The hash processor sequentially processes 512-bit blocks when computing the message
digest. Thus, each time 16 × 32-bit words (= 512 bits) have been written to the hash
processor by the DMA or the CPU, the HASH automatically starts computing the message
digest. This operation is known as ‘partial digest computation’.
As described in
Section 29.3.4: Message data feeding
, the message to be processed is
entered into the HASH 32-bit word at a time, writing to the HASH_DIN register to fill the
input FIFO. In order to perform the hash computation on this data below sequence shall be
used by the application.
1.
Initialize the hash processor using the HASH_CR register:
–
Select the right algorithm using ALGO field. If needed program the correct
swapping operation on the message input words using DATATYPE bitfield in
HASH_CR.
–
Set MODE=1 and select the key length using LKEY if HMAC mode has been
selected.
–
Update NBLW to define the number of valid bits in last word if it is different from 32
bits. If it is the case automatic padding could be applied by the HASH.
2. Complete the initialization by setting to 1 the INIT bit in HASH_CR. Also set the bit
DMAE to 1 if data are transferred via DMA.
Caution:
When programming step 2, it is important to set up before or at the same time the correct
configuration values (ALGO, DATATYPE, HMAC mode, key length, NBLW).
3. Start filling data by writing to HASH_DIN register, unless data are automatically:
transferred via DMA. Note that the processing of a block can start only once the last
value of the block has entered the IN FIFO. The way the partial or final digest
computation is managed depends on the way data are fed into the processor:
a) When data are filled by software:
–
The partial digest computation is triggered when the software writes an additional
word to the HASH_DIN register (actually the first word of the next block). Once the
processor is ready again (DINIS=1 in HASH_SR), the software can write new data
to HASH_DIN. This mechanism avoids the introduction of wait states by the
HASH.
–
The final digest computation is triggered when the last block is entered and the
software writes the DCAL bit to 1. If the message length is not an exact multiple of
512 bits, the NBLW field in HASH_STR register must be written prior to writing
DCAL bit (see
for details).
b) When data are filled by DMA as a single DMA transfer (MDMAT bit=”0”):
–
The partial digest computation is triggered automatically each time the FIFO is full.
–
The final digest computation is triggered automatically when the last block has
been transferred to the HASH_DIN register (DCAL bit is set to 1 by hardware). If
the message length is not an exact multiple of 512 bits, the NBLW field in
HASH_STR register must be written prior to enabling the DMA (see
for details).
c) When data are filled using multiple DMA transfers (MDMAT bit=”1”) :
–
The partial digest computations are triggered as for single DMA transfers.
However the final digest computation is not triggered automatically when the last
block has been transferred to the HASH_DIN register (DCAL bit is not set to 1 by
hardware). It allows the hash processor to receive a new DMA transfer as part of