From 46b5af1842ccae7db76171aca5813f13991054c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Wed, 10 Apr 2024 18:02:22 +0200 Subject: [PATCH] Improve inlining of se050 constants --- Cargo.toml | 2 +- src/lib.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9c94eea..0f146be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ trussed = { version = "0.1.0", features = ["serde-extensions"] } serde.workspace = true trussed.workspace = true -se05x = { version = "0.1.1", features = ["serde", "builder"] } +se05x = { version = "0.1.3", features = ["serde", "builder"] } trussed-auth = "0.3.0" trussed-manage = "0.1.0" trussed-se050-manage = "0.1.0" diff --git a/src/lib.rs b/src/lib.rs index c28ac77..5253603 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,11 @@ use littlefs2::path; use littlefs2::path::Path; use namespacing::{Namespace, NamespaceValue}; use se05x::{ - se05x::{commands::ReadEcCurveList, Atr, EcCurve, ObjectId, Se05X}, + se05x::{ + commands::ReadEcCurveList, + constants::{CurveInitializer, PRIME256V1_INITIALIZER, SECP521R1_INITIALIZER}, + Atr, ObjectId, Se05X, + }, t1::I2CForT1, }; use trussed::{types::Location, Bytes}; @@ -124,7 +128,8 @@ impl> Se050Backend { } fn configure(&mut self) -> Result<(), trussed::Error> { - const REQUIRED_CURVES: [EcCurve; 2] = [EcCurve::NistP256, EcCurve::NistP521]; + const REQUIRED_CURVES: [CurveInitializer; 2] = + [PRIME256V1_INITIALIZER, SECP521R1_INITIALIZER]; self.enable()?; if self.configured { return Ok(()); @@ -138,8 +143,8 @@ impl> Se050Backend { trussed::Error::FunctionFailed })?; for i in REQUIRED_CURVES { - if !configured_curves.ids.contains(&i.into()) { - self.se.create_and_set_curve(i).map_err(|_err| { + if !configured_curves.ids.contains(&i.curve.into()) { + self.se.create_and_set_curve_params(&i).map_err(|_err| { debug!("Failed to create curve: {_err:?}"); trussed::Error::FunctionFailed })?;