Make PIN verification failure a StatusWord case

Retry count is now u8, as  it cannot exceed 16 (being returned in the
lower half of SW2).
This commit is contained in:
Jack Grigg
2019-11-30 15:22:14 +00:00
parent 9fe363661e
commit 4b5cd8dd45
4 changed files with 16 additions and 15 deletions
+2 -2
View File
@@ -184,7 +184,7 @@ impl<'tx> Transaction<'tx> {
match response.status_words() {
StatusWords::Success => Ok(()),
StatusWords::AuthBlockedError => Err(Error::WrongPin { tries: 0 }),
StatusWords::Other(sw) if sw >> 8 == 0x63 => Err(Error::WrongPin { tries: sw & 0xf }),
StatusWords::VerifyFailError { tries } => Err(Error::WrongPin { tries }),
_ => Err(Error::GenericError),
}
}
@@ -215,7 +215,7 @@ impl<'tx> Transaction<'tx> {
match status_words {
StatusWords::Success => Ok(()),
StatusWords::AuthBlockedError => Err(Error::PinLocked),
StatusWords::Other(sw) if sw >> 8 == 0x63 => Err(Error::WrongPin { tries: sw & 0xf }),
StatusWords::VerifyFailError { tries } => Err(Error::WrongPin { tries }),
_ => {
error!(
"failed changing pin, token response code: {:x}.",