Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Error string in decryptPrivKey. Use errors.As in IsErrWrongPassword. #1289

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tm2/pkg/crypto/keys/armor/armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privK
}
key = crypto.Sha256(key) // Get 32 bytes
privKeyBytes, err := xsalsa20symmetric.DecryptSymmetric(encBytes, key)
if err != nil && err.Error() == "Ciphertext decryption failed" {
if err != nil && err.Error() == "ciphertext decryption failed" {
return privKey, keyerror.NewErrWrongPassword()
} else if err != nil {
return privKey, err
Expand Down
7 changes: 5 additions & 2 deletions tm2/pkg/crypto/keys/keyerror/errors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keyerror

import (
"errors"
"fmt"
)

Expand Down Expand Up @@ -40,7 +41,8 @@ func IsErrKeyNotFound(err error) bool {
if err == nil {
return false
}
if keyErr, ok := err.(keybaseError); ok {
var keyErr keybaseError
if errors.As(err, &keyErr) {
if keyErr.Code() == codeKeyNotFound {
return true
}
Expand Down Expand Up @@ -72,7 +74,8 @@ func IsErrWrongPassword(err error) bool {
if err == nil {
return false
}
if keyErr, ok := err.(keybaseError); ok {
var keyErr keybaseError
if errors.As(err, &keyErr) {
if keyErr.Code() == codeWrongPassword {
return true
}
Expand Down
Loading