aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/crypto/elliptic/elliptic_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/crypto/elliptic/elliptic_test.go')
-rw-r--r--libgo/go/crypto/elliptic/elliptic_test.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/libgo/go/crypto/elliptic/elliptic_test.go b/libgo/go/crypto/elliptic/elliptic_test.go
index a68a380..c23af75 100644
--- a/libgo/go/crypto/elliptic/elliptic_test.go
+++ b/libgo/go/crypto/elliptic/elliptic_test.go
@@ -13,7 +13,7 @@ import (
func TestOnCurve(t *testing.T) {
p224 := P224()
- if !p224.IsOnCurve(p224.Gx, p224.Gy) {
+ if !p224.IsOnCurve(p224.Params().Gx, p224.Params().Gy) {
t.Errorf("FAIL")
}
}
@@ -295,7 +295,25 @@ func TestBaseMult(t *testing.T) {
}
x, y := p224.ScalarBaseMult(k.Bytes())
if fmt.Sprintf("%x", x) != e.x || fmt.Sprintf("%x", y) != e.y {
- t.Errorf("%d: bad output for k=%s: got (%x, %s), want (%x, %s)", i, e.k, x, y, e.x, e.y)
+ t.Errorf("%d: bad output for k=%s: got (%x, %x), want (%s, %s)", i, e.k, x, y, e.x, e.y)
+ }
+ if testing.Short() && i > 5 {
+ break
+ }
+ }
+}
+
+func TestGenericBaseMult(t *testing.T) {
+ // We use the P224 CurveParams directly in order to test the generic implementation.
+ p224 := P224().Params()
+ for i, e := range p224BaseMultTests {
+ k, ok := new(big.Int).SetString(e.k, 10)
+ if !ok {
+ t.Errorf("%d: bad value for k: %s", i, e.k)
+ }
+ x, y := p224.ScalarBaseMult(k.Bytes())
+ if fmt.Sprintf("%x", x) != e.x || fmt.Sprintf("%x", y) != e.y {
+ t.Errorf("%d: bad output for k=%s: got (%x, %x), want (%s, %s)", i, e.k, x, y, e.x, e.y)
}
if testing.Short() && i > 5 {
break
@@ -316,13 +334,13 @@ func BenchmarkBaseMult(b *testing.B) {
func TestMarshal(t *testing.T) {
p224 := P224()
- _, x, y, err := p224.GenerateKey(rand.Reader)
+ _, x, y, err := GenerateKey(p224, rand.Reader)
if err != nil {
t.Error(err)
return
}
- serialized := p224.Marshal(x, y)
- xx, yy := p224.Unmarshal(serialized)
+ serialized := Marshal(p224, x, y)
+ xx, yy := Unmarshal(p224, serialized)
if xx == nil {
t.Error("failed to unmarshal")
return