aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/crypto/openpgp/packet/public_key.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/crypto/openpgp/packet/public_key.go')
-rw-r--r--vendor/golang.org/x/crypto/openpgp/packet/public_key.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/vendor/golang.org/x/crypto/openpgp/packet/public_key.go b/vendor/golang.org/x/crypto/openpgp/packet/public_key.go
index ead2623..fcd5f52 100644
--- a/vendor/golang.org/x/crypto/openpgp/packet/public_key.go
+++ b/vendor/golang.org/x/crypto/openpgp/packet/public_key.go
@@ -244,7 +244,12 @@ func NewECDSAPublicKey(creationTime time.Time, pub *ecdsa.PublicKey) *PublicKey
244 } 244 }
245 245
246 pk.ec.p.bytes = elliptic.Marshal(pub.Curve, pub.X, pub.Y) 246 pk.ec.p.bytes = elliptic.Marshal(pub.Curve, pub.X, pub.Y)
247 pk.ec.p.bitLength = uint16(8 * len(pk.ec.p.bytes)) 247
248 // The bit length is 3 (for the 0x04 specifying an uncompressed key)
249 // plus two field elements (for x and y), which are rounded up to the
250 // nearest byte. See https://tools.ietf.org/html/rfc6637#section-6
251 fieldBytes := (pub.Curve.Params().BitSize + 7) & ^7
252 pk.ec.p.bitLength = uint16(3 + fieldBytes + fieldBytes)
248 253
249 pk.setFingerPrintAndKeyId() 254 pk.setFingerPrintAndKeyId()
250 return pk 255 return pk
@@ -515,7 +520,7 @@ func (pk *PublicKey) VerifySignature(signed hash.Hash, sig *Signature) (err erro
515 switch pk.PubKeyAlgo { 520 switch pk.PubKeyAlgo {
516 case PubKeyAlgoRSA, PubKeyAlgoRSASignOnly: 521 case PubKeyAlgoRSA, PubKeyAlgoRSASignOnly:
517 rsaPublicKey, _ := pk.PublicKey.(*rsa.PublicKey) 522 rsaPublicKey, _ := pk.PublicKey.(*rsa.PublicKey)
518 err = rsa.VerifyPKCS1v15(rsaPublicKey, sig.Hash, hashBytes, sig.RSASignature.bytes) 523 err = rsa.VerifyPKCS1v15(rsaPublicKey, sig.Hash, hashBytes, padToKeySize(rsaPublicKey, sig.RSASignature.bytes))
519 if err != nil { 524 if err != nil {
520 return errors.SignatureError("RSA verification failure") 525 return errors.SignatureError("RSA verification failure")
521 } 526 }
@@ -566,7 +571,7 @@ func (pk *PublicKey) VerifySignatureV3(signed hash.Hash, sig *SignatureV3) (err
566 switch pk.PubKeyAlgo { 571 switch pk.PubKeyAlgo {
567 case PubKeyAlgoRSA, PubKeyAlgoRSASignOnly: 572 case PubKeyAlgoRSA, PubKeyAlgoRSASignOnly:
568 rsaPublicKey := pk.PublicKey.(*rsa.PublicKey) 573 rsaPublicKey := pk.PublicKey.(*rsa.PublicKey)
569 if err = rsa.VerifyPKCS1v15(rsaPublicKey, sig.Hash, hashBytes, sig.RSASignature.bytes); err != nil { 574 if err = rsa.VerifyPKCS1v15(rsaPublicKey, sig.Hash, hashBytes, padToKeySize(rsaPublicKey, sig.RSASignature.bytes)); err != nil {
570 return errors.SignatureError("RSA verification failure") 575 return errors.SignatureError("RSA verification failure")
571 } 576 }
572 return 577 return