/*
GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
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
import (
"bytes"
- "crypto/rand"
"encoding/binary"
+ "io"
"testing"
"testing/quick"
)
)
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
}
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)
}
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++ {