ID Unit

The ID Unit is a crypto coprocessor with hardware-based secure key storage, integrated with ATECC608B hardware cryptographic chip, using I2C communication interface. The chip has a built-in 10Kb EEPROM for storing keys, certificates, data, consumption records and security configurations.

Support the following products:

IDUnit

Micropython Example:

import os, sys, io
import M5
from M5 import *
from hardware import *
from unit import IDUnit


i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
id_0 = IDUnit(i2c0)
print(id_0.get_sha256_hash('Hello M5', 1))
print(id_0.get_generate_key(0, False))
print(id_0.randrange(500, 1000, 5))

UIFLOW2 Example:

example.png

cores3_id_example.m5f2

class IDUnit

Constructors

class IDUnit(i2c)

Create a IDUnit object

Parameters:

i2c (object) – the I2C object.

UIFLOW2:

init.png

Methods

IDUnit.get_revision_number() int

Returns the ATECC608B revision number. A revision number refers to a version identifier that indicates a specific iteration or update of the hardware design. The revision number helps distinguish between different versions of the same chip model.

  • Return: int: hexdecimal

UIFLOW2:

get_revision_number.png

IDUnit.get_serial_number() str

Returns the ATECC serial number.

9-byte serial number is structured as follows:

First 4 Bytes: These bytes are the first part of the serial number, which includes a fixed pattern and a portion that is unique to the device. Next 2 Bytes: These bytes are reserved and typically set to 0x00 or other reserved values. Last 3 Bytes: These bytes are the final part of the serial number and are unique to the device.

  • Return: string

UIFLOW2:

get_serial_number.png

IDUnit.randint(min, max) int

Returns the random number(4 byte). generate true random numbers using its hardware-based random number generator(RNG). This RNG is often used in secure applications where high-quality randomness is needed, such as in key generation.

Parameters:
  • min (int) – 0 ~ 4294967295.

  • max (int) – 0 ~ 4294967295.

  • Return: int: 0 ~ 4294967295

UIFLOW2:

randint.png

IDUnit.random() float

Returns a random floating point number in the range [0.0 ~ 1.0].

  • Return: float: 0.0 ~ 1.0

UIFLOW2:

random.png

IDUnit.randrange(min, max, step) int

The first form returns a random integer from the range(0, max). The second form returns a random integer from the range (min, max, step) in steps of step. For instance, calling randrange(1, 10, 2) will return odd numbers between 1 and 9 inclusive.

Parameters:
  • min (int) – 0 ~ 4294967295.

  • max (int) – 0 ~ 4294967295.

  • step (int) – 0 ~ 4294967295.

  • Return: int: 0 ~ 4294967295

UIFLOW2:

randrange_max.png randrange.png

IDUnit.uniform(min, max) float

Return a random floating point number N such that min <= N <= max for min <= max, and max <= N <= min for max < min.

Parameters:
  • Return: float:

UIFLOW2:

uniform.png

IDUnit.get_generate_key(slot_num, private_key) bytearray

Returns the generates a private or public key. A private key is a confidential piece of data that is used in cryptography to perform various functions. A public key is a cryptographic key that is paired with a private key in public-key cryptography.

Parameters:
  • slot_num (int) – 0 ~ 4

  • private_key (bool) – True or False

  • Return: bytearray:

UIFLOW2:

get_generate_key.png

IDUnit.get_ecdsa_sign(slot, message) bytearray

Returns the ECDSA signatures. ECDSA is widely used in digital signatures for ensuring the authenticity and integrity of messages and documents.

Parameters:
  • slot (int) – 0 ~ 4

  • messagestring or list or bytearray

  • Return: bytearray:

UIFLOW2:

get_ecdsa_sign.png

IDUnit.get_verify_ecdsa_sign(message, sign, key) bool

Returns the verify ecsda signature status. A signature verification in the Elliptic Curve Digital Signature Algorithm (ECDSA) is the process of checking whether a given digital signature is valid and was indeed generated by the holder of the corresponding private key or public key. This process ensures that the message or data.

Parameters:
  • messagestring or list or bytearray

  • signbytearray

  • keybytearray

  • Return: bool: True or False

UIFLOW2:

get_verify_ecdsa_sign.png

IDUnit.get_sha256_hash(message, format) str

Get the generate the SHA-256 hash value. SHA-256 (Secure Hash Algorithm 256-bit) is a cryptographic hash function that produces a fixed-size, 256-bit (32-byte) hash value, regardless of the size of the input data.

Parameters:
  • messagestring

  • format – 0: hexdecimal, 1: base64

  • Return: string:

UIFLOW2:

get_sha256_hash.png

IDUnit.set_certificate_signing_request(slot_num, private_key, country, state_prov, city, org, org_unit, file_path) None

A Certificate Signing Request (CSR) is a block of encoded text that is sent to a Certificate Authority (CA) when you apply for an SSL/TLS certificate. It contains information that the CA uses to create your certificate, including your public key and some information about your organization.

Parameters:
  • slot_num (int) – 0 ~ 4

  • private_key (bool) – True or False

  • country (str) – country name example: China

  • state_prov (str) – states or province name

  • city (str) – city name

  • org (str) – organization or company name

  • org_unit (str) – organization or company unit name

  • file_path (str) – Store the file to flash or SD

UIFLOW2:

set_certificate_signing_request.png