1 // Copyright 2023 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 package sysrand
6 7 import "syscall"
8 9 func read(b []byte) error {
10 // This uses the wasi_snapshot_preview1 random_get syscall defined in
11 // https://github.com/WebAssembly/WASI/blob/23a52736049f4327dd335434851d5dc40ab7cad1/legacy/preview1/docs.md#-random_getbuf-pointeru8-buf_len-size---result-errno.
12 // The definition does not explicitly guarantee that the entire buffer will
13 // be filled, but this appears to be the case in all runtimes tested.
14 return syscall.RandomGet(b)
15 }
16