mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-01-18 18:31:56 +00:00
handle wrongpukerror
This commit is contained in:
parent
a7c15e6c91
commit
19d8b0b3a1
@ -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)
|
||||
}
|
||||
|
4
utils.go
4
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user