コード例 #1
0
func TestSignAndVerify(t *testing.T) {
	testSignAndVerify(t, bitelliptic.S256(), "S256")
	if testing.Short() {
		return
	}
	testSignAndVerify(t, bitelliptic.S160(), "S160")
	testSignAndVerify(t, bitelliptic.S192(), "S192")
	testSignAndVerify(t, bitelliptic.S224(), "S224")
}
コード例 #2
0
func TestKeyGeneration(t *testing.T) {
	testKeyGeneration(t, bitelliptic.S256(), "S256")
	if testing.Short() {
		return
	}
	testKeyGeneration(t, bitelliptic.S160(), "S160")
	testKeyGeneration(t, bitelliptic.S192(), "S192")
	testKeyGeneration(t, bitelliptic.S224(), "S224")
}
コード例 #3
0
func BenchmarkSign(b *testing.B) {
	b.StopTimer()
	priv, _ := GenerateKey(bitelliptic.S256(), rand.Reader)
	hashed := []byte("testing")
	b.StartTimer()

	for i := 0; i < b.N; i++ {
		Sign(rand.Reader, priv, hashed)
	}
}
コード例 #4
0
func BenchmarkVerify(b *testing.B) {
	b.StopTimer()
	data := testVectors[0]
	pub := &PublicKey{
		BitCurve: bitelliptic.S256(),
		X:        fromHex(data.Qx),
		Y:        fromHex(data.Qy),
	}
	hashed, _ := base64.StdEncoding.DecodeString(data.hash)
	r := fromHex(data.r)
	s := fromHex(data.s)
	b.StartTimer()

	for i := 0; i < b.N; i++ {
		Verify(pub, hashed, r, s)
	}
}
コード例 #5
0
func TestVectors(t *testing.T) {
	for i, test := range testVectors {
		pub := PublicKey{
			BitCurve: bitelliptic.S256(),
			X:        fromHex(test.Qx),
			Y:        fromHex(test.Qy),
		}
		hashed, _ := base64.StdEncoding.DecodeString(test.hash)
		r := fromHex(test.r)
		s := fromHex(test.s)
		if Verify(&pub, hashed, r, s) != test.ok {
			t.Errorf("%d: bad result", i)
		}
		if testing.Short() {
			break
		}
	}
}