]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/aont/aont_test.go
crypto/rand does not guarantee full read at once
[govpn.git] / src / cypherpunks.ru / govpn / aont / aont_test.go
index 93b7db51afbaf3b3f667c684735b3d01d1ab46fb..0ef140c2c407726531a21b951875a4ab0b2b5aa5 100644 (file)
@@ -21,6 +21,7 @@ package aont
 import (
        "bytes"
        "crypto/rand"
+       "io"
        "testing"
        "testing/quick"
 )
@@ -30,7 +31,7 @@ var (
 )
 
 func init() {
-       rand.Read(testKey[:])
+       io.ReadFull(rand.Reader, testKey[:])
 }
 
 func TestSymmetric(t *testing.T) {
@@ -80,7 +81,7 @@ func TestTampered(t *testing.T) {
 
 func BenchmarkEncode(b *testing.B) {
        data := make([]byte, 128)
-       rand.Read(data)
+       io.ReadFull(rand.Reader, data)
        b.ResetTimer()
        for i := 0; i < b.N; i++ {
                Encode(testKey, data)
@@ -89,7 +90,7 @@ func BenchmarkEncode(b *testing.B) {
 
 func BenchmarkDecode(b *testing.B) {
        data := make([]byte, 128)
-       rand.Read(data)
+       io.ReadFull(rand.Reader, data)
        encoded, _ := Encode(testKey, data)
        b.ResetTimer()
        for i := 0; i < b.N; i++ {