aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2021-03-17 11:17:02 +0100
committerTobias Klauser <tobias.klauser@gmail.com>2021-03-17 22:14:28 +0000
commitf38b6428a2d1beae784a9402368e4d7f9c7cd8c5 (patch)
treeccfe175969079982dadacf923b2353c5ad81106f /src/crypto
parentf82ce7fb230c0c0934be8975bd8b56c953c29422 (diff)
downloadgo-f38b6428a2d1beae784a9402368e4d7f9c7cd8c5.tar.gz
go-f38b6428a2d1beae784a9402368e4d7f9c7cd8c5.zip
crypto/rand, internal/syscall/unix: add support for getentropy syscall on darwin
The getentropy syscall is available on macOS since version 10.12, which is the minimum required version since Go 1.15. Change-Id: I294259af0b11df9669e4dc5fa891d2f2f039d91a Reviewed-on: https://go-review.googlesource.com/c/go/+/302489 Trust: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/rand/rand_getentropy.go (renamed from src/crypto/rand/rand_openbsd.go)7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/crypto/rand/rand_openbsd.go b/src/crypto/rand/rand_getentropy.go
index 9cc39f72d1..f82018a495 100644
--- a/src/crypto/rand/rand_openbsd.go
+++ b/src/crypto/rand/rand_getentropy.go
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build darwin || openbsd
+// +build darwin openbsd
+
package rand
import (
@@ -9,10 +12,10 @@ import (
)
func init() {
- altGetRandom = getRandomOpenBSD
+ altGetRandom = getEntropy
}
-func getRandomOpenBSD(p []byte) (ok bool) {
+func getEntropy(p []byte) (ok bool) {
// getentropy(2) returns a maximum of 256 bytes per call
for i := 0; i < len(p); i += 256 {
end := i + 256