Merge pull request #223 from harmony-one/clean_file_input

[keys] Improve passphrase sanitization when read from file
pull/225/head
Daniel Van Der Maden 5 years ago committed by GitHub
commit fbb058cda5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      cmd/subcommands/keys.go
  2. 1
      pkg/keys/bls.go

@ -53,7 +53,9 @@ func getPassphrase() (string, error) {
if err != nil {
return "", err
}
pw := strings.TrimSuffix(string(dat), "\n")
pw := strings.ReplaceAll(string(dat), "\n", "")
pw = strings.ReplaceAll(pw, "\t", "")
pw = strings.TrimSpace(pw)
return pw, nil
} else if userProvidesPassphrase {
fmt.Println("Enter wallet keystore passphrase:")

@ -208,6 +208,7 @@ func VerifyBLS(blsPubKey string, blsPubKeyDir string) (shard.BLSSignature, error
}
cleanPass := strings.TrimSpace(string(pass))
cleanPass = strings.ReplaceAll(cleanPass, "\t", "")
decryptedPrivateKeyBytes, err := decrypt(encryptedPrivateKeyBytes, cleanPass)
if err != nil {
return sig, err

Loading…
Cancel
Save