From 4306c920e509b1ccc71328d79bae215c6b03e8e1 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 21 Oct 2024 10:45:34 +0200 Subject: [PATCH] fixup! Use apdu-app instead of apdu-dispatch --- Cargo.lock | 24 ++++++------------------ Cargo.toml | 9 ++++++--- examples/usbip/main.rs | 26 +++++++++++++++++++------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0309f4a..8411d13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,9 +5,9 @@ version = 3 [[package]] name = "admin-app" version = "0.1.0" -source = "git+https://github.com/Nitrokey/admin-app.git?tag=v0.1.0-nitrokey.11#0ba0e766cba65a1fe7b0865f343de589e4202d82" +source = "git+https://github.com/Nitrokey/admin-app.git?branch=apdu-app#21ddbf12a3a5f60916c4a47e1bf3e49ce5cf03cd" dependencies = [ - "apdu-dispatch", + "apdu-app", "cbor-smol", "ctaphid-dispatch", "delog", @@ -60,18 +60,6 @@ dependencies = [ "iso7816", ] -[[package]] -name = "apdu-dispatch" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898c4ae30eeab17a209d5576cf7b312fdbee4d1cb739333c1308908fc841a5fb" -dependencies = [ - "delog", - "heapless", - "interchange 0.2.2", - "iso7816", -] - [[package]] name = "atomic-polyfill" version = "1.0.3" @@ -179,8 +167,8 @@ dependencies = [ [[package]] name = "cbor-smol" -version = "0.4.0" -source = "git+https://github.com/Nitrokey/cbor-smol.git?tag=v0.4.0-nitrokey.4#d6211450a8e29fcf8cd41b01104c32ac15370508" +version = "0.4.1" +source = "git+https://github.com/trussed-dev/cbor-smol.git?rev=d499e527f1214b2998b844720f0d41a9d05be7e1#d499e527f1214b2998b844720f0d41a9d05be7e1" dependencies = [ "delog", "heapless", @@ -586,9 +574,9 @@ dependencies = [ [[package]] name = "fido-authenticator" version = "0.1.1" -source = "git+https://github.com/Nitrokey/fido-authenticator.git?tag=v0.1.1-nitrokey.18#58a8ca1166cdda5dc7119ae393b05f71a16164be" +source = "git+https://github.com/Nitrokey/fido-authenticator.git?branch=apdu-app#629a75f189a3db930070fb19753a9d347afea38d" dependencies = [ - "apdu-dispatch", + "apdu-app", "cbor-smol", "cosey", "ctap-types 0.3.1", diff --git a/Cargo.toml b/Cargo.toml index b3f22c1..cbabd8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,9 +100,12 @@ ctaphid-dispatch = { git = "https://github.com/Nitrokey/ctaphid-dispatch", tag = #apdu-dispatch = { git = "https://github.com/Nitrokey/apdu-dispatch.git", branch="sz-multiple-apps" } # forked -admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.11" } -fido-authenticator = { git = "https://github.com/Nitrokey/fido-authenticator.git", tag = "v0.1.1-nitrokey.18" } -cbor-smol = { git = "https://github.com/Nitrokey/cbor-smol.git", tag = "v0.4.0-nitrokey.4"} +# admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.11" } +admin-app = { git = "https://github.com/Nitrokey/admin-app.git", branch = "apdu-app" } +# fido-authenticator = { git = "https://github.com/Nitrokey/fido-authenticator.git", tag = "v0.1.1-nitrokey.18" } +fido-authenticator = { git = "https://github.com/Nitrokey/fido-authenticator.git", branch = "apdu-app" } +# cbor-smol = { git = "https://github.com/Nitrokey/cbor-smol.git", tag = "v0.4.0-nitrokey.4"} +cbor-smol = { git = "https://github.com/trussed-dev/cbor-smol.git", rev = "d499e527f1214b2998b844720f0d41a9d05be7e1" } # unreleased upstream changes littlefs2 = { git = "https://github.com/sosthene-nitrokey/littlefs2.git", rev = "2b45a7559ff44260c6dd693e4cb61f54ae5efc53" } diff --git a/examples/usbip/main.rs b/examples/usbip/main.rs index c1537cd..6395c82 100644 --- a/examples/usbip/main.rs +++ b/examples/usbip/main.rs @@ -244,6 +244,7 @@ mod dispatch { #[cfg(feature = "ccid")] use apdu_dispatch::command::SIZE as ApduCommandSize; +use admin_app::StatusBytes; use clap::Parser; use clap_num::maybe_hex; use trussed::backend::BackendId; @@ -340,12 +341,12 @@ impl TryFrom for CustomStatus { match value { 0 => Ok(Self::ReverseHotpSuccess), 1 => Ok(Self::ReverseHotpError), - _ => Err(UnknownStatusError(value)), + _ => Err(UnknownStatusError), } } } -pub struct UnknownStatusError(u8); +pub struct UnknownStatusError; impl CustomStatus {} @@ -427,6 +428,7 @@ pub struct AdminData { pub efs_blocks: u16, pub variant: Variant, } + impl AdminData { pub fn new(variant: Variant) -> Self { Self { @@ -438,9 +440,18 @@ impl AdminData { } } -pub type AdminStatus = [u8; 5]; -impl AdminData { - fn encode(&self) -> AdminStatus { +impl StatusBytes for AdminData { + type Serialized = [u8; 5]; + + fn set_random_error(&mut self, _value: bool) { + unimplemented!(); + } + + fn get_random_error(&self) -> bool { + false + } + + fn serialize(&self) -> Self::Serialized { let efs_blocks = self.efs_blocks.to_be_bytes(); [ self.init_status, @@ -456,7 +467,7 @@ type FidoAuthApp = fido_authenticator::Authenticator; struct Apps { - admin: admin_app::App, + admin: admin_app::App, peeking_fido: PeekingBypass<'static, FidoAuthApp, WebcryptApp>, } @@ -482,7 +493,8 @@ impl trussed_usbip::Apps<'static, VirtClient, dispatch::Dispatch> for Apps { [0; 16], 0, "", - data.encode(), + data, + &[], ); let webcrypt = webcrypt::Webcrypt::new_with_options(