|
|
@ -73,6 +73,14 @@ var ( |
|
|
|
DerivationSignatureHash = sha256.Sum256(common.Hash{}.Bytes()) |
|
|
|
DerivationSignatureHash = sha256.Sum256(common.Hash{}.Bytes()) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
|
|
|
// PinRegexp is the regular expression used to validate PIN codes.
|
|
|
|
|
|
|
|
pinRegexp = regexp.MustCompile(`^[0-9]{6,}$`) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PukRegexp is the regular expression used to validate PUK codes.
|
|
|
|
|
|
|
|
pukRegexp = regexp.MustCompile(`^[0-9]{12,}$`) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// List of APDU command-related constants
|
|
|
|
// List of APDU command-related constants
|
|
|
|
const ( |
|
|
|
const ( |
|
|
|
claISO7816 = 0 |
|
|
|
claISO7816 = 0 |
|
|
@ -380,7 +388,7 @@ func (w *Wallet) Open(passphrase string) error { |
|
|
|
case passphrase == "": |
|
|
|
case passphrase == "": |
|
|
|
return ErrPINUnblockNeeded |
|
|
|
return ErrPINUnblockNeeded |
|
|
|
case status.PinRetryCount > 0: |
|
|
|
case status.PinRetryCount > 0: |
|
|
|
if !regexp.MustCompile(`^[0-9]{6,}$`).MatchString(passphrase) { |
|
|
|
if !pinRegexp.MatchString(passphrase) { |
|
|
|
w.log.Error("PIN needs to be at least 6 digits") |
|
|
|
w.log.Error("PIN needs to be at least 6 digits") |
|
|
|
return ErrPINNeeded |
|
|
|
return ErrPINNeeded |
|
|
|
} |
|
|
|
} |
|
|
@ -388,7 +396,7 @@ func (w *Wallet) Open(passphrase string) error { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
if !regexp.MustCompile(`^[0-9]{12,}$`).MatchString(passphrase) { |
|
|
|
if !pukRegexp.MatchString(passphrase) { |
|
|
|
w.log.Error("PUK needs to be at least 12 digits") |
|
|
|
w.log.Error("PUK needs to be at least 12 digits") |
|
|
|
return ErrPINUnblockNeeded |
|
|
|
return ErrPINUnblockNeeded |
|
|
|
} |
|
|
|
} |
|
|
|