sysrand

Imports

Imports #

"internal/byteorder"
"internal/chacha8rand"
"io"
"os"
"sync"
"syscall"
"internal/syscall/unix"
"internal/syscall/windows"
"os"
"sync"
"sync/atomic"
"time"
_ "unsafe"
"errors"
"internal/syscall/unix"
"math"
"runtime"
"syscall"
"internal/syscall/unix"

Constants & Variables

firstUse var #

var firstUse atomic.Bool

maxGetRandomRead const #

The maximum buffer size for crypto.getRandomValues is 65536 bytes. https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#exceptions

const maxGetRandomRead = *ast.BinaryExpr

mu var #

var mu sync.Mutex

randomDevice const #

const randomDevice = "/dev/random"

seedErr var #

var seedErr error

seeded var #

var seeded sync.Once

state var #

var state chacha8rand.State

testingOnlyFailRead var #

var testingOnlyFailRead bool

urandomErr var #

var urandomErr error

urandomFile var #

var urandomFile *os.File

urandomOnce var #

var urandomOnce sync.Once

Functions

Read function #

Read fills b with cryptographically secure random bytes from the operating system. It always fills b entirely and crashes the program irrecoverably if an error is encountered. The operating system APIs are documented to never return an error on all but legacy Linux systems.

func Read(b []byte)

fatal function #

fatal is [runtime.fatal], pushed via linkname. go:linkname fatal

func fatal(string)

getRandomValues function #

go:wasmimport gojs runtime.getRandomData go:noescape

func getRandomValues(r []byte)

read function #

arc4random_buf is the recommended application CSPRNG, accepts buffers of any size, and never returns an error. "The subsystem is re-seeded from the kernel random number subsystem on a regular basis, and also upon fork(2)." - arc4random(3) Note that despite its legacy name, it uses a secure CSPRNG (not RC4) in all supported macOS versions.

func read(b []byte) error

read function #

func read(b []byte) error

read function #

read calls the JavaScript Crypto.getRandomValues() method. See https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues.

func read(b []byte) error

read function #

func read(b []byte) error

read function #

func read(b []byte) error

read function #

func read(b []byte) error

read function #

func read(b []byte) error

read function #

func read(b []byte) error

urandomRead function #

func urandomRead(b []byte) error

warnBlocked function #

func warnBlocked()

Generated with Arrow