]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/rand/rand_unix.go
[dev.boringcrypto] all: merge master into dev.boringcrypto
[gostls13.git] / src / crypto / rand / rand_unix.go
index 40347874c53412b4ce6491b0be7df80940c2a4ea..28f2f5b58b17baeb1dc1abafa14d362781abc190 100644 (file)
@@ -22,12 +22,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 {
@@ -52,6 +58,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.
@@ -121,6 +128,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)