atecc608x (0.1.0)

Published 2026-03-07 14:52:05 +00:00 by faicel

Installation

[registries.forgejo]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add atecc608x@0.1.0 --registry forgejo

About this package

ATECC608A Driver

no_std driver for the Microchip ATECC608A Secure Element.

Description

This crate provides a Rust interface for the ATECC608A Secure Element, supporting:

  • P-256 ECDSA key pair generation
  • P-256 ECDSA digital signatures
  • P-256 ECDH key exchange
  • Secure key storage (private keys never exposed to the MCU)

Features

  • no_std compatible
  • Uses embedded-hal I2C traits
  • Hardware-accelerated cryptographic operations
  • Private keys never exposed to the MCU
  • Protection against physical attacks

Usage

Adding to your project

Add the dependency from the Forgejo registry:

[dependencies]
atecc608x = { version = "0.1.0", registry = "forgejo" }
embedded-hal = "1.0.0"

Configure the Forgejo registry in your project (e.g. in .cargo/config.toml or environment) so Cargo can resolve the forgejo registry index and authentication.

Basic example

use atecc608x::Atecc608x;
use embedded_hal::i2c::I2c;

// Initialize the driver (pass &mut i2c; you keep ownership of the bus)
let mut atecc = Atecc608x::new(&mut delay, &mut i2c, 0x60)?;

// Generate a P-256 key pair in slot 0
let public_key = atecc.generate_keypair(0)?;

// Sign a message hash
let message_hash = [0u8; 32]; // SHA-256 hash
let signature = atecc.sign(0, &message_hash)?;

// Perform ECDH key exchange
let peer_public_key = [0u8; 65]; // Peer public key
let shared_secret = atecc.ecdh(0, &peer_public_key)?;

Project structure

atecc608x/
├── src/
│   ├── lib.rs          # Entry point and re-exports
│   ├── driver/         # Main driver implementation
│   ├── error.rs        # Error types
│   ├── types.rs        # Types (KeySlot, P256PublicKey, P256Signature)
│   ├── status.rs       # Status handling
│   └── setup/          # Configuration profiles
├── scripts/
│   └── test.sh         # Run tests
├── Cargo.toml
└── README.md

Current status

⚠️ In development: Core implementation is in place; the following are still to be completed:

  • I2C communication protocol with ATECC608A
  • INFO command
  • GENKEY command
  • SIGN command
  • ECDH command
  • Timeout and error handling
  • Unit tests with I2C mock

ATECC608A documentation

For implementing commands, refer to:

Dependencies

ID Version
embedded-hal ^1.0.0
heapless ^0.9.2
p256 ^0.13
embedded-hal-mock ^0.11.1
Details
Cargo
2026-03-07 14:52:05 +00:00
27
120 KiB
Assets (1)
Versions (1) View all
0.1.0 2026-03-07