1 // Copyright 2024 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4 5 //go:build darwin || openbsd
6 7 package sysrand
8 9 import "internal/syscall/unix"
10 11 // arc4random_buf is the recommended application CSPRNG, accepts buffers of
12 // any size, and never returns an error.
13 //
14 // "The subsystem is re-seeded from the kernel random number subsystem on a
15 // regular basis, and also upon fork(2)." - arc4random(3)
16 //
17 // Note that despite its legacy name, it uses a secure CSPRNG (not RC4) in
18 // all supported macOS versions.
19 func read(b []byte) error {
20 unix.ARC4Random(b)
21 return nil
22 }
23