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:
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:
class IDUnit
Constructors
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:
- 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:
- 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.
Return:
int
: 0 ~ 4294967295
UIFLOW2:
- IDUnit.random() float
Returns a random floating point number in the range [0.0 ~ 1.0].
Return:
float
: 0.0 ~ 1.0
UIFLOW2:
- 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.
Return:
int
: 0 ~ 4294967295
UIFLOW2:
- 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.
Return:
float
:
UIFLOW2:
- 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.
Return:
bytearray
:
UIFLOW2:
- 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
message –
string
orlist
orbytearray
Return:
bytearray
:
UIFLOW2:
- 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:
message –
string
orlist
orbytearray
sign –
bytearray
key –
bytearray
Return:
bool
: True or False
UIFLOW2:
- 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:
message –
string
format – 0: hexdecimal, 1: base64
Return:
string
:
UIFLOW2:
- 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: