![Texas Instruments SimpleLink Ethernet MSP432E401Y Technical Reference Manual Download Page 1592](http://html1.mh-extra.com/html/texas-instruments/simplelink-ethernet-msp432e401y/simplelink-ethernet-msp432e401y_technical-reference-manual_10955781592.webp)
SHA/MD5 Functional Description
1592
SLAU723A – October 2017 – Revised October 2018
Copyright © 2017–2018, Texas Instruments Incorporated
SHA/MD5 Accelerator
•
SHA_IDIGEST_A to SHA_IDIGEST_D registers for MD5
•
SHA_IDIGEST_A to SHA_IDIGEST_E registers for SHA-1
•
SHA_IDIGEST_A to SHA_IDIGEST_H registers for SHA-2
When ALGO_CONSTANT = 1 in the SHA_MODE register, the SHA Inner Digest n (SHA_IDIGEST_n)
registers do not need to be written by the application because they are overwritten with the appropriate
algorithm constants.
When HMAC_KEY_PROC is 1, these registers must be written with the upper 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 order of the bytes within the digest is such that it can be fed back unmodified into the little-endian
data input when preprocessing HMAC keys larger than 64 bytes, or it can typically be inserted unmodified
into a little-endian data stream (for example, IPSEC packets), regardless of the selected algorithm.
NOTE:
The HMAC key or inner digest is not preserved. If another block must be authenticated using
the same key, the key or inner digest 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.
25.1.5.1.2 Closing a Hash
The amount of data to hash is not necessarily a multiple of 64 bytes. The CLOSE_HASH bit in the
SHA_MODE register is set to append padding so that the message size becomes a multiple of 64 bytes.
Consequently, a minimum of 9 bytes must be added to the message. Nine bytes is the minimum number
of bytes that contains the minimum 65-bit padding specified by FIPS 180-1.
If the size of the last block of data is less than or equal to 55 bytes, no additional 64-byte block is required.
However, if the last block of data contains more than 55 bytes, an extra 64-byte block must be added to
make the padding as specified by FIPS 180-1. This extra block is added automatically by the hardware;
thus, the module is fed with a 64-byte block of data. However, appending a pad on the last block of data
can result in the creation of an extra 64-byte block.
The one or two last blocks that contain the padding are processed in the same way as the other blocks.
Hash completion is then indicated in the same way as for a new hash, and the hash result can be read in
the digest registers. The SHA_DIGESTCOUNT register returns restored Digest Count + Length when it is
read, and hashing completes.
Assuming a message of 129 bytes,
shows the SHA digest for three passes.
shows
the SHA digest for one pass.
Table 25-5. SHA Digest Processed in Three Passes
Digest (A to E)
SHA_
DIGEST_COUNT
SHA_MODE and SHA_LENGTH
SHA_DATA_n_IN
First pass
WRITE:
LENGTH = 64
ALGO (dependent on the algorithm to apply)
ALGO_CONSTANT = 1
CLOSE_HASH = 0
First 64 bytes of
message