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 10, 2024
1 parent 2c06c5b commit e273dd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ trussed-wrap-key-to-file = { git = "https://github.com/trussed-dev/trussed-stagi
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.12" }

trussed-se050-manage = { path = "extensions/se050-manage" }
se05x = { git = "https://github.com/Nitrokey/se05x.git" , rev = "2cd31b814ffa188f2c105ce034af316858ed4dd1" }

[features]
default = ["log-all"]
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 e273dd5

Please sign in to comment.