aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go')
-rw-r--r--vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go b/vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go
index 266840d..02b372c 100644
--- a/vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go
+++ b/vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go
@@ -42,12 +42,18 @@ func (e *EncryptedKey) parse(r io.Reader) (err error) {
42 switch e.Algo { 42 switch e.Algo {
43 case PubKeyAlgoRSA, PubKeyAlgoRSAEncryptOnly: 43 case PubKeyAlgoRSA, PubKeyAlgoRSAEncryptOnly:
44 e.encryptedMPI1.bytes, e.encryptedMPI1.bitLength, err = readMPI(r) 44 e.encryptedMPI1.bytes, e.encryptedMPI1.bitLength, err = readMPI(r)
45 if err != nil {
46 return
47 }
45 case PubKeyAlgoElGamal: 48 case PubKeyAlgoElGamal:
46 e.encryptedMPI1.bytes, e.encryptedMPI1.bitLength, err = readMPI(r) 49 e.encryptedMPI1.bytes, e.encryptedMPI1.bitLength, err = readMPI(r)
47 if err != nil { 50 if err != nil {
48 return 51 return
49 } 52 }
50 e.encryptedMPI2.bytes, e.encryptedMPI2.bitLength, err = readMPI(r) 53 e.encryptedMPI2.bytes, e.encryptedMPI2.bitLength, err = readMPI(r)
54 if err != nil {
55 return
56 }
51 } 57 }
52 _, err = consumeAll(r) 58 _, err = consumeAll(r)
53 return 59 return
@@ -72,7 +78,8 @@ func (e *EncryptedKey) Decrypt(priv *PrivateKey, config *Config) error {
72 // padding oracle attacks. 78 // padding oracle attacks.
73 switch priv.PubKeyAlgo { 79 switch priv.PubKeyAlgo {
74 case PubKeyAlgoRSA, PubKeyAlgoRSAEncryptOnly: 80 case PubKeyAlgoRSA, PubKeyAlgoRSAEncryptOnly:
75 b, err = rsa.DecryptPKCS1v15(config.Random(), priv.PrivateKey.(*rsa.PrivateKey), e.encryptedMPI1.bytes) 81 k := priv.PrivateKey.(*rsa.PrivateKey)
82 b, err = rsa.DecryptPKCS1v15(config.Random(), k, padToKeySize(&k.PublicKey, e.encryptedMPI1.bytes))
76 case PubKeyAlgoElGamal: 83 case PubKeyAlgoElGamal:
77 c1 := new(big.Int).SetBytes(e.encryptedMPI1.bytes) 84 c1 := new(big.Int).SetBytes(e.encryptedMPI1.bytes)
78 c2 := new(big.Int).SetBytes(e.encryptedMPI2.bytes) 85 c2 := new(big.Int).SetBytes(e.encryptedMPI2.bytes)