From 39434e383b9e6fee30371afd5a9841de75671f56 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Fri, 13 Feb 2015 15:38:18 +0100 Subject: Unexport randEntropy type and use exported Reader instead --- crypto/key_store_test.go | 6 +++--- crypto/randentropy/rand_entropy.go | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'crypto') diff --git a/crypto/key_store_test.go b/crypto/key_store_test.go index a136ba992..485d8f536 100644 --- a/crypto/key_store_test.go +++ b/crypto/key_store_test.go @@ -9,7 +9,7 @@ import ( func TestKeyStorePlain(t *testing.T) { ks := NewKeyStorePlain(DefaultDataDir()) pass := "" // not used but required by API - k1, err := ks.GenerateNewKey(new(randentropy.RandEntropy), pass) + k1, err := ks.GenerateNewKey(randentropy.Reader, pass) if err != nil { t.Fatal(err) } @@ -37,7 +37,7 @@ func TestKeyStorePlain(t *testing.T) { func TestKeyStorePassphrase(t *testing.T) { ks := NewKeyStorePassphrase(DefaultDataDir()) pass := "foo" - k1, err := ks.GenerateNewKey(new(randentropy.RandEntropy), pass) + k1, err := ks.GenerateNewKey(randentropy.Reader, pass) if err != nil { t.Fatal(err) } @@ -63,7 +63,7 @@ func TestKeyStorePassphrase(t *testing.T) { func TestKeyStorePassphraseDecryptionFail(t *testing.T) { ks := NewKeyStorePassphrase(DefaultDataDir()) pass := "foo" - k1, err := ks.GenerateNewKey(new(randentropy.RandEntropy), pass) + k1, err := ks.GenerateNewKey(randentropy.Reader, pass) if err != nil { t.Fatal(err) } diff --git a/crypto/randentropy/rand_entropy.go b/crypto/randentropy/rand_entropy.go index 28181030c..b87fa564e 100644 --- a/crypto/randentropy/rand_entropy.go +++ b/crypto/randentropy/rand_entropy.go @@ -10,10 +10,12 @@ import ( "time" ) -type RandEntropy struct { +var Reader io.Reader = &randEntropy{} + +type randEntropy struct { } -func (*RandEntropy) Read(bytes []byte) (n int, err error) { +func (*randEntropy) Read(bytes []byte) (n int, err error) { readBytes := GetEntropyMixed(len(bytes)) copy(bytes, readBytes) return len(bytes), nil -- cgit