Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Change-Id: I0cec341301c103b4c9a505906f00adfb72571b0d
  • Loading branch information
mateusz834 committed Apr 13, 2024
1 parent 81fe51c commit c63aa96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/crypto/rand/rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"bytes"
"compress/flate"
"io"
"runtime"
"std/crypto/internal/boring"
"std/runtime"
"testing"
)

Expand Down Expand Up @@ -62,7 +65,11 @@ func benchmarkRead(b *testing.B, size int) {
}

func TestReadAllocs(t *testing.T) {
allocs := testing.AllocsPerRun(100, func() {
if boring.Enabled || (runtime.GOOS == "js" && runtime.GOARCH == "wasm") {
t.Skip("zero-allocs unsupported")
}

allocs := testing.AllocsPerRun(1000, func() {
buf := make([]byte, 32)
Read(buf)
})
Expand Down
6 changes: 6 additions & 0 deletions src/crypto/rand/rand_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const urandomDevice = "/dev/urandom"

var randReader = &reader{}

func init() {
if boring.Enabled {
Reader = boring.RandReader
}
}

// A reader satisfies reads by reading from urandomDevice
type reader struct {
f hideAgainFileReader
Expand Down

0 comments on commit c63aa96

Please sign in to comment.