From f54745e994eef2408fbb2daaaf88b8c41e2d26db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Thu, 3 Oct 2024 11:08:46 +0200 Subject: [PATCH] Add support for listing configs Depends on https://github.com/Nitrokey/admin-app/pull/29 --- Cargo.lock | 11 ++++++++--- Cargo.toml | 4 +++- components/apps/Cargo.toml | 1 + components/apps/src/lib.rs | 25 +++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80779504..323aa409 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "admin-app" version = "0.1.0" -source = "git+https://github.com/Nitrokey/admin-app.git?tag=v0.1.0-nitrokey.13#c24149193fb9bdcaa9ed4dd99fd2a503159a66ee" +source = "git+https://github.com/Nitrokey/admin-app.git?rev=2bcefb3dda021a7e815016bf4f0719a84af13d3f#2bcefb3dda021a7e815016bf4f0719a84af13d3f" dependencies = [ "apdu-dispatch", "cbor-smol", @@ -165,6 +165,7 @@ dependencies = [ "embedded-hal", "fido-authenticator", "heapless", + "heapless-bytes", "hex", "if_chain", "littlefs2", @@ -495,8 +496,7 @@ dependencies = [ [[package]] name = "cbor-smol" version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f2529cc8240fcc91e8642754ce85e5360c2ee7f4435a76aa150e4ed746a5da4" +source = "git+https://github.com/Nitrokey/cbor-smol.git?tag=v0.4.0-nitrokey.5#4a368461e06e3ca52d79638b9ab8f34b038491fc" dependencies = [ "delog", "heapless", @@ -3857,3 +3857,8 @@ dependencies = [ "quote", "syn 2.0.69", ] + +[[patch.unused]] +name = "lpc55-hal" +version = "0.3.0" +source = "git+https://github.com/Nitrokey/lpc55-hal?tag=v0.3.0-nitrokey.2#781c97372d07e98d48828ae345412cc311bd4113" diff --git a/Cargo.toml b/Cargo.toml index 0c3147bf..9937303b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,8 +17,10 @@ version = "1.7.2" memory-regions = { path = "components/memory-regions" } # forked -admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.13" } +admin-app = { git = "https://github.com/Nitrokey/admin-app.git", rev = "2bcefb3dda021a7e815016bf4f0719a84af13d3f" } +cbor-smol = { git = "https://github.com/Nitrokey/cbor-smol.git", tag = "v0.4.0-nitrokey.5" } fido-authenticator = { git = "https://github.com/Nitrokey/fido-authenticator.git", tag = "v0.1.1-nitrokey.20" } +lpc55-hal = { git = "https://github.com/Nitrokey/lpc55-hal", tag = "v0.3.0-nitrokey.2" } trussed = { git = "https://github.com/nitrokey/trussed.git", tag = "v0.1.0-nitrokey.21" } # unreleased upstream changes diff --git a/components/apps/Cargo.toml b/components/apps/Cargo.toml index 5ce688ef..2b88b7f2 100644 --- a/components/apps/Cargo.toml +++ b/components/apps/Cargo.toml @@ -10,6 +10,7 @@ bitflags = "2" ctaphid-dispatch = "0.1" embedded-hal = "0.2.7" heapless = "0.7" +heapless-bytes = "0.3" se05x = { version = "0.1.1", optional = true} serde = { version = "1.0.180", default-features = false } trussed = { version = "0.1", features = ["serde-extensions"] } diff --git a/components/apps/src/lib.rs b/components/apps/src/lib.rs index 9495156c..0dc8cffb 100644 --- a/components/apps/src/lib.rs +++ b/components/apps/src/lib.rs @@ -19,6 +19,7 @@ use littlefs2::path; #[cfg(feature = "factory-reset")] use admin_app::ResetConfigResult; +use admin_app::{ConfigField, FieldType}; #[macro_use] extern crate delog; @@ -82,6 +83,26 @@ impl admin_app::Config for Config { } } + fn list_available_fields(&self) -> &'static [ConfigField] { + &[ + ConfigField { + name: "fido.disable_skip_up_timeout", + requires_touch_confirmation: false, + requires_reboot: false, + destructive: false, + ty: FieldType::Bool, + }, + #[cfg(feature = "se050")] + ConfigField { + name: "opcard.use_se050_backend", + requires_touch_confirmation: true, + requires_reboot: true, + destructive: true, + ty: FieldType::Bool, + }, + ] + } + fn reset_client_id( &self, key: &str, @@ -1104,7 +1125,7 @@ impl App for ProvisionerApp { #[cfg(test)] mod tests { use super::{Config, FidoConfig, OpcardConfig}; - use cbor_smol::{cbor_serialize_bytes, Bytes}; + use cbor_smol::cbor_serialize_bytes; #[test] fn test_config_size() { @@ -1118,7 +1139,7 @@ mod tests { }, fs_version: 1, }; - let data: Bytes<1024> = cbor_serialize_bytes(&config).unwrap(); + let data: heapless_bytes::Bytes<1024> = cbor_serialize_bytes(&config).unwrap(); // littlefs2 is most efficient with files < 1/4 of the block size. The block sizes are 512 // bytes for LPC55 and 256 bytes for NRF52. As the block count is only problematic on the // LPC55, this could be increased to 128 if necessary.