diff --git a/kyber_1024/kyber_1024_test.go b/kyber_1024/kyber_1024_test.go index 3f40b98..8c7c8fb 100644 --- a/kyber_1024/kyber_1024_test.go +++ b/kyber_1024/kyber_1024_test.go @@ -16,6 +16,7 @@ import( func Test_kyber1024(t *testing.T){ var curpos,temp_len uint + kyber_ops.Set_test_rand() data,err:=os.ReadFile("kyber1024-kat.rsp") if err!=nil{ t.Fatal(err) @@ -54,6 +55,7 @@ func Test_kyber1024(t *testing.T){ func Test_kyber1024_90s(t *testing.T){ var curpos,temp_len uint + kyber_ops.Set_test_rand() data,err:=os.ReadFile("kyber1024_90s-kat.rsp") if err!=nil{ t.Fatal(err) diff --git a/kyber_512/kyber_512_test.go b/kyber_512/kyber_512_test.go index 20b2902..fa2de96 100644 --- a/kyber_512/kyber_512_test.go +++ b/kyber_512/kyber_512_test.go @@ -16,6 +16,7 @@ import( func Test_kyber512(t *testing.T){ var curpos,temp_len uint + kyber_ops.Set_test_rand() data,err:=os.ReadFile("kyber512-kat.rsp") if err!=nil{ t.Fatal(err) @@ -54,6 +55,7 @@ func Test_kyber512(t *testing.T){ func Test_kyber512_90s(t *testing.T){ var curpos,temp_len uint + kyber_ops.Set_test_rand() data,err:=os.ReadFile("kyber512_90s-kat.rsp") if err!=nil{ t.Fatal(err) diff --git a/kyber_768/kyber_768_test.go b/kyber_768/kyber_768_test.go index d53bfd8..cefd9a0 100644 --- a/kyber_768/kyber_768_test.go +++ b/kyber_768/kyber_768_test.go @@ -16,6 +16,7 @@ import( func Test_kyber_768(t *testing.T){ var curpos,temp_len uint + kyber_ops.Set_test_rand() data,err:=os.ReadFile("kyber768-kat.rsp") if err!=nil{ t.Fatal(err) @@ -54,6 +55,7 @@ func Test_kyber_768(t *testing.T){ func Test_kyber_768_90s(t *testing.T){ var curpos,temp_len uint + kyber_ops.Set_test_rand() data,err:=os.ReadFile("kyber768_90s-kat.rsp") if err!=nil{ t.Fatal(err) diff --git a/kyber_ops/Common.go b/kyber_ops/Common.go index 606f2a0..e19fc4c 100644 --- a/kyber_ops/Common.go +++ b/kyber_ops/Common.go @@ -42,6 +42,11 @@ func Init_Seed(str string)(err error){ } var rng rng_info +var test_rand bool=false + +func Set_test_rand(){ + test_rand=true +} func init_rng(seed *[48]byte){ rng.iv=[16]byte{} @@ -50,6 +55,10 @@ func init_rng(seed *[48]byte){ } func Read_RNG(rand_data []byte){ + if !test_rand{ + rand.Read(rand_data) + return + } cipher,_:=aes.NewCipher(rng.key[:]) length:=len(rand_data) for cur:=0;cur0;i--{ + for i:=15;i>=0;i--{ iv[i]++ if iv[i]>0{ break