Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 37 additions & 42 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,58 +1,53 @@
[package]
name = "at-cryptoauth"
version = "0.4.1-alpha.0"
authors = ["Kei Shirakizawa <[email protected]>"]
authors = ["The Factbird Team"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/BlackbirdHQ/at-cryptoauth-rs"
documentation = "https://docs.rs/at-cryptoauth"
description = "Driver for ATECC608 Crypto Authentication secure elements"
edition = "2018"
edition = "2021"

[workspace]
members = []
default-members = ["."]
exclude = ["examples"]

[dependencies]
crc = { version = "2.0.0", default-features = false }
heapless = "^0.7"
generic-array = "0.14.4"
crc = { version = "3.0", default-features = false }
heapless = "0.8"
bitfield-struct = "0.9"


log = { version = "^0.4", default-features = false, optional = true }
defmt = { version = "^0.3", optional = true }


[dependencies.embedded-hal]
version = "=1.0.0-rc.2"

[dependencies.signature]
version = "1.2.2"
default-features = false

[dependencies.digest]
version = "0.9.0"
default-features = false

# Dependencies for the STM32L4XX example
[target.'cfg(all(target_arch = "arm", target_os = "none"))'.dev-dependencies]
cortex-m = "0.7.2"
cortex-m-rt = "0.7"
cortex-m-semihosting = "0.3.5"
panic-halt = "0.2.0"
panic-semihosting = "0.5.0"

# [target.'cfg(all(target_arch = "arm", target_os = "none"))'.dev-dependencies.stm32l4xx-hal]
# path = "../stm32l4xx-hal"
# features = ["rt", "stm32l475"]

# Dependencies for the RaspberryPi example
[target.armv7-unknown-linux-gnueabihf.dependencies]
env_logger = { version = "0.9", optional = true }
# linux-embedded-hal = { version = "0.4.0-alpha.1", optional = true }
openssl = { version = "0.10.30", features = ["vendored"], optional = true }
embedded-hal = { version = "1.0" }
embedded-hal-async = { version = "1.0" }

embassy-time = { version = "0.4" }
embassy-sync = { version = "0.6" }
embassy-futures = { version = "0.1.1" }

signature = { version = "2.2", default-features = false, features = [
"digest",
"derive",
"rand_core",
] }
# async-signature = { version = "0.5", default-features = false, features = ["digest", "rand_core"] }
embedded-tls = { git = "https://github.com/drogue-iot/embedded-tls", rev = "7936bc1", default-features = false, optional = true }

p256 = { version = "0.13.2", default-features = false, features = [
"ecdsa-core",
"pkcs8",
] }
const-oid = { version = "0.9.6", features = ["db"] }
der = { version = "0.7.8", features = ["derive", "flagset", "oid"] }
spki = { version = "0.7.3" }
pem-rfc7468 = { version = "0.7.0", optional = true }
hex-literal = "0.4.1"

[features]
default = []
std = ["env_logger", "log", "openssl"]

[[example]]
name = "raspberrypi_atecc608"
required-features = ["std"]
default = ["embedded-tls", "pem"]

[[example]]
name = "stm32l4xx_atecc608"
pem = ["dep:pem-rfc7468"]
40 changes: 40 additions & 0 deletions examples/raspberrypi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "at-cryptoauth-examples-raspberrypi"
version = "0.1.0"
edition = "2021"

[dependencies]
at-cryptoauth = { path = "../../", features = ["log"] }
env_logger = { version = "0.11" }
# linux-embedded-hal = { version = "0.4.0-alpha.1" }
openssl = { version = "0.10.30", features = ["vendored"] }

[profile.dev]
debug = 2
debug-assertions = true
opt-level = 1
overflow-checks = true

[profile.release]
codegen-units = 1
debug = 2
debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 'z'
overflow-checks = false

# do not optimize proc-macro crates = faster builds from scratch
[profile.dev.build-override]
codegen-units = 8
debug = false
debug-assertions = false
opt-level = 0
overflow-checks = false

[profile.release.build-override]
codegen-units = 8
debug = false
debug-assertions = false
opt-level = 0
overflow-checks = false
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use at_cryptoauth::memory::{Size, Slot, Zone};
use at_cryptoauth::tngtls::{AES_KEY, AUTH_PRIVATE_KEY, SIGN_PRIVATE_KEY, USER_PRIVATE_KEY1};
use at_cryptoauth::{AtCaClient, Block};
use core::fmt::Debug;
use embedded_hal::delay::DelayNs embedded_hal::i2c::{Read, Write};
use linux_embedded_hal::Delay;
use linux_embedded_hal::I2cdev;
use log::info;
Expand Down Expand Up @@ -65,7 +64,7 @@ fn main() -> Result<(), Box<dyn Error>> {

let mut i2c = I2cdev::new(I2C_PATH)?;
i2c.set_slave_address(ATECC608_ADDR)?;
let mut atca = AtCaClient::new(i2c, Delay);
let mut atca = AtCaClient::new(i2c);

// Imitate flash-time procedure.
let revision = atca.info().map_err(|e| format!("{}", e))?;
Expand Down
8 changes: 8 additions & 0 deletions examples/rp2040/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "probe-rs run --chip RP2040"

[build]
target = "thumbv6m-none-eabi"

[env]
DEFMT_LOG = "debug"
1 change: 1 addition & 0 deletions examples/rp2040/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
75 changes: 75 additions & 0 deletions examples/rp2040/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[package]
name = "at-cryptoauth-examples-rp2040"
version = "0.1.0"
edition = "2021"

[dependencies]
at-cryptoauth = { path = "../../", features = ["defmt"] }

embassy-executor = { version = "0.5.0", features = [
"arch-cortex-m",
"executor-thread",
"executor-interrupt",
"defmt",
"integrated-timers",
] }
embassy-time = { version = "0.3", features = [
"defmt",
"defmt-timestamp-uptime",
] }
embassy-rp = { version = "0.1.0", features = [
"defmt",
"unstable-pac",
"time-driver",
] }
embassy-futures = { version = "0.1.0" }
embassy-sync = { version = "0.5.0" }
portable-atomic = { version = "1.0.2", features = [
"unsafe-assume-single-core",
] }

static_cell = { version = "2" }
defmt = "0.3.4"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }

cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
futures = { version = "0.3.17", default-features = false, features = [
"async-await",
"cfg-target-has-atomic",
"unstable",
] }

embedded-io-async = { version = "0.6.0" }
heapless = "0.8"

[profile.dev]
debug = 2
debug-assertions = true
opt-level = 1
overflow-checks = true

[profile.release]
codegen-units = 1
debug = 2
debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 'z'
overflow-checks = false

# do not optimize proc-macro crates = faster builds from scratch
[profile.dev.build-override]
codegen-units = 8
debug = false
debug-assertions = false
opt-level = 0
overflow-checks = false

[profile.release.build-override]
codegen-units = 8
debug = false
debug-assertions = false
opt-level = 0
overflow-checks = false
36 changes: 36 additions & 0 deletions examples/rp2040/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.

use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());

// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");

println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}
5 changes: 5 additions & 0 deletions examples/rp2040/memory.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MEMORY {
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
FLASH : ORIGIN = 0x10000100, LENGTH = 1024K - 0x100
RAM : ORIGIN = 0x20000000, LENGTH = 256K
}
Loading