Skip to content

Commit

Permalink
nit fix for #20 (#22)
Browse files Browse the repository at this point in the history
Signed-off-by: SamYuan1990 <[email protected]>
  • Loading branch information
SamYuan1990 authored Jan 3, 2021
1 parent 890e4cf commit 347510a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
36 changes: 36 additions & 0 deletions test/gmssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
package main

import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"fmt"
"testing"

Expand Down Expand Up @@ -382,3 +385,36 @@ func BenchmarkSM2Verify(b *testing.B) {
err = sm2pk.Verify("sm2sign", digest, signature, nil)
}
}

func BenchmarkEcdsaSign(t *testing.B) {
t.ReportAllocs()
msg := []byte("test")
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
t.Fatal(err)
}
t.ResetTimer()
for i := 0; i < t.N; i++ {
_, _, err := ecdsa.Sign(rand.Reader, priv, msg)
if err != nil {
t.Fatal(err)
}
}
}

func BenchmarkEcdsaVerify(t *testing.B) {
t.ReportAllocs()
msg := []byte("test")
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
t.Fatal(err)
}
r, s, err := ecdsa.Sign(rand.Reader, priv, msg)
if err != nil {
t.Fatal(err)
}
t.ResetTimer()
for i := 0; i < t.N; i++ {
ecdsa.Verify(&priv.PublicKey, msg, r, s)
}
}
6 changes: 3 additions & 3 deletions test/smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func TestPublicKeyAlgorithms(t *testing.T) {
}
}

/*func TestEngines(t *testing.T) {
/* Engines
func TestEngines(t *testing.T) {
/* Engines */
fmt.Print("Engines:")
engines := gmssl.GetEngineNames()
for _, engine := range engines {
fmt.Print(" " + engine)
}
}*/
}

0 comments on commit 347510a

Please sign in to comment.