Fix OpenBSD hang; we were using the blocking RNG to seed MT

db4
Doug Coleman 2008-04-12 21:35:07 -05:00
parent c97e13a236
commit 58fde2efff
4 changed files with 9 additions and 6 deletions

View File

@ -10,6 +10,6 @@ namespaces random ;
} cond
[
[ 32 random-bits ] with-secure-random
[ 32 random-bits ] with-system-random
<mersenne-twister> random-generator set-global
] "generator.random" add-init-hook

View File

@ -5,7 +5,7 @@ io.backend io.binary combinators system vocabs.loader
inspector ;
IN: random
SYMBOL: insecure-random-generator
SYMBOL: system-random-generator
SYMBOL: secure-random-generator
SYMBOL: random-generator
@ -48,5 +48,8 @@ M: f random-32* ( obj -- * ) no-random-number-generator ;
: with-random ( tuple quot -- )
random-generator swap with-variable ; inline
: with-system-random ( quot -- )
system-random-generator get swap with-random ; inline
: with-secure-random ( quot -- )
>r secure-random-generator get r> with-random ; inline
secure-random-generator get swap with-random ; inline

View File

@ -18,11 +18,11 @@ M: unix-random random-bytes* ( n tuple -- byte-array )
os openbsd? [
[
"/dev/srandom" <unix-random> secure-random-generator set-global
"/dev/prandom" <unix-random> insecure-random-generator set-global
"/dev/arandom" <unix-random> system-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
"/dev/urandom" <unix-random> system-random-generator set-global
] "random.unix" add-init-hook
] if

View File

@ -44,7 +44,7 @@ M: windows-rng random-bytes* ( n tuple -- bytes )
[
MS_DEF_PROV
PROV_RSA_FULL <windows-rng> insecure-random-generator set-global
PROV_RSA_FULL <windows-rng> system-random-generator set-global
MS_STRONG_PROV
PROV_RSA_FULL <windows-rng> secure-random-generator set-global