ATSHA204A
Security Commands
TempKey.SlotID == SlotConfig.ReadKey
• If the slot number being read is even, then TempKey.SourceFlag must be “RAND”.
• If the slot number is odd, then TempKey.SourceFlag must match the value in
Config.CheckMacSource corresponding to the slot.
• XOR the data from the memory zone with TempKey. Return as “Contents.”
8.5.16
SHA Command
The SHA command computes a SHA-256 digest for general purpose use by the system. Any message
length can be accommodated. The system is responsible for sending the pad and length bytes with the
last block.
Calculation of a digest occurs through the following two steps:
1. Initialization
Setup the SHA-256 calculation engine by overwriting the current value of TempKey with the
initialization constant. Force the TempKey flags to match the state they would have after a
Nonce(Fixed)command. This mode does not accept any message bytes.
2. Compute
The command can be called a variable number of times with this mode to add bytes to the
message. Each iteration of this mode must include a message of 64 bytes. The output buffer
always contains the digest, which can be ignored if desired. The digest is also loaded into
TempKey.
The SHA(Init) command must be run before any SHA(Compute) commands are accepted. The
system may run as many SHA(Compute) commands as required to compute the desired digest. An error
is returned if any command other than SHA is run between the “Init” iteration and the last “Compute”
iteration. The command also returns a Parse error if the Mode byte has a value other than 0x00 or 0x01.
The intermediate digest stored in TempKey is invalidated if the device is put to sleep or the watchdog
timer expires. The system software must ensure that either the entire message is sent to the device
during a single wake/watchdog interval or that the appropriate Idle sequences are inserted between the
SHA commands.
Table 8-36. Input Parameters
Name Size Notes
Opcode SHA
1 0x47
Param1 Mode
Bits 7-1: Must be zero.
0 = (Init): Load TempKey with the initialization value for SHA-256. No
1
message bytes are accepted (Length must be zero).
Bit 0:
1 = (Compute): Add 64 bytes in the message parameter to the SHA
context and return the digest
Param2 Param2 2 Must be 0x0000.
Data Message 0 or 64 64 bytes of data to be included into the hash operation. Ignored if Mode<0> is zero.
© 2018 Microchip Technology Inc.
DS40002025A-page 62