Skip to content

Commit

Permalink
Support full Yubico OATH AID
Browse files Browse the repository at this point in the history
The full AID is used by eg. Yubico Authenticator on Android, which
previously would not recognise the Trussed OATH implementation.
  • Loading branch information
abrasive committed Jul 4, 2022
1 parent 4b680a3 commit 02edced
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ impl<'l> Credential<'l> {

impl<T> iso7816::App for Authenticator<T> {
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)
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,10 @@ impl<'l, const C: usize> TryFrom<&'l iso7816::Command<C>> for Command<'l> {
impl<'l, const C: usize> TryFrom<&'l Data<C>> for Select<'l> {
type Error = Status;
fn try_from(data: &'l Data<C>) -> Result<Self, Self::Error> {
// 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)
}
}

3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 02edced

Please sign in to comment.