Skip to content

Commit

Permalink
Update apdu-dispatch and reject calls from contactless interface
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Nov 8, 2023
1 parent ad49691 commit 90a1bbc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ serde_cbor = "0.11"
hex = { version = "0.4", features = ["serde"] }

# usbip
trussed-usbip = { git = "https://github.com/trussed-dev/pc-usbip-runner", default-features = false, features = ["ccid"], rev = "f3a680ca4c9a1411838ae0774f1713f79d4c2979" }
trussed-usbip = { version = "0.0.1", default-features = false, features = ["ccid"] }

[features]
default = []
Expand Down Expand Up @@ -92,6 +92,9 @@ trussed = { git = "https://github.com/trussed-dev/trussed" , rev = "55ea391367fc
trussed-auth = { git = "https://github.com/trussed-dev/trussed-auth.git", tag = "v0.2.2"}
trussed-rsa-alloc = { git = "https://github.com/Nitrokey/trussed-rsa-backend", tag = "v0.1.0" }
trussed-staging = { git = "https://github.com/Nitrokey/trussed-staging", tag = "v0.1.0" }
apdu-dispatch = { git = "https://github.com/trussed-dev/apdu-dispatch", rev = "2a4a3eda992da897894c8c00a6388567a0013993" }
trussed-usbip = { git = "https://github.com/Nitrokey/pc-usbip-runner.git", rev = "43655c47e13687f96fab607e6f06b331538c6bfc" }
usbd-ccid = { git = "https://github.com/trussed-dev/usbd-ccid", rev = "eeea54f85cfa69a43c676b63c030608830ea35ea" }

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion examples/usbip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct OpcardApp {
opcard: opcard::Card<VirtClient>,
}

impl trussed_usbip::Apps<VirtClient, Dispatch> for OpcardApp {
impl trussed_usbip::Apps<'_, VirtClient, Dispatch> for OpcardApp {
type Data = ();
fn new<B: ClientBuilder<VirtClient, Dispatch>>(builder: &B, _data: ()) -> Self {
OpcardApp {
Expand Down
11 changes: 10 additions & 1 deletion src/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,27 @@ impl<T: Client> iso7816::App for Card<T> {
impl<T: Client, const C: usize, const R: usize> apdu_dispatch::App<C, R> for Card<T> {
fn select(
&mut self,
interface: apdu_dispatch::dispatch::Interface,
command: &iso7816::Command<C>,
reply: &mut heapless::Vec<u8, R>,
) -> Result<(), Status> {
use apdu_dispatch::dispatch::Interface;
if interface != Interface::Contact {
return Err(Status::ConditionsOfUseNotSatisfied);
}
self.handle(command, reply)
}

fn call(
&mut self,
_interface: apdu_dispatch::dispatch::Interface,
interface: apdu_dispatch::dispatch::Interface,
command: &iso7816::Command<C>,
reply: &mut heapless::Vec<u8, R>,
) -> Result<(), Status> {
use apdu_dispatch::dispatch::Interface;
if interface != Interface::Contact {
return Err(Status::ConditionsOfUseNotSatisfied);
}
self.handle(command, reply)
}

Expand Down

0 comments on commit 90a1bbc

Please sign in to comment.