atecc508a v0.1.0 ATECC508A.DataZone

This module handles operations on the data zone.

Link to this section Summary

Functions

Lock the data and OTP zones

Pad the passed in data to a multiple of 32-bytes

Pad the specified data to the exact size of the slot

Read a slot

Return the size in bytes of the specified slot

Write a slot in the data zone

Write a slot in the data zone and pad to a multiple of 32-bytes

Link to this section Functions

Link to this function lock(transport, expected_contents)
lock(ATECC508A.Transport.t(), ATECC508A.crc16()) :: :ok | {:error, atom()}

Lock the data and OTP zones.

The expected contents concatenated together for the non-private key data slots and the OTP need to be passed for a CRC calculation. They are not written by design. The logic is that this is a final chance before it’s too late to check that the device is programmed correctly.

Link to this function pad_to_32(data)
pad_to_32(binary()) :: binary()

Pad the passed in data to a multiple of 32-bytes

This is useful when 4-byte writes aren’t allowed.

Link to this function pad_to_slot_size(slot, data)
pad_to_slot_size(ATECC508A.Request.slot(), binary()) :: binary()

Pad the specified data to the exact size of the slot.

Link to this function read(transport, slot)
read(ATECC508A.Transport.t(), ATECC508A.Request.slot()) ::
  {:ok, binary()} | {:error, atom()}

Read a slot

Return the size in bytes of the specified slot.

Link to this function write(transport, slot, data)
write(ATECC508A.Transport.t(), ATECC508A.Request.slot(), binary()) ::
  :ok | {:error, atom()}

Write a slot in the data zone.

This uses 4 byte writes. These are only allowed under some conditions. Most notably, 4-byte writes aren’t allowed when the data zone is UNLOCKED.

Link to this function write_padded(transport, slot, data)
write_padded(ATECC508A.Transport.t(), ATECC508A.Request.slot(), binary()) ::
  :ok | {:error, atom()}

Write a slot in the data zone and pad to a multiple of 32-bytes

This is useful to get around 32-byte write limitations. The padded bytes are set to 0.