aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Harper <nharper@google.com>2016-06-29 11:18:01 -0700
committerAdam Langley <agl@golang.org>2016-06-29 18:44:36 +0000
commitcc6f5f6ce1daca51f475764a3e4fa9420cafcefa (patch)
tree12bd60ac3c9cd2efa327841839e4c3425a1bc908
parentad82f2cf4b7e8e5f5398b5546b7d834432347355 (diff)
downloadgo-cc6f5f6ce1daca51f475764a3e4fa9420cafcefa.tar.gz
go-cc6f5f6ce1daca51f475764a3e4fa9420cafcefa.zip
crypto/ecdsa: Update documentation for Sign
Change-Id: I2b7a81cb809d109f10d5f0db957c614f466d6bfd Reviewed-on: https://go-review.googlesource.com/24582 Reviewed-by: Adam Langley <agl@golang.org>
-rw-r--r--src/crypto/ecdsa/ecdsa.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/crypto/ecdsa/ecdsa.go b/src/crypto/ecdsa/ecdsa.go
index 288e366a88..72fb49934f 100644
--- a/src/crypto/ecdsa/ecdsa.go
+++ b/src/crypto/ecdsa/ecdsa.go
@@ -143,10 +143,11 @@ func fermatInverse(k, N *big.Int) *big.Int {
var errZeroParam = errors.New("zero parameter")
-// Sign signs an arbitrary length hash (which should be the result of hashing a
-// larger message) using the private key, priv. It returns the signature as a
-// pair of integers. The security of the private key depends on the entropy of
-// rand.
+// Sign signs a hash (which should be the result of hashing a larger message)
+// using the private key, priv. If the hash is longer than the bit-length of the
+// private key's curve order, the hash will be truncated to that length. It
+// returns the signature as a pair of integers. The security of the private key
+// depends on the entropy of rand.
func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err error) {
// Get max(log2(q) / 2, 256) bits of entropy from rand.
entropylen := (priv.Curve.Params().BitSize + 7) / 16