atecc608

package
v0.0.0-...-57044a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package atecc608 supports communication with Microchip ATECC608A and ATECC608B secure elements.

Index

Constants

View Source
const (
	CmdAddress        = 0x03
	CRC16Poly  uint16 = 0x8005
)
View Source
const CmdMaxExecutionTime = (200 + 50) * time.Millisecond

Max command execution time in ms considering a Clock-Divider set to the default/recommended value of 0x00, (p66, Table 10-5, ATECC608A Full Datasheet).

Variables

View Source
var (
	I2CBus     = 0
	I2CAddress = 0x60
)
View Source
var Cmd = map[string]byte{
	"AES":         0x51,
	"CheckMac":    0x28,
	"Counter":     0x24,
	"DeriveKey":   0x1C,
	"ECDH":        0x43,
	"GenDig":      0x15,
	"GenKey":      0x40,
	"Info":        0x30,
	"KDF":         0x56,
	"Lock":        0x17,
	"MAC":         0x08,
	"Nonce":       0x16,
	"PrivWrite":   0x46,
	"Random":      0x1B,
	"Read":        0x02,
	"SecureBoot":  0x80,
	"SelfTest":    0x77,
	"Sign":        0x41,
	"SHA":         0x47,
	"UpdateExtra": 0x20,
	"Verify":      0x45,
	"Write":       0x12,
}

Cmd represents the list of supported command codes, (p65, 10.4.1. Command Summary, ATECC608A Full Datasheet).

View Source
var CmdExecutionTime = CmdMaxExecutionTime

CmdExecutionTime sets the wait time between command execution and result retrieval.

View Source
var Status = map[byte]string{
	0x00: "successful command execution",
	0x01: "checkmac or verify miscompare",
	0x03: "parse error",
	0x05: "ECC fault",
	0x07: "self test error",
	0x08: "health test error",
	0x0f: "execution error",
	0x11: "after wake, prior to first command",
	0xee: "watchdog about to expire",
	0xff: "CRC or other communications error",
}

Status represents the device status/error codes, (p64-65, Tab 10-3, ATECC608A Full Datasheet).

Functions

func ExecuteCmd

func ExecuteCmd(opcode byte, param1 [1]byte, param2 [2]byte, data []byte, wake bool) (res []byte, err error)

ExecuteCmd issues an ATECC command conforming to:

  • p55, Table 9-1, ATECC508A Full Datasheet
  • p63, Table 10-1, ATECC608A Full Datasheet

The wake flag results in the executed command to be issued individually within a Wake() and Idle() cycle, when the flag is false the caller must take care of waking/idling/sleeping according to its desired command sequence.

func Idle

func Idle()

Idle puts the device in idle mode, (p50, Table 7-2, ATECC608A Full Datasheet).

func Info

func Info() (res string, err error)

Info executes the info command and returns the device serial number and software revision.

func SelfTest

func SelfTest() (res string, err error)

SelfTest executes the self test command and returns its results.

func Sleep

func Sleep()

Sleep puts the device in sleep mode, (p50, Table 7-2, ATECC608A Full Datasheet).

func Wake

func Wake() (err error)

Wake issues a device wake-up which is always needed before starting a new command session.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL