From 288fc030d16c137a482caf3a76146dca1b9ade3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Wed, 8 Nov 2023 11:46:12 +0100 Subject: [PATCH] Update apdu-dispatch This allows rejecting calls to `Select` over CCID --- Cargo.toml | 1 + src/dispatch/apdu.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a81630d..9e82879 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,5 +47,6 @@ features = ["dispatch"] [patch.crates-io] ctap-types = { git = "https://github.com/nitrokey/ctap-types.git", tag = "v0.1.2-nitrokey.4" } ctaphid-dispatch = { git = "https://github.com/trussed-dev/ctaphid-dispatch.git", rev = "57cb3317878a8593847595319aa03ef17c29ec5b" } +apdu-dispatch = { git = "https://github.com/trussed-dev/apdu-dispatch.git", rev = "915fc237103fcecc29d0f0b73391f19abf6576de" } trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "51e68500d7601d04f884f5e95567d14b9018a6cb" } serde-indexed = { git = "https://github.com/sosthene-nitrokey/serde-indexed.git", rev = "5005d23cb4ee8622e62188ea0f9466146f851f0d" } diff --git a/src/dispatch/apdu.rs b/src/dispatch/apdu.rs index cbc2ed4..2b233f3 100644 --- a/src/dispatch/apdu.rs +++ b/src/dispatch/apdu.rs @@ -1,4 +1,4 @@ -use apdu_dispatch::{app as apdu, response::Data, Command}; +use apdu_dispatch::{app as apdu, dispatch::Interface, response::Data, Command}; use ctap_types::{serde::error::Error as SerdeError, Error}; use ctaphid_dispatch::app as ctaphid; use iso7816::Status; @@ -28,7 +28,13 @@ where UP: UserPresence, T: TrussedRequirements, { - fn select(&mut self, _: &Command, reply: &mut Data) -> apdu::Result { + fn select(&mut self, interface: Interface, _: &Command, reply: &mut Data) -> apdu::Result { + // FIDO-over-CCID does not seem to officially be a thing; we don't support it. + // If we would, need to review the following cases catering to semi-documented U2F legacy. + if interface != apdu::Interface::Contactless { + return Err(Status::ConditionsOfUseNotSatisfied); + } + reply.extend_from_slice(b"U2F_V2").unwrap(); Ok(()) }