diff options
author | Wim <wim@42.be> | 2020-07-18 17:27:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-18 17:27:41 +0200 |
commit | 23d8742f0d95096b92f11729fb47f86ac3b68d43 (patch) | |
tree | 7b8acb02b051ae06e5454fda4a9d5118428fe016 /vendor/golang.org/x/crypto/ssh/keys.go | |
parent | 3b6a8be07b9422714db30fb50977f342057febf3 (diff) | |
download | matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.tar.gz matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.tar.bz2 matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.zip |
Update dependencies for 1.18.0 release (#1175)
Diffstat (limited to 'vendor/golang.org/x/crypto/ssh/keys.go')
-rw-r--r-- | vendor/golang.org/x/crypto/ssh/keys.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/vendor/golang.org/x/crypto/ssh/keys.go b/vendor/golang.org/x/crypto/ssh/keys.go index 06f537c1..31f26349 100644 --- a/vendor/golang.org/x/crypto/ssh/keys.go +++ b/vendor/golang.org/x/crypto/ssh/keys.go @@ -1246,15 +1246,23 @@ func passphraseProtectedOpenSSHKey(passphrase []byte) openSSHDecryptFunc { } key, iv := k[:32], k[32:] - if cipherName != "aes256-ctr" { - return nil, fmt.Errorf("ssh: unknown cipher %q, only supports %q", cipherName, "aes256-ctr") - } c, err := aes.NewCipher(key) if err != nil { return nil, err } - ctr := cipher.NewCTR(c, iv) - ctr.XORKeyStream(privKeyBlock, privKeyBlock) + switch cipherName { + case "aes256-ctr": + ctr := cipher.NewCTR(c, iv) + ctr.XORKeyStream(privKeyBlock, privKeyBlock) + case "aes256-cbc": + if len(privKeyBlock)%c.BlockSize() != 0 { + return nil, fmt.Errorf("ssh: invalid encrypted private key length, not a multiple of the block size") + } + cbc := cipher.NewCBCDecrypter(c, iv) + cbc.CryptBlocks(privKeyBlock, privKeyBlock) + default: + return nil, fmt.Errorf("ssh: unknown cipher %q, only supports %q or %q", cipherName, "aes256-ctr", "aes256-cbc") + } return privKeyBlock, nil } |