diff options
author | Ian Lance Taylor <iant@google.com> | 2016-02-03 21:58:02 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-02-03 21:58:02 +0000 |
commit | f98dd1a338867a408f7c72d73fbad7fe7fc93e3a (patch) | |
tree | 2f8da9862a9c1fe0df138917f997b03439c02773 /libgo/go/crypto/ecdsa/ecdsa_test.go | |
parent | b081ed4efc144da0c45a6484aebfd10e0eb9fda3 (diff) | |
download | gcc-f98dd1a338867a408f7c72d73fbad7fe7fc93e3a.zip gcc-f98dd1a338867a408f7c72d73fbad7fe7fc93e3a.tar.gz gcc-f98dd1a338867a408f7c72d73fbad7fe7fc93e3a.tar.bz2 |
libgo: Update to go1.6rc1.
Reviewed-on: https://go-review.googlesource.com/19200
From-SVN: r233110
Diffstat (limited to 'libgo/go/crypto/ecdsa/ecdsa_test.go')
-rw-r--r-- | libgo/go/crypto/ecdsa/ecdsa_test.go | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/libgo/go/crypto/ecdsa/ecdsa_test.go b/libgo/go/crypto/ecdsa/ecdsa_test.go index 169944d..62a3fcc 100644 --- a/libgo/go/crypto/ecdsa/ecdsa_test.go +++ b/libgo/go/crypto/ecdsa/ecdsa_test.go @@ -42,6 +42,41 @@ func TestKeyGeneration(t *testing.T) { testKeyGeneration(t, elliptic.P521(), "p521") } +func BenchmarkSignP256(b *testing.B) { + b.ResetTimer() + p256 := elliptic.P256() + hashed := []byte("testing") + priv, _ := GenerateKey(p256, rand.Reader) + + b.ResetTimer() + for i := 0; i < b.N; i++ { + _, _, _ = Sign(rand.Reader, priv, hashed) + } +} + +func BenchmarkVerifyP256(b *testing.B) { + b.ResetTimer() + p256 := elliptic.P256() + hashed := []byte("testing") + priv, _ := GenerateKey(p256, rand.Reader) + r, s, _ := Sign(rand.Reader, priv, hashed) + + b.ResetTimer() + for i := 0; i < b.N; i++ { + Verify(&priv.PublicKey, hashed, r, s) + } +} + +func BenchmarkKeyGeneration(b *testing.B) { + b.ResetTimer() + p256 := elliptic.P256() + + b.ResetTimer() + for i := 0; i < b.N; i++ { + GenerateKey(p256, rand.Reader) + } +} + func testSignAndVerify(t *testing.T, c elliptic.Curve, tag string) { priv, _ := GenerateKey(c, rand.Reader) @@ -91,11 +126,11 @@ func testNonceSafety(t *testing.T, c elliptic.Curve, tag string) { if s0.Cmp(s1) == 0 { // This should never happen. - t.Errorf("%s: the signatures on two different messages were the same") + t.Errorf("%s: the signatures on two different messages were the same", tag) } if r0.Cmp(r1) == 0 { - t.Errorf("%s: the nonce used for two diferent messages was the same") + t.Errorf("%s: the nonce used for two diferent messages was the same", tag) } } @@ -126,11 +161,11 @@ func testINDCCA(t *testing.T, c elliptic.Curve, tag string) { } if s0.Cmp(s1) == 0 { - t.Errorf("%s: two signatures of the same message produced the same result") + t.Errorf("%s: two signatures of the same message produced the same result", tag) } if r0.Cmp(r1) == 0 { - t.Errorf("%s: two signatures of the same message produced the same nonce") + t.Errorf("%s: two signatures of the same message produced the same nonce", tag) } } |