diff --git a/Cargo.toml b/Cargo.toml index 0cbbc65..1df8af0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,6 +78,7 @@ 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/trussed-dev/trussed-rsa-backend.git", tag = "v0.1.0"} trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging", tag = "v0.1.0" } +apdu-dispatch = { git = "https://github.com/trussed-dev/apdu-dispatch.git", rev = "915fc237103fcecc29d0f0b73391f19abf6576de" } [profile.dev.package.rsa] opt-level = 2 diff --git a/src/dispatch.rs b/src/dispatch.rs index 6f20256..ade26b9 100644 --- a/src/dispatch.rs +++ b/src/dispatch.rs @@ -1,13 +1,22 @@ use crate::{reply::Reply, Authenticator, /*constants::PIV_AID,*/ Result}; use apdu_dispatch::{app::App, command, response, Command}; +use iso7816::{Interface, Status}; #[cfg(feature = "apdu-dispatch")] impl App<{ command::SIZE }, { response::SIZE }> for Authenticator where T: crate::Client, { - fn select(&mut self, _apdu: &Command, reply: &mut response::Data) -> Result { + fn select( + &mut self, + interface: Interface, + _apdu: &Command, + reply: &mut response::Data, + ) -> Result { + if interface != Interface::Contact { + return Err(Status::ConditionsOfUseNotSatisfied); + } self.select(Reply(reply)) } @@ -15,12 +24,10 @@ where self.deselect() } - fn call( - &mut self, - _: iso7816::Interface, - apdu: &Command, - reply: &mut response::Data, - ) -> Result { + fn call(&mut self, interface: Interface, apdu: &Command, reply: &mut response::Data) -> Result { + if interface != Interface::Contact { + return Err(Status::ConditionsOfUseNotSatisfied); + } self.respond(apdu, &mut Reply(reply)) } }