diff --git a/flow_commands.go b/flow_commands.go index 61a0a5b..4e42854 100644 --- a/flow_commands.go +++ b/flow_commands.go @@ -173,7 +173,7 @@ func (f *KeycardFlow) unblockPIN(kc *keycardContext) error { return nil } else if isSCardError(err) { return restartErr() - } else if leftRetries, ok := getPinRetries(err); ok { + } else if leftRetries, ok := getRetries(err); ok { f.cardInfo.pukRetries = leftRetries delete(f.params, PUK) pukOK = false @@ -199,7 +199,7 @@ func (f *KeycardFlow) authenticate(kc *keycardContext) error { if f.cardInfo.pukRetries == 0 { return f.pauseAndRestart(SwapCard, PUKRetries) } else if f.cardInfo.pinRetries == 0 { - // succesful PUK unblock leaves the card authenticated + // succesful unblock leaves the card authenticated return f.unblockPIN(kc) } @@ -213,7 +213,7 @@ func (f *KeycardFlow) authenticate(kc *keycardContext) error { return nil } else if isSCardError(err) { return restartErr() - } else if leftRetries, ok := getPinRetries(err); ok { + } else if leftRetries, ok := getRetries(err); ok { f.cardInfo.pinRetries = leftRetries delete(f.params, PIN) } diff --git a/utils.go b/utils.go index 468c986..0b67eda 100644 --- a/utils.go +++ b/utils.go @@ -33,9 +33,11 @@ func isSCardError(err error) bool { return ok } -func getPinRetries(err error) (int, bool) { +func getRetries(err error) (int, bool) { if wrongPIN, ok := err.(*keycard.WrongPINError); ok { return wrongPIN.RemainingAttempts, ok + } else if wrongPUK, ok := err.(*keycard.WrongPUKError); ok { + return wrongPUK.RemainingAttempts, ok } else { return 0, false }