aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/rsa/rsa.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-12-06 00:35:28 -0500
committerRuss Cox <rsc@golang.org>2017-12-06 01:03:36 -0500
commit185e6094fd968b35b80e56aad1286c66bb2cc261 (patch)
tree411babe570d6faa1e99251a9167123afd07407d2 /src/crypto/rsa/rsa.go
parentc36033a379a4907fb75309416ffcf2904e613ab9 (diff)
parenta032f74bf0b40a94669159e7d7e96722eb76199b (diff)
downloadgo-185e6094fd968b35b80e56aad1286c66bb2cc261.tar.gz
go-185e6094fd968b35b80e56aad1286c66bb2cc261.zip
[dev.boringcrypto] all: merge master (nearly Go 1.10 beta 1) into dev.boringcrypto
This is a git merge of master into dev.boringcrypto. The branch was previously based on release-branch.go1.9, so there are a handful of spurious conflicts that would also arise if trying to merge master into release-branch.go1.9 (which we never do). Those have all been resolved by taking the original file from master, discarding any Go 1.9-specific edits. all.bash passes on darwin/amd64, which is to say without actually using BoringCrypto. Go 1.10-related fixes to BoringCrypto itself will be in a followup CL. This CL is just the merge. Change-Id: I4c97711fec0fb86761913dcde28d25c001246c35
Diffstat (limited to 'src/crypto/rsa/rsa.go')
-rw-r--r--src/crypto/rsa/rsa.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/crypto/rsa/rsa.go b/src/crypto/rsa/rsa.go
index 8e63185ec6..9af5cbb165 100644
--- a/src/crypto/rsa/rsa.go
+++ b/src/crypto/rsa/rsa.go
@@ -98,17 +98,19 @@ func (priv *PrivateKey) Public() crypto.PublicKey {
return &priv.PublicKey
}
-// Sign signs msg with priv, reading randomness from rand. If opts is a
+// Sign signs digest with priv, reading randomness from rand. If opts is a
// *PSSOptions then the PSS algorithm will be used, otherwise PKCS#1 v1.5 will
-// be used. This method is intended to support keys where the private part is
-// kept in, for example, a hardware module. Common uses should use the Sign*
-// functions in this package.
-func (priv *PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) ([]byte, error) {
+// be used.
+//
+// This method implements crypto.Signer, which is an interface to support keys
+// where the private part is kept in, for example, a hardware module. Common
+// uses should use the Sign* functions in this package directly.
+func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
if pssOpts, ok := opts.(*PSSOptions); ok {
- return SignPSS(rand, priv, pssOpts.Hash, msg, pssOpts)
+ return SignPSS(rand, priv, pssOpts.Hash, digest, pssOpts)
}
- return SignPKCS1v15(rand, priv, opts.HashFunc(), msg)
+ return SignPKCS1v15(rand, priv, opts.HashFunc(), digest)
}
// Decrypt decrypts ciphertext with priv. If opts is nil or of type
@@ -480,8 +482,7 @@ var ErrVerification = errors.New("crypto/rsa: verification error")
func modInverse(a, n *big.Int) (ia *big.Int, ok bool) {
g := new(big.Int)
x := new(big.Int)
- y := new(big.Int)
- g.GCD(x, y, a, n)
+ g.GCD(x, nil, a, n)
if g.Cmp(bigOne) != 0 {
// In this case, a and n aren't coprime and we cannot calculate
// the inverse. This happens because the values of n are nearly