SWCU194 March 2023 CC1314R10 , CC1354P10 , CC1354R10 , CC2674P10 , CC2674R10
Setup of the Hash engine is accomplished with the CRYPTO:HASHMODE, CRYPTO:HASHIOBUFCTRL, CRYPTO:HASHINLENL, and CRYPTO:HASHINLENH registers.
The HASHMODE register provides a bit field for each of the SHA-224, SHA-256, SHA-384, and SHA-512 modes. Only one bit should be set, the others must be cleared. The HASHMODE register also contains a NEW_HASH bit. Setting this bit to 1 will cause the Hash engine to load the appropriate initial digest values into the CRYPTO:HASHDIGESTn registers.
The HASHIOBUFCTRL provides several control bits used when the host writes the Hash Data Input registers (CRYPTO:HASHDATAINn) and reads the Digest registers, CRYPTO:HASHDIGESTA - CRYPTO:HASHDIGESTP (as opposed to the DMA performing the reads and writes). See Section 12.2.9.2 for more information. In addition, the CRYPTO:HASHIOBUFCTRL.PAD_DMA_MESSAGEbit is provided. Set this bit to 1 when the DMA has been configured to load the last block of the message. When set to 1, the Hash engine will finalize the digest value. If the DMA is not being used or if the digest is not (yet) to be finalized, this bit must be set to 0.
The HASHINLENL and HASHINLENH are written to indicate the length, in bits, of the message being hashed. The HASHINLENL should we written first, and then the HASHINLENH since a write to HASHINLENL will clear HASHINLENH. When a hash is to be finalized, the length value written must be the total length of the message, including any bits of the message processed in a prior hash operation.