Hello Alex.

Le jeu. 18 juil. 2019 à 13:54, <aherb...@apache.org> a écrit :
>
> This is an automated email from the ASF dual-hosted git repository.
>
> aherbert pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/commons-rng.git
>
>
> The following commit(s) were added to refs/heads/master by this push:
>      new 70c0929  Update SeedFactory use of SecureRandom to non-blocking on 
> Linux systems.
> 70c0929 is described below
>
> commit 70c09297f771771ee341303530c80ca174f10307
> Author: aherbert <aherb...@apache.org>
> AuthorDate: Thu Jul 18 12:54:11 2019 +0100
>
>     Update SeedFactory use of SecureRandom to non-blocking on Linux systems.
>
>     See 
> https://tersesystems.com/blog/2015/12/17/the-right-way-to-use-securerandom/

The above says:
---CUT---
The generateSeed method is not needed for a Native PRNG of any type,
but it IS useful to seed a user space PRNG such as SHA1PRNG.
----CUT---

IIRC, I assumed that when initializing the SeedFactory RNG, we were in
that case.

Regards,
Gilles


> ---
>  .../java/org/apache/commons/rng/simple/internal/SeedFactory.java     | 5 
> +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git 
> a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedFactory.java
>  
> b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedFactory.java
> index 8802622..170c978 100644
> --- 
> a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedFactory.java
> +++ 
> b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedFactory.java
> @@ -68,8 +68,9 @@ public final class SeedFactory {
>          // Use a secure RNG so that different instances (e.g. in multiple JVM
>          // instances started in rapid succession) will have different seeds.
>          final SecureRandom seedGen = new SecureRandom();
> -        final long[] seed = NumberFactory.makeLongArray(
> -                seedGen.generateSeed(8 * XOR_SHIFT_1024_STATE_SIZE));
> +        final byte[] bytes = new byte[8 * XOR_SHIFT_1024_STATE_SIZE];
> +        seedGen.nextBytes(bytes);
> +        final long[] seed = NumberFactory.makeLongArray(bytes);
>          // The XorShift1024StarPhi generator cannot recover from an all zero 
> seed and
>          // will produce low quality initial output if initialised with some 
> zeros.
>          // Ensure it is non zero at all array positions using a SplitMix64
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to