diff options
Diffstat (limited to 'src/crypto/rand/rand_unix.go')
-rw-r--r-- | src/crypto/rand/rand_unix.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/crypto/rand/rand_unix.go b/src/crypto/rand/rand_unix.go index 3d11159a34..526e54a5c9 100644 --- a/src/crypto/rand/rand_unix.go +++ b/src/crypto/rand/rand_unix.go @@ -23,12 +23,18 @@ import ( "time" ) +import "crypto/internal/boring" + const urandomDevice = "/dev/urandom" // Easy implementation: read from /dev/urandom. // This is sufficient on Linux, OS X, and FreeBSD. func init() { + if boring.Enabled { + Reader = boring.RandReader + return + } if runtime.GOOS == "plan9" { Reader = newReader(nil) } else { @@ -53,6 +59,7 @@ func warnBlocked() { } func (r *devReader) Read(b []byte) (n int, err error) { + boring.Unreachable() if atomic.CompareAndSwapInt32(&r.used, 0, 1) { // First use of randomness. Start timer to warn about // being blocked on entropy not being available. @@ -122,6 +129,7 @@ type reader struct { } func (r *reader) Read(b []byte) (n int, err error) { + boring.Unreachable() r.mu.Lock() defer r.mu.Unlock() n = len(b) |