Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
3476c231
Commit
3476c231
authored
Jun 06, 2012
by
Markus Sonderegger
Committed by
Russ Cox
Jun 06, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto/rand: enable rand.Reader on plan9
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/6297044
parent
fe80cf0f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
rand_unix.go
src/pkg/crypto/rand/rand_unix.go
+15
-5
No files found.
src/pkg/crypto/rand/rand_unix.go
View file @
3476c231
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin freebsd linux netbsd openbsd
// +build darwin freebsd linux netbsd openbsd
plan9
// Unix cryptographically secure pseudorandom number
// generator.
...
...
@@ -15,6 +15,7 @@ import (
"crypto/cipher"
"io"
"os"
"runtime"
"sync"
"time"
)
...
...
@@ -22,7 +23,13 @@ import (
// Easy implementation: read from /dev/urandom.
// This is sufficient on Linux, OS X, and FreeBSD.
func
init
()
{
Reader
=
&
devReader
{
name
:
"/dev/urandom"
}
}
func
init
()
{
if
runtime
.
GOOS
==
"plan9"
{
Reader
=
newReader
(
nil
)
}
else
{
Reader
=
&
devReader
{
name
:
"/dev/urandom"
}
}
}
// A devReader satisfies reads by reading the file named name.
type
devReader
struct
{
...
...
@@ -39,14 +46,17 @@ func (r *devReader) Read(b []byte) (n int, err error) {
if
f
==
nil
{
return
0
,
err
}
r
.
f
=
bufio
.
NewReader
(
f
)
if
runtime
.
GOOS
==
"plan9"
{
r
.
f
=
f
}
else
{
r
.
f
=
bufio
.
NewReader
(
f
)
}
}
return
r
.
f
.
Read
(
b
)
}
// Alternate pseudo-random implementation for use on
// systems without a reliable /dev/urandom. So far we
// haven't needed it.
// systems without a reliable /dev/urandom.
// newReader returns a new pseudorandom generator that
// seeds itself by reading from entropy. If entropy == nil,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment