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