X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgovpn%2Fencless_test.go;h=e7a5ef5a726d3d5b48b6befe893225700246a496;hb=572cac17bde738055312f7a468a0bde0e760a262;hp=20b0df63281e481a254eee1a25bf86a81bf8f0a6;hpb=cecb63f12f4a9f523276a0c19c7feb7437c7f53a;p=govpn.git diff --git a/src/cypherpunks.ru/govpn/encless_test.go b/src/cypherpunks.ru/govpn/encless_test.go index 20b0df6..e7a5ef5 100644 --- a/src/cypherpunks.ru/govpn/encless_test.go +++ b/src/cypherpunks.ru/govpn/encless_test.go @@ -1,6 +1,6 @@ /* GoVPN -- simple secure free software virtual private network daemon -Copyright (C) 2014-2016 Sergey Matveev +Copyright (C) 2014-2017 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,8 +20,8 @@ package govpn import ( "bytes" - "crypto/rand" "encoding/binary" + "io" "testing" "testing/quick" ) @@ -31,13 +31,13 @@ var ( ) func init() { - rand.Read(testKey[:]) + io.ReadFull(Rand, testKey[:]) } func TestEnclessSymmetric(t *testing.T) { - nonce := make([]byte, 8) + nonce := new([16]byte) f := func(pktNum uint64, in []byte) bool { - binary.BigEndian.PutUint64(nonce, pktNum) + binary.BigEndian.PutUint64(nonce[8:], pktNum) encoded, err := EnclessEncode(testKey, nonce, in) if err != nil { return false @@ -54,10 +54,10 @@ func TestEnclessSymmetric(t *testing.T) { } func BenchmarkEnclessEncode(b *testing.B) { - nonce := make([]byte, 8) + nonce := new([16]byte) data := make([]byte, 128) - rand.Read(nonce) - rand.Read(data) + io.ReadFull(Rand, nonce[8:]) + io.ReadFull(Rand, data) b.ResetTimer() for i := 0; i < b.N; i++ { EnclessEncode(testKey, nonce, data) @@ -65,10 +65,10 @@ func BenchmarkEnclessEncode(b *testing.B) { } func BenchmarkEnclessDecode(b *testing.B) { - nonce := make([]byte, 8) + nonce := new([16]byte) data := make([]byte, 128) - rand.Read(nonce) - rand.Read(data) + io.ReadFull(Rand, nonce[8:]) + io.ReadFull(Rand, data) encoded, _ := EnclessEncode(testKey, nonce, data) b.ResetTimer() for i := 0; i < b.N; i++ {