mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
crypto tests: remove dependency on /dev/urandom
This commit is contained in:
parent
c228a212b0
commit
47219a790f
1 changed files with 4 additions and 13 deletions
|
@ -2,9 +2,9 @@ package crypto_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/chunker"
|
"github.com/restic/chunker"
|
||||||
|
@ -50,10 +50,7 @@ func TestSmallBuffer(t *testing.T) {
|
||||||
|
|
||||||
size := 600
|
size := 600
|
||||||
data := make([]byte, size)
|
data := make([]byte, size)
|
||||||
f, err := os.Open("/dev/urandom")
|
_, err := io.ReadFull(rand.Reader, data)
|
||||||
OK(t, err)
|
|
||||||
|
|
||||||
_, err = io.ReadFull(f, data)
|
|
||||||
OK(t, err)
|
OK(t, err)
|
||||||
|
|
||||||
ciphertext := make([]byte, size/2)
|
ciphertext := make([]byte, size/2)
|
||||||
|
@ -75,10 +72,7 @@ func TestSameBuffer(t *testing.T) {
|
||||||
|
|
||||||
size := 600
|
size := 600
|
||||||
data := make([]byte, size)
|
data := make([]byte, size)
|
||||||
f, err := os.Open("/dev/urandom")
|
_, err := io.ReadFull(rand.Reader, data)
|
||||||
OK(t, err)
|
|
||||||
|
|
||||||
_, err = io.ReadFull(f, data)
|
|
||||||
OK(t, err)
|
OK(t, err)
|
||||||
|
|
||||||
ciphertext := make([]byte, 0, size+crypto.Extension)
|
ciphertext := make([]byte, 0, size+crypto.Extension)
|
||||||
|
@ -124,10 +118,7 @@ func TestLargeEncrypt(t *testing.T) {
|
||||||
|
|
||||||
for _, size := range []int{chunker.MaxSize, chunker.MaxSize + 1, chunker.MaxSize + 1<<20} {
|
for _, size := range []int{chunker.MaxSize, chunker.MaxSize + 1, chunker.MaxSize + 1<<20} {
|
||||||
data := make([]byte, size)
|
data := make([]byte, size)
|
||||||
f, err := os.Open("/dev/urandom")
|
_, err := io.ReadFull(rand.Reader, data)
|
||||||
OK(t, err)
|
|
||||||
|
|
||||||
_, err = io.ReadFull(f, data)
|
|
||||||
OK(t, err)
|
OK(t, err)
|
||||||
|
|
||||||
ciphertext, err := crypto.Encrypt(k, make([]byte, size+crypto.Extension), data)
|
ciphertext, err := crypto.Encrypt(k, make([]byte, size+crypto.Extension), data)
|
||||||
|
|
Loading…
Reference in a new issue