Skip to content

Commit

Permalink
test nano key
Browse files Browse the repository at this point in the history
  • Loading branch information
micolous committed Jan 29, 2024
1 parent 6b04076 commit bdfe711
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 0 additions & 2 deletions webauthn-authenticator-rs/src/tlv/ber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ impl<'a> Iterator for BerTlvParser<'a> {
// 5.2.2.1: BER-TLV tag fields
let class = self.b[0] >> 5;
let mut tag = u16::from(self.b[0] & 0x1f);
// trace!(?class, ?tag);
self.b = &self.b[1..];
if tag == 0x1f {
self.stop_if_empty()?;
Expand Down Expand Up @@ -130,7 +129,6 @@ impl<'a> Iterator for BerTlvParser<'a> {
return None;
}
};
// info!(?len);

let len = len as usize;
self.stop_and_brick_if_less_than(len)?;
Expand Down
28 changes: 27 additions & 1 deletion webauthn-authenticator-rs/src/transport/yubikey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ impl YubiKeyConfig {
let parser = BerTlvParser::new(&b[1..]);

for (cls, tag, val) in parser {
// trace!(?cls, ?tag, ?val);
if cls != 0 {
continue;
}
Expand Down Expand Up @@ -432,6 +431,33 @@ mod tests {
assert_eq!(expected, cfg);
}

#[test]
fn yubikey_5c_nano() {
let _ = tracing_subscriber::fmt().try_init();
let expected = YubiKeyConfig {
serial: Some(0xcafe1234),
form_factor: FormFactor::UsbCNano,
version: [5, 2, 4],
supported_usb_interfaces: Interface::OTP
| Interface::CTAP1
| Interface::CTAP2
| Interface::OPENPGP
| Interface::PIV
| Interface::OATH,
enabled_usb_interfaces: Interface::CTAP1 | Interface::CTAP2,
supported_nfc_interfaces: Interface::empty(),
enabled_nfc_interfaces: Interface::empty(),
auto_eject_timeout: 0,
challenge_response_timeout: 15,
..Default::default()
};
let v =
hex::decode("260102023f030202020204cafe123404010405030502040602000007010f0801000a01000f0100")
.unwrap();
let cfg = YubiKeyConfig::from_bytes(v.as_slice()).unwrap();
assert_eq!(expected, cfg);
}

#[test]
fn yubico_security_key_c_nfc() {
let _ = tracing_subscriber::fmt().try_init();
Expand Down

0 comments on commit bdfe711

Please sign in to comment.