Skip to content
Snippets Groups Projects
Commit 5e7f5966 authored by kayrus's avatar kayrus
Browse files

Update putty dependency, fix regression

parent 2c19231c
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ require (
github.com/gophercloud/gophercloud v0.15.1-0.20210205220151-18b16b34db5c
github.com/gophercloud/utils v0.0.0-20210209042946-13abf2251886
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c
github.com/kayrus/putty v1.0.3
github.com/kayrus/putty v1.0.4
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.1
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
......
......@@ -331,9 +331,13 @@ func decodeFields(r reader) (*Key, error) {
} else {
k.PrivateKey = v
}
case "`Private-Hash",
case "Private-Hash",
"Private-MAC":
// read hash or signature
if k.Version == 0 {
return nil, fmt.Errorf("cannot read %q without a header: %v", h, err)
}
k.PrivateMac, err = hex.DecodeString(string(b))
if err != nil {
return nil, fmt.Errorf("failed to decode the %q hex string: %v", h, err)
......@@ -500,6 +504,8 @@ func (k Key) deriveKeys(password []byte) ([]byte, []byte, []byte, error) {
h = argon2.IDKey(password, k.Argon2Salt, k.Argon2Passes, k.Argon2Memory, k.Argon2Parallelism, argon2KeyLength)
case "Argon2i":
h = argon2.Key(password, k.Argon2Salt, k.Argon2Passes, k.Argon2Memory, k.Argon2Parallelism, argon2KeyLength)
case "":
return nil, nil, nil, nil
default:
return nil, nil, nil, fmt.Errorf("%q argon2 key deriviation is not supported", k.KeyDerivation)
}
......@@ -515,20 +521,13 @@ func (k Key) deriveKeys(password []byte) ([]byte, []byte, []byte, error) {
// decrypt decrypts the key, when it is encrypted. and validates its signature
func (k *Key) decrypt(password []byte) error {
var (
err error
cipherKey,
cipherIV,
macKey []byte
)
cipherKey, cipherIV, macKey, err := k.deriveKeys(password)
if err != nil {
return err
}
// decrypt the key, when it is encrypted
if !k.decrypted && k.Encryption != "none" {
cipherKey, cipherIV, macKey, err = k.deriveKeys(password)
if err != nil {
return err
}
err = decryptCBC(cipherKey, cipherIV, macKey, k.PrivateKey)
if err != nil {
return err
......
......@@ -39,7 +39,7 @@ github.com/hashicorp/hcl/json/token
github.com/howeyc/gopass
# github.com/inconshreveable/mousetrap v1.0.0
github.com/inconshreveable/mousetrap
# github.com/kayrus/putty v1.0.3
# github.com/kayrus/putty v1.0.4
## explicit
github.com/kayrus/putty
# github.com/magiconair/properties v1.8.1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment