aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2021-03-10 10:26:20 +0100
committerTobias Klauser <tobias.klauser@gmail.com>2021-03-11 08:19:39 +0000
commit9ece63f0647ec34cc729ad71a87254193014dcca (patch)
tree920f2e4c8d3ab2780d4adbc7605469ea77da5c10 /src/crypto
parent79e3ee52f48411eb7c4edfe3daa55e2ecf7a6c61 (diff)
downloadgo-9ece63f0647ec34cc729ad71a87254193014dcca.tar.gz
go-9ece63f0647ec34cc729ad71a87254193014dcca.zip
crypto/rand, internal/syscall/unix: add support for getrandom syscall on solaris
The getrandom syscall is available on Solaris and Illumos, see https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html and https://illumos.org/man/2/getrandom Change-Id: Id1c65d6a5b2fbc80d20b43d8b32dab137ca950ca Reviewed-on: https://go-review.googlesource.com/c/go/+/299134 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/rand/rand_batched.go4
-rw-r--r--src/crypto/rand/rand_batched_test.go4
-rw-r--r--src/crypto/rand/rand_solaris.go10
3 files changed, 14 insertions, 4 deletions
diff --git a/src/crypto/rand/rand_batched.go b/src/crypto/rand/rand_batched.go
index 538769a868..d7c5bf3562 100644
--- a/src/crypto/rand/rand_batched.go
+++ b/src/crypto/rand/rand_batched.go
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build linux || freebsd || dragonfly
-// +build linux freebsd dragonfly
+//go:build linux || freebsd || dragonfly || solaris
+// +build linux freebsd dragonfly solaris
package rand
diff --git a/src/crypto/rand/rand_batched_test.go b/src/crypto/rand/rand_batched_test.go
index 814f15201a..2d20922c82 100644
--- a/src/crypto/rand/rand_batched_test.go
+++ b/src/crypto/rand/rand_batched_test.go
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build linux || freebsd || dragonfly
-// +build linux freebsd dragonfly
+//go:build linux || freebsd || dragonfly || solaris
+// +build linux freebsd dragonfly solaris
package rand
diff --git a/src/crypto/rand/rand_solaris.go b/src/crypto/rand/rand_solaris.go
new file mode 100644
index 0000000000..bbad0fe557
--- /dev/null
+++ b/src/crypto/rand/rand_solaris.go
@@ -0,0 +1,10 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package rand
+
+// maxGetRandomRead is the maximum number of bytes to ask for in one call to the
+// getrandom() syscall. Across all the Solaris platforms, 256 bytes is the
+// lowest number of bytes returned atomically per call.
+const maxGetRandomRead = 1 << 8