aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/crypto/ecdsa
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-06-25 16:20:03 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-06-25 16:20:03 +0000
commit08a680a8879ce9da16d808644730f7cfacaf667f (patch)
tree5dfe28c3f573ae57b971ed4d9a1c99a76f0a70c4 /libgo/go/crypto/ecdsa
parent72de8622ae2d5aaeb58173f454aed87640a989b5 (diff)
downloadgcc-08a680a8879ce9da16d808644730f7cfacaf667f.zip
gcc-08a680a8879ce9da16d808644730f7cfacaf667f.tar.gz
gcc-08a680a8879ce9da16d808644730f7cfacaf667f.tar.bz2
libgo: Update to Go 1.0.2 release.
From-SVN: r188943
Diffstat (limited to 'libgo/go/crypto/ecdsa')
-rw-r--r--libgo/go/crypto/ecdsa/ecdsa.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/libgo/go/crypto/ecdsa/ecdsa.go b/libgo/go/crypto/ecdsa/ecdsa.go
index b28239b..8508e3b 100644
--- a/libgo/go/crypto/ecdsa/ecdsa.go
+++ b/libgo/go/crypto/ecdsa/ecdsa.go
@@ -66,7 +66,9 @@ func GenerateKey(c elliptic.Curve, rand io.Reader) (priv *PrivateKey, err error)
// hashToInt converts a hash value to an integer. There is some disagreement
// about how this is done. [NSA] suggests that this is done in the obvious
// manner, but [SECG] truncates the hash to the bit-length of the curve order
-// first. We follow [SECG] because that's what OpenSSL does.
+// first. We follow [SECG] because that's what OpenSSL does. Additionally,
+// OpenSSL right shifts excess bits from the number if the hash is too large
+// and we mirror that too.
func hashToInt(hash []byte, c elliptic.Curve) *big.Int {
orderBits := c.Params().N.BitLen()
orderBytes := (orderBits + 7) / 8
@@ -75,7 +77,7 @@ func hashToInt(hash []byte, c elliptic.Curve) *big.Int {
}
ret := new(big.Int).SetBytes(hash)
- excess := orderBytes*8 - orderBits
+ excess := len(hash)*8 - orderBits
if excess > 0 {
ret.Rsh(ret, uint(excess))
}