crypto/rand.Reader may not return all entropy immediately

This commit is contained in:
Jakob Borg 2014-12-08 19:36:08 +01:00
parent 749bbec566
commit 957643f523

View File

@ -19,6 +19,7 @@ import (
"crypto/md5"
cryptoRand "crypto/rand"
"encoding/binary"
"io"
mathRand "math/rand"
)
@ -48,7 +49,7 @@ func randomString(l int) string {
// randomInt64 returns a strongly random int64, slowly
func randomInt64() int64 {
var bs [8]byte
n, err := cryptoRand.Reader.Read(bs[:])
n, err := io.ReadFull(cryptoRand.Reader, bs[:])
if n != 8 || err != nil {
panic("randomness failure")
}