use srandom and prandom on openbsd

/dev/random is reserved for hardware rngs..
db4
Doug Coleman 2008-03-30 06:45:38 -05:00
parent ea12d45337
commit 883c54e077
1 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,6 @@
USING: alien.c-types io io.files io.nonblocking kernel
namespaces random io.encodings.binary singleton init
accessors ;
accessors system ;
IN: random.unix
TUPLE: unix-random path ;
@ -15,7 +15,14 @@ C: <unix-random> unix-random
M: unix-random random-bytes* ( n tuple -- byte-array )
path>> file-read-unbuffered ;
[
"/dev/random" <unix-random> secure-random-generator set-global
"/dev/urandom" <unix-random> insecure-random-generator set-global
] "random.unix" add-init-hook
os "openbsd" = [
[
"/dev/srandom" <unix-random> secure-random-generator set-global
"/dev/prandom" <unix-random> insecure-random-generator set-global
] "random.unix" add-init-hook
] [
[
"/dev/random" <unix-random> secure-random-generator set-global
"/dev/urandom" <unix-random> insecure-random-generator set-global
] "random.unix" add-init-hook
] if