61.4.6 Automatic Padding
The SHA module features an automatic padding computation to speed up the execution of the algorithm.
The automatic padding function requires the following information:
- Complete message size in bytes to be written in the MSGSIZE
field of the SHA Message Size register (SHA_MSR).
The size of the message is written at
the end of the last block, as required by the FIPS 180 specification (the size is
automatically converted into a bit-size).Note: SHA_MSR is a 32-bit register, thus the automatic padding capability is limited to messages of less than 4 gigabytes. For messages greater than 4 gigabytes, padding must be performed by the software.
- Number of remaining bytes (to write in the SHA_IDATARx) to be written in the BYTCNT field of the SHA Bytes Count register (SHA_BCR). Automatic padding occurs when the BYTCNT field reaches 0. At each write in the SHA Input registers, the BYTCNT field value is decreased by the number of bytes written.
The BYTCNT field value must be written with the same value as the MSGSIZE field value if the full message is processed. If the message is partially preprocessed and an initial hash value is used, BYTCNT must be written with the remaining bytes to hash while MSGSIZE holds the message size.
To disable the automatic padding feature, the MSGSIZE and BYTCNT fields must be configured with 0.