SLAU723A October 2017 – October 2018 MSP432E401Y , MSP432E411Y
The SHA_ODIGEST_A to SHA_ODIGEST_H registers are relevant only for HMAC operations; the contents are ignored for hash operations.
Before writing to the digest registers, the operation must be configured in the SHA Mode (SHA_MODE) register. For HMAC operations without key processing, the HMAC_KEY_PROC bit must be clear in the SHA_MODE register before starting operations. Once the algorithm has been programmed in the SHA_MODE register, only the relevant digest registers for the selected algorithm must be written:
When HMAC key processing is enabled (HMAC_KEY_PROC =1), these registers must be written with the lower 256 bits of the HMAC key to be processed in little-endian format (first byte of key string in bits [7:0]).
NOTE
If the HMAC key is less than 512 bits, it must be properly padded with zeros: all 16 HMAC key registers must be written explicitly; the core does not pad. Additionally, if the HMAC key is larger than 512 bits, the host must perform a preprocessing step to reduce it to one 512-bit block. This involves hashing the large key and padding the hash result with zeros until it is 512 bits wide.
The computed outer digest can be read from these registers when the SHA Interrupt Status (SHA_IRQSTATUS) register when the OUTPUT_READY bit has been set indicating that the operation is done.
NOTE
If no HMAC key processing is performed, the value read is identical to the value written initially. The MD5 outer digest is available from registers SHA_ODIGEST_A to SHA_ODIGEST_D, the SHA-1 outer digest from registers SHA_ODIGEST_A to SHA_ODIGEST_E, and the SHA-224 and SHA-256 outer digest from registers SHA_ODIGEST_A to SHA_ODIGEST_H.
NOTE
The HMAC key is not preserved. If another block must be authenticated using the same key, the key must be reloaded by the host. If the same key must be used many times, it is advisable to do a HMAC key processing-only pass to obtain the inner and outer digest precomputes and load these precomputes for subsequent passes (only the inner digest must be reloaded if the outer digest is not modified by the host), because this saves two hash blocks worth of computation time.