Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error type for third invalid PIN entry #60

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/ctap2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,12 +1185,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
self.state
.runtime
.rotate_key_agreement_key(&mut self.trussed);
if self.state.persistent.retries() == 0 {
return Err(Error::PinBlocked);
}
if self.state.persistent.pin_blocked() {
return Err(Error::PinAuthBlocked);
}
self.state.pin_blocked()?;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having 3 methods in state.rs called pin_blocked is confusing. Makes me wish for jump to definition in code review

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was confused by the very same and had to look it up manually - but still makes sense as it is I guess

return Err(Error::PinInvalid);
}

Expand Down
2 changes: 1 addition & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl PersistentState {
}

pub fn retries(&self) -> u8 {
Self::RESET_RETRIES - self.consecutive_pin_mismatches
Self::RESET_RETRIES.saturating_sub(self.consecutive_pin_mismatches)
}

pub fn pin_blocked(&self) -> bool {
Expand Down