Use faster DRBG

This commit is contained in:
Henry Case 2019-04-12 11:53:30 +01:00
parent 2761895f46
commit 3369703ace

View File

@ -2,14 +2,16 @@ package main
import (
"bytes"
"crypto/rand"
"fmt"
"time"
"github.com/henrydcase/nobs/dh/csidh"
"github.com/henrydcase/nobs/drbg"
"github.com/henrydcase/sidh_torture/csidh/ref/go-wrapper"
)
var rng *drbg.CtrDrbg
func TestSS() {
var r wrapper.Ref
var ssRef [csidh.SharedSecretSize]byte
@ -21,7 +23,7 @@ func TestSS() {
prB := csidh.NewPrivateKey()
pkB := csidh.NewPublicKey()
prB.Generate(rand.Reader)
prB.Generate(rng)
pkB.Generate(&prB)
s1 := time.Now()
@ -51,9 +53,9 @@ func TestKeyGeneration() {
prB := csidh.NewPrivateKey()
pkB := csidh.NewPublicKey()
prA.Generate(rand.Reader)
prA.Generate(rng)
pkA.Generate(&prA)
prB.Generate(rand.Reader)
prB.Generate(rng)
pkB.Generate(&prB)
s1 := time.Now()
@ -76,8 +78,7 @@ func main() {
fmt.Printf("| TestName |Go | C |\n")
fmt.Printf("|------------------|----------|----------|\n")
// OZAPTF: make configurable
// for i:=0; i<100; i++ {
rng = drbg.NewCtrDrbg()
for {
TestSS()
TestKeyGeneration()