Skip to content

Commit 5ebb4a4

Browse files
clientPin: Support getRetries without PIN protocol
This fixes compatibility with CTAP 2.1. Fixes: #118
1 parent 4554cb8 commit 5ebb4a4

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ required-features = ["dispatch"]
1616

1717
[dependencies]
1818
cbor-smol = { version = "0.5" }
19-
ctap-types = { version = "0.3.1", features = ["get-info-full", "large-blobs", "third-party-payment"] }
19+
ctap-types = { version = "0.4", features = ["get-info-full", "large-blobs", "third-party-payment"] }
2020
cosey = "0.3"
2121
delog = "0.1.0"
2222
heapless = "0.7"

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2021"
88
cargo-fuzz = true
99

1010
[dependencies]
11-
ctap-types = { version = "0.3.0", features = ["arbitrary"] }
11+
ctap-types = { version = "0.4", features = ["arbitrary"] }
1212
libfuzzer-sys = "0.4"
1313
trussed = { version = "0.1", features = ["clients-1", "certificate-client", "crypto-client", "filesystem-client", "management-client", "aes256-cbc", "ed255", "p256", "sha256"] }
1414
trussed-staging = { version = "0.3.0", features = ["chunked", "hkdf", "virt", "fs-info"] }

src/ctap2.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,10 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
530530
debug_now!("CTAP2.PIN...");
531531
// info_now!("{:?}", parameters);
532532

533-
let pin_protocol = self.parse_pin_protocol(parameters.pin_protocol)?;
533+
let pin_protocol = parameters
534+
.pin_protocol
535+
.ok_or(Error::MissingParameter)
536+
.and_then(|pin_protocol| self.parse_pin_protocol(pin_protocol));
534537
let mut response = ctap2::client_pin::Response::default();
535538

536539
match parameters.sub_command {
@@ -543,6 +546,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
543546
Subcommand::GetKeyAgreement => {
544547
debug_now!("CTAP2.Pin.GetKeyAgreement");
545548

549+
let pin_protocol = pin_protocol?;
546550
response.key_agreement = Some(self.pin_protocol(pin_protocol).key_agreement_key());
547551
}
548552

@@ -567,6 +571,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
567571
return Err(Error::MissingParameter);
568572
}
569573
};
574+
let pin_protocol = pin_protocol?;
570575

571576
// 2. is pin already set
572577
if self.state.persistent.pin_is_set() {
@@ -624,6 +629,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
624629
return Err(Error::MissingParameter);
625630
}
626631
};
632+
let pin_protocol = pin_protocol?;
627633

628634
// 2. fail if no retries left
629635
self.state.pin_blocked()?;
@@ -679,7 +685,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
679685
.ok_or(Error::MissingParameter)?;
680686

681687
// 2. Check PIN protocol
682-
let pin_protocol = self.parse_pin_protocol(parameters.pin_protocol)?;
688+
let pin_protocol = pin_protocol?;
683689

684690
// 3. + 4. Check invalid parameters
685691
if parameters.permissions.is_some() || parameters.rp_id.is_some() {
@@ -744,7 +750,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
744750
let permissions = parameters.permissions.ok_or(Error::MissingParameter)?;
745751

746752
// 2. Check PIN protocol
747-
let pin_protocol = self.parse_pin_protocol(parameters.pin_protocol)?;
753+
let pin_protocol = pin_protocol?;
748754

749755
// 3. Check that permissions are not empty
750756
let permissions = Permissions::from_bits_truncate(permissions);

0 commit comments

Comments
 (0)