Skip to content

Commit

Permalink
Allow three instead of two PIN retries per boot
Browse files Browse the repository at this point in the history
Previously, a PinAuthBlocked error was already returned after two wrong
PIN entries. The reason for this as that decrement_retries also checks
if the allowed retries are exceeded. This as unnecessary because
pin_blocked is always checked before decrement_retries is called.

This patch removes the check in decrement_retries.

Fixes: trussed-dev#35
  • Loading branch information
robin-nitrokey authored and nickray committed Sep 13, 2023
1 parent 492ec63 commit 713c5e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Ignore public key credential parameters with an unknown type, as required by
the Webauthn spec ([#28][])
- Ignore user data with empty ID in getAssertion ([#32][])
- Allow three instead of two PIN retries per boot ([#35][])

[#26]: https://github.com/solokeys/fido-authenticator/issues/26
[#28]: https://github.com/solokeys/fido-authenticator/issues/28
[#32]: https://github.com/solokeys/fido-authenticator/issues/32
[#35]: https://github.com/solokeys/fido-authenticator/issues/35

## [0.1.1] - 2022-08-22
- Fix bug that treated U2F payloads as APDU over APDU in NFC transport @conorpp
Expand Down
9 changes: 2 additions & 7 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl State {

pub fn decrement_retries<T: TrussedClient>(&mut self, trussed: &mut T) -> Result<()> {
self.persistent.decrement_retries(trussed)?;
self.runtime.decrement_retries()?;
self.runtime.decrement_retries();
Ok(())
}

Expand Down Expand Up @@ -452,15 +452,10 @@ impl PersistentState {
impl RuntimeState {
const POWERCYCLE_RETRIES: u8 = 3;

fn decrement_retries(&mut self) -> Result<()> {
fn decrement_retries(&mut self) {
if self.consecutive_pin_mismatches < Self::POWERCYCLE_RETRIES {
self.consecutive_pin_mismatches += 1;
}
if self.consecutive_pin_mismatches == Self::POWERCYCLE_RETRIES {
Err(Error::PinAuthBlocked)
} else {
Ok(())
}
}

fn reset_retries(&mut self) {
Expand Down

0 comments on commit 713c5e7

Please sign in to comment.