View Source ATECC508A.DataZone (atecc508a v1.3.0)

This module handles operations on the data zone.

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

Functions

Link to this function

lock(transport, expected_contents)

View Source
@spec 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.

@spec 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)

View Source
@spec pad_to_slot_size(ATECC508A.Request.slot(), binary()) :: binary()

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

@spec read(ATECC508A.Transport.t(), ATECC508A.Request.slot()) ::
  {:ok, binary()} | {:error, atom()}

Read a slot

@spec slot_size(ATECC508A.Request.slot()) :: 36 | 72 | 416

Return the size in bytes of the specified slot.

Link to this function

write(transport, slot, data)

View Source
@spec write(ATECC508A.Transport.t(), ATECC508A.Request.slot(), binary()) ::
  :ok | {:error, atom()}

Write a slot in the data zone.

This can use 4 byte writes if the data is not a multiple of 32 bytes. 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)

View Source
@spec 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.