summaryrefslogtreecommitdiffhomepage
path: root/pkg/rand/rand.go
diff options
context:
space:
mode:
authorGoogler <noreply@google.com>2018-08-22 13:29:57 -0700
committerShentubot <shentubot@google.com>2018-08-22 13:31:11 -0700
commitbbee911179aaf925f58051de4392502743539802 (patch)
treeb6ee895a917a324cdb612f898ac3d0b7b78e4c35 /pkg/rand/rand.go
parent6b9133ba96863e3653fa6f3949710203bb077c50 (diff)
Allow building on !linux
PiperOrigin-RevId: 209819644 Change-Id: I329d054bf8f4999e7db0dcd95b13f7793c65d4e2
Diffstat (limited to 'pkg/rand/rand.go')
-rw-r--r--pkg/rand/rand.go22
1 files changed, 6 insertions, 16 deletions
diff --git a/pkg/rand/rand.go b/pkg/rand/rand.go
index 37ac07620..e81f0f5db 100644
--- a/pkg/rand/rand.go
+++ b/pkg/rand/rand.go
@@ -12,28 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// +build !linux
+
// Package rand implements a cryptographically secure pseudorandom number
// generator.
package rand
-import (
- "io"
-
- "golang.org/x/sys/unix"
-)
-
-// reader implements an io.Reader that returns pseudorandom bytes.
-type reader struct{}
-
-// Read implements io.Reader.Read.
-func (reader) Read(p []byte) (int, error) {
- return unix.Getrandom(p, 0)
-}
+import "crypto/rand"
// Reader is the default reader.
-var Reader io.Reader = reader{}
+var Reader = rand.Reader
-// Read reads from the default reader.
+// Read implements io.Reader.Read.
func Read(b []byte) (int, error) {
- return io.ReadFull(Reader, b)
+ return rand.Read(b)
}