Skip to content

Commit

Permalink
Improve inlining of se050 constants
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Apr 11, 2024
1 parent 2c06c5b commit 46b5af1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 9 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -124,7 +128,8 @@ impl<Twi: I2CForT1, D: DelayUs<u32>> Se050Backend<Twi, D> {
}

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(());
Expand All @@ -138,8 +143,8 @@ impl<Twi: I2CForT1, D: DelayUs<u32>> Se050Backend<Twi, D> {
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
})?;
Expand Down

0 comments on commit 46b5af1

Please sign in to comment.