mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 12:03:41 +00:00
d94f42f6e2
This package provides access to an operating system resource
(cryptographic numbers) and so needs to be replaced with a TinyGo
version that does this in a different way.
I've made the following choices while adding this feature:
- I'm using the getentropy call whenever possible (most POSIX like
systems), because it is easier to use and more reliable. Linux is
the exception: it only added getentropy relatively recently.
- I've left bare-metal implementations to a future patch. This because
it's hard to reliably get cryptographically secure random numbers on
embedded devices: most devices do not have a hardware PRNG for this
purpose.
20 lines
586 B
Go
20 lines
586 B
Go
// Copyright 2010 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Package rand implements a cryptographically secure
|
|
// random number generator.
|
|
package rand
|
|
|
|
import "io"
|
|
|
|
// Reader is a global, shared instance of a cryptographically
|
|
// secure random number generator.
|
|
var Reader io.Reader
|
|
|
|
// Read is a helper function that calls Reader.Read using io.ReadFull.
|
|
// On return, n == len(b) if and only if err == nil.
|
|
func Read(b []byte) (n int, err error) {
|
|
return io.ReadFull(Reader, b)
|
|
}
|