ATECC508A.DataZone (atecc508a v0.3.0) View Source

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)

View Source

Specs

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.

Specs

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

Specs

pad_to_slot_size(ATECC508A.Request.slot(), binary()) :: binary()

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

Specs

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

Read a slot

Specs

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

Specs

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

Specs

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.