Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add selection of interface so that Opcard only accept one of them. #167

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ log-warn = []
log-error = []

[patch.crates-io]
iso7816 = { git = "https://github.com/Nitrokey/iso7816.git", tag = "v0.1.1-nitrokey.1" }
apdu-dispatch = { git = "https://github.com/trussed-dev/apdu-dispatch.git", rev = "3c6722d01bb9aea13b1b7a1fb0d5ec23d5a39d6a" }
iso7816 = { git = "https://github.com/Nitrokey/iso7816.git", rev = "82971bac269205dec7e6d0d371306f76b5d77442" }
p256-cortex-m4 = { git = "https://github.com/Nitrokey/p256-cortex-m4", tag = "v0.1.0-alpha.6-nitrokey-1" }
trussed = { git = "https://github.com/trussed-dev/trussed" , rev = "55ea391367fce4bf5093ff2d3c79041d7aef0485" }
trussed-auth = { git = "https://github.com/trussed-dev/trussed-auth.git", tag = "v0.2.2"}
Expand Down
13 changes: 12 additions & 1 deletion src/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,25 @@ 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> {
if interface != self.options.interface {
return Err(Status::FunctionNotSupported);
}
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> {
if interface != self.options.interface {
return Err(Status::FunctionNotSupported);
}
self.handle(command, reply)
}

Expand All @@ -128,6 +135,9 @@ pub struct Options {
pub button_available: bool,
/// Which trussed storage to use
pub storage: Location,

/// Which Interface should opcard accept calls from (Opcard cannot accept calls from both without being restarted in any circumstance)
pub interface: iso7816::Interface,
}

impl Options {
Expand Down Expand Up @@ -166,6 +176,7 @@ impl Default for Options {
historical_bytes: heapless::Vec::from_slice(&hex!("0031F573C00160009000")).unwrap(),
button_available: true,
storage: Location::External,
interface: iso7816::Interface::Contact,
}
}
}
Expand Down