aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/rsa/rsa.go
diff options
context:
space:
mode:
authorAdam Langley <agl@golang.org>2017-10-14 11:43:17 -0700
committerAdam Langley <agl@golang.org>2017-10-29 19:45:11 +0000
commit507ca082d116c19cbe5cbdd457e6b37d851d2341 (patch)
treebc0890fb2516bff8a59d835b572cc85ce540bfcb /src/crypto/rsa/rsa.go
parent5a4b6bce37ed85b1d26a00b215d2401d90de6b76 (diff)
downloadgo-507ca082d116c19cbe5cbdd457e6b37d851d2341.tar.gz
go-507ca082d116c19cbe5cbdd457e6b37d851d2341.zip
crypto/{ecdsa,rsa}: rename argument to PrivateKey.Sign.
The crypto.Signer interface takes pre-hased messages for ECDSA and RSA, but the argument in the implementations was called “msg”, not “digest”, which is confusing. This change renames them to help clarify the intended use. Change-Id: Ie2fb8753ca5280e493810d211c7c66223f94af88 Reviewed-on: https://go-review.googlesource.com/70950 Reviewed-by: Filippo Valsorda <hi@filippo.io>
Diffstat (limited to 'src/crypto/rsa/rsa.go')
-rw-r--r--src/crypto/rsa/rsa.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/crypto/rsa/rsa.go b/src/crypto/rsa/rsa.go
index 69a2b58a5a..0faca43e43 100644
--- a/src/crypto/rsa/rsa.go
+++ b/src/crypto/rsa/rsa.go
@@ -92,17 +92,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