diff --git a/extra/bootstrap/random/random.factor b/extra/bootstrap/random/random.factor index 782cf16e9e..5f5e11d913 100755 --- a/extra/bootstrap/random/random.factor +++ b/extra/bootstrap/random/random.factor @@ -10,6 +10,6 @@ namespaces random ; } cond [ - [ 32 random-bits ] with-secure-random + [ 32 random-bits ] with-system-random random-generator set-global ] "generator.random" add-init-hook diff --git a/extra/random/random.factor b/extra/random/random.factor index b1c57ede60..b4b6ad9aff 100755 --- a/extra/random/random.factor +++ b/extra/random/random.factor @@ -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 diff --git a/extra/random/unix/unix.factor b/extra/random/unix/unix.factor index 6a72baa21b..6016a6e9cb 100644 --- a/extra/random/unix/unix.factor +++ b/extra/random/unix/unix.factor @@ -18,11 +18,11 @@ M: unix-random random-bytes* ( n tuple -- byte-array ) os openbsd? [ [ "/dev/srandom" secure-random-generator set-global - "/dev/prandom" insecure-random-generator set-global + "/dev/arandom" system-random-generator set-global ] "random.unix" add-init-hook ] [ [ "/dev/random" secure-random-generator set-global - "/dev/urandom" insecure-random-generator set-global + "/dev/urandom" system-random-generator set-global ] "random.unix" add-init-hook ] if diff --git a/extra/random/windows/windows.factor b/extra/random/windows/windows.factor index 65426d4277..6f47d3e6bf 100644 --- a/extra/random/windows/windows.factor +++ b/extra/random/windows/windows.factor @@ -44,7 +44,7 @@ M: windows-rng random-bytes* ( n tuple -- bytes ) [ MS_DEF_PROV - PROV_RSA_FULL insecure-random-generator set-global + PROV_RSA_FULL system-random-generator set-global MS_STRONG_PROV PROV_RSA_FULL secure-random-generator set-global