From d16dc8d4b9b079bd5410c45a6b3f456f1fe33d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Wed, 15 Nov 2023 18:06:41 +0100 Subject: [PATCH] Allow factory-resetting opcard from admin-app --- Cargo.lock | 3 ++- Cargo.toml | 2 +- components/apps/src/lib.rs | 13 ++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8e917fee..1870a1bc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2176,8 +2176,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "opcard" version = "1.2.0" -source = "git+https://github.com/Nitrokey/opcard-rs?tag=v1.2.0#ad61078c4653d0daa0512bf1a8466bbba7039edc" +source = "git+https://github.com/Nitrokey/opcard-rs?rev=b8ba8f5e70076533ce8c6d92b0666a0b24f5595e#b8ba8f5e70076533ce8c6d92b0666a0b24f5595e" dependencies = [ + "admin-app", "apdu-dispatch", "delog", "heapless 0.7.16", diff --git a/Cargo.toml b/Cargo.toml index daa5d90de..2bfd077b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ littlefs2 = { git = "https://github.com/trussed-dev/littlefs2", rev = "e6c46e7ba # unreleased crates secrets-app = { git = "https://github.com/Nitrokey/trussed-secrets-app", tag = "v0.13.0-rc2" } webcrypt = { git = "https://github.com/nitrokey/nitrokey-websmartcard-rust", tag = "v0.8.0-rc4"} -opcard = { git = "https://github.com/Nitrokey/opcard-rs", tag = "v1.2.0" } +opcard = { git = "https://github.com/Nitrokey/opcard-rs", rev = "b8ba8f5e70076533ce8c6d92b0666a0b24f5595e" } piv-authenticator = { git = "https://github.com/Nitrokey/piv-authenticator", tag = "v0.3.3" } se05x = { git = "https://github.com/Nitrokey/se05x.git", tag = "v0.1.0"} trussed-auth = { git = "https://github.com/trussed-dev/trussed-auth", rev = "62235294bd63977bbb88eb01e7ac44b8010eb450" } diff --git a/components/apps/src/lib.rs b/components/apps/src/lib.rs index d3035c173..96b389d95 100644 --- a/components/apps/src/lib.rs +++ b/components/apps/src/lib.rs @@ -56,8 +56,11 @@ impl admin_app::Config for Config { None } - fn can_reset(&self, _client: &str) -> Option<&'static ResetSignalAllocation> { - None + fn can_reset(&self, client: &str) -> Option<&'static ResetSignalAllocation> { + match client { + "opcard" => Some(&OPCARD_RESET_SIGNAL), + _ => None, + } } } @@ -533,6 +536,8 @@ impl App for SecretsApp { } } +static OPCARD_RESET_SIGNAL: ResetSignalAllocation = ResetSignalAllocation::new(); + #[cfg(feature = "opcard")] impl App for OpcardApp { const CLIENT_ID: &'static str = "opcard"; @@ -548,7 +553,9 @@ impl App for OpcardApp { options.manufacturer = 0x000Fu16.to_be_bytes(); options.serial = [uuid[0], uuid[1], uuid[2], uuid[3]]; options.storage = trussed::types::Location::External; - Self::new(trussed, options) + let mut card = Self::new(trussed, options); + card.set_reset_signal(Some(&OPCARD_RESET_SIGNAL)); + card } fn backends(runner: &R, _: &()) -> &'static [BackendId] { const BACKENDS_OPCARD: &[BackendId] = &[