Skip to main content

Module read_write

Module read_write 

Source
Expand description

Read and Write commands.

These access the config, data, or OTP zones. They support 4-byte and 32-byte transfers. Writes to the data zone are subject to the per-slot SlotConfig.WriteConfig rules captured in crates/hsm-crypto-service.

§Address encoding

The ATECC608B encodes the target of a Read or Write into the 16-bit param2 of the command frame. The format depends on the zone.

  • Config zone. The zone is 128 bytes laid out as 4 blocks of 32 bytes. Each block is addressable as 8 “words” of 4 bytes.

    bits 0..=2  : offset within block (word index, 0..=7).
    bits 3..=4  : block index (0..=3).
    bits 5..=15 : reserved (zero).
  • OTP zone. Same layout as the config zone but only 2 blocks of 32 bytes (block index in 0..=1).

  • Data zone. One slot per row.

    bits 0..=2  : offset within block (word index).
    bits 3..=7  : slot index (0..=15).
    bits 8..=15 : block index.

In 32-byte transfers the offset bits must be zero, the chip rejects the command otherwise.

§param1 encoding

param1 carries the zone identifier in its low two bits, an optional encryption flag, and a single “this is a 32-byte transfer” flag.

bits 0..=1 : zone (0 = Config, 1 = OTP, 2 = Data).
bit  6     : 1 -> data field is encrypted with TempKey + MAC (Write only).
bit  7     : 1 -> 32-byte transfer, 0 -> 4-byte transfer.

Reference: CryptoAuthLib lib/calib/calib_read.c and lib/calib/calib_write.c, constants ATCA_ZONE_CONFIG, ATCA_ZONE_OTP, ATCA_ZONE_DATA, ATCA_ZONE_READWRITE_32, ATCA_ZONE_ENCRYPTED.

Enums§

Zone
One of the three addressable zones of the ATECC608B.

Constants§

BLOCK_SIZE
Size of one block transferred in a 32-byte read or write.
CONFIG_ZONE_BLOCK_COUNT 🔒
Number of 32-byte blocks in the config zone (128 / 32 = 4).
CONFIG_ZONE_SIZE 🔒
Size of the config zone in bytes.
ENCRYPTED_WRITE_DATA_SIZE
Total size of the data field for an encrypted 32-byte write: 32 bytes of ciphertext followed by 32 bytes of MAC.
ENCRYPTED_WRITE_MAC_SIZE 🔒
Size of the MAC appended to an encrypted 32-byte write.
PARAM1_FLAG_32_BYTES 🔒
Flag OR’d into param1 to switch from a 4-byte to a 32-byte transfer.
PARAM1_FLAG_ENCRYPTED 🔒
Flag OR’d into param1 to indicate the data field is encrypted with TempKey and is followed by a MAC. Only valid for 32-byte Writes.
WORD_SIZE
Size of one word transferred in a 4-byte read or write.

Functions§

config_or_otp_address
Build the param2 address for a config or OTP zone access.
data_address
Build the param2 address for a data zone access.
read_param1 🔒
Compose the param1 byte for a Read.
write_param1 🔒
Compose the param1 byte for a Write.