SHA - Context Switching

Context switching allows for the generation of a digest to be interrupted to do other functions or to generate other digests. Context switching can be used only in the SHA256 Digest mode, so it can only occur after a SHA Start has been issued and prior to a SHA Finalize command. Context switching may happen multiple times during the course of a digest generation.

Context switching involves two phases:
  1. 1.Read_Context - Reads a variable length context from the ATECC608A-TFLXTLS while leaving the context valid within the chip. The total length of the output data parameter is always from 40 to 99 bytes and can either be determined from the length field in the output packet or computed as 40 plus the Least Significant six bits of the first byte in the output.
  2. 2.Write_Context - Writes a SHA256 context from the host to the ATECC608A-TFLXTLS to allow subsequent update operations to be completed. This context must have previously been read from the chip with the Read_Context mode. The ATECC608A-TFLXTLS determines the size of the context from the first 4 bytes of the data parameter.

After the context has been read, the device may perform any other operations as required. Upon completion of the other operations, the context may be written back to the ATECC608A-TFLXTLS and the SHA256 Digest generation process may continue until it has completed.

Table 1. Input Parameters SHA Context Switching

Opcode
(1 Byte)

Mode
(1 Byte)

Param2
(2 Bytes)

Data
(Varies by Mode)

Description
0x47 0x06 0x00 00 0 bytes Read the current context
0x07 0x00 [ByteCount] 40 to 99 bytes Restore the current context from the prior session
Table 2. Output Response SHA Context Switching
Name Mode Size Description
Response 0x06

1 byte
40-99 bytes

If error code
context value

0x07 1 byte 0x00 if successful, otherwise an error code is received