From 02edced79b0f5acee1d86865e63f1412ec46e554 Mon Sep 17 00:00:00 2001 From: James Wah Date: Mon, 4 Jul 2022 10:20:52 +1000 Subject: [PATCH] Support full Yubico OATH AID The full AID is used by eg. Yubico Authenticator on Android, which previously would not recognise the Trussed OATH implementation. --- src/authenticator.rs | 2 +- src/command.rs | 9 ++++----- src/lib.rs | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/authenticator.rs b/src/authenticator.rs index 3df8e0781d..606b49a21f 100644 --- a/src/authenticator.rs +++ b/src/authenticator.rs @@ -754,7 +754,7 @@ impl<'l> Credential<'l> { impl iso7816::App for Authenticator { fn aid(&self) -> iso7816::Aid { - iso7816::Aid::new(&crate::YUBICO_OATH_AID) + iso7816::Aid::new_truncatable(&crate::YUBICO_OATH_AID, crate::YUBICO_OATH_AID_TRUNCATED_LEN) } } diff --git a/src/command.rs b/src/command.rs index a2b80f3c66..8537ab16ea 100644 --- a/src/command.rs +++ b/src/command.rs @@ -384,11 +384,10 @@ impl<'l, const C: usize> TryFrom<&'l iso7816::Command> for Command<'l> { impl<'l, const C: usize> TryFrom<&'l Data> for Select<'l> { type Error = Status; fn try_from(data: &'l Data) -> Result { - // info_now!("comparing {} against {}", hex_str!(data.as_slice()), hex_str!(crate::YUBICO_OATH_AID)); - Ok(match data.as_slice() { - crate::YUBICO_OATH_AID => Self { aid: data }, - _ => return Err(Status::NotFound), - }) + if crate::YUBICO_OATH_AID.starts_with(data.as_slice()) { + return Ok(Self { aid: data}); + } + Err(Status::NotFound) } } diff --git a/src/lib.rs b/src/lib.rs index 0713ff3feb..7eb61821bd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,8 @@ pub mod state; pub const YUBICO_RID: [u8; 5] = hex!("A000000 527"); // pub const YUBICO_OTP_PIX: [u8; 3] = hex!("200101"); // pub const YUBICO_OTP_AID: &[u8] = &hex!("A000000527 2001 01"); -pub const YUBICO_OATH_AID: &[u8] = &hex!("A000000527 2101");// 01"); +pub const YUBICO_OATH_AID: &[u8] = &hex!("A000000527 2101 01"); +pub const YUBICO_OATH_AID_TRUNCATED_LEN: usize = 7; // class AID(bytes, Enum): // OTP = b'\xa0\x00\x00\x05\x27 \x20\x01'