5.1.8.3 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. Read_Context - Reads a variable length context from the ATECC608B-TNGLoRaWAN 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. Write_Context - Writes a SHA256 context from the host to the ATECC608B-TNGLoRaWAN to allow subsequent update operations to be completed. This context must have previously been read from the chip with the Read_Context mode. The ATECC608B-TNGLoRaWAN 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 ATECC608B-TNGLoRaWAN and the SHA256 Digest generation process may continue until it has completed.

Table 5-29. Input Parameters SHA Context Switching

Opcode
(1 Byte)

Mode
(1 Byte)

Param2
(2 Bytes)

Data
(Varies by Mode)

Description
0x470x060x00 000 bytesRead the current context
0x070x00 [ByteCount]40 to 99 bytesRestore the current context from the prior session
Table 5-30. Output Response SHA Context Switching
NameModeSizeDescription
Response0x06

1 byte
40-99 bytes

If error code
context value

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