ATECC508A.Host (atecc508a v1.4.0)

Copy Markdown View Source

Implementations of useful operations for the host CPU to perform.

This is mainly things like constructing a message correctly for hashing.

Summary

Functions

CheckMac operation on the host.

Generate hash using SHA-256.

MAC operation on the host.

Generate a random binary of the specified length.

Generate a nonce from a random input.

Functions

checkmac(key, nonce, arg)

@spec checkmac(binary(), binary(), binary()) :: %{
  msg: binary(),
  digest: binary(),
  other: binary()
}

CheckMac operation on the host.

This is used for the ClientResp parameter when authorizing a key using CheckMac.

This implementation does not use the extra bytes of the serial number.

Returns a map of the constructed message, the digest and the OtherData used when building the message.

digest(msg)

@spec digest(binary()) :: binary()

Generate hash using SHA-256.

mac(key, nonce, opcode, mode, param2, arg)

@spec mac(
  key :: binary(),
  nonce :: binary(),
  opcode :: binary(),
  mode :: binary(),
  param2 :: binary(),
  serial_number :: binary()
) :: %{msg: binary(), digest: binary()}

MAC operation on the host.

This implementation does not use the extra bytes of the serial number.

Returns a map of the constructed message, the digest and the OtherData used when building the message.

rand(bytes)

@spec rand(bytes :: non_neg_integer()) :: binary()

Generate a random binary of the specified length.

random_nonce(arg1, arg2, arg3)

@spec random_nonce(binary(), binary(), binary()) :: binary()

Generate a nonce from a random input.

This matches the nonce implementation of the device.

It takes an input from the device RNG, the random input the host used to seed the RNG, and the nonce mode.

It returns a digest.