Skip to content

Commit

Permalink
fixup! Use apdu-app instead of apdu-dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed Oct 21, 2024
1 parent 93f54e9 commit 4306c92
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
24 changes: 6 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
26 changes: 19 additions & 7 deletions examples/usbip/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -340,12 +341,12 @@ impl TryFrom<u8> 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 {}

Expand Down Expand Up @@ -427,6 +428,7 @@ pub struct AdminData {
pub efs_blocks: u16,
pub variant: Variant,
}

impl AdminData {
pub fn new(variant: Variant) -> Self {
Self {
Expand All @@ -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,
Expand All @@ -456,7 +467,7 @@ type FidoAuthApp = fido_authenticator::Authenticator<fido_authenticator::Conform
type WebcryptApp = webcrypt::Webcrypt<VirtClient>;

struct Apps {
admin: admin_app::App<VirtClient, Reboot, AdminStatus, ()>,
admin: admin_app::App<VirtClient, Reboot, AdminData, ()>,
peeking_fido: PeekingBypass<'static, FidoAuthApp, WebcryptApp>,
}

Expand All @@ -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(
Expand Down

0 comments on commit 4306c92

Please sign in to comment.