You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles (Jira)" <ji...@apache.org> on 2019/08/30 12:35:00 UTC

[jira] [Comment Edited] (RNG-19) System generator (/dev/random)

    [ https://issues.apache.org/jira/browse/RNG-19?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16919499#comment-16919499 ] 

Gilles edited comment on RNG-19 at 8/30/19 12:34 PM:
-----------------------------------------------------

If the aim is to be able to use the "native" generator through the {{UniformRandomProvider}} API, we could implement a wrapper similar to [{{JDKRandom}}|https://gitbox.apache.org/repos/asf?p=commons-rng.git;a=blob;f=commons-rng-core/src/main/java/org/apache/commons/rng/core/source32/JDKRandom.java]:
{code:java}
public class JDKSecureRandom extends IntProvider {
    private SecureRandom delegate;
    public class JDKSecureRandom(long[] seed) {
        final byte[] s = NumberFactory.makeByteArray(seed);
        delegate = new SecureRandom(s);
    }
    // ... (same as in "JDKRandom")
}
{code}
where we'd use the constructor that builds the [default instance|https://docs.oracle.com/javase/8/docs/api/java/security/SecureRandom.html#SecureRandom-byte:A-] so that the wrapper is usable on all OSes that support the JDK.


was (Author: erans):
If the aim is to be able to use the "native" generator through the {{UniformRandomProvider}} API, we could implement a wrapper similar to [{{JDKRandom}}|https://gitbox.apache.org/repos/asf?p=commons-rng.git;a=blob;f=commons-rng-core/src/main/java/org/apache/commons/rng/core/source32/JDKRandom.java]:
{code:java}
public class JDKSecureRandom extends IntProvider {
    private SecureRandom delegate;
    public class JDKSecureRandom(Long[] seed) {
        final byte[] s = NumberFactory.makeByteArray(seed);
        delegate = new SecureRandom(s);
    }
    // ... (same as in "JDKRandom")
}
{code}
where we'd use the constructor that builds the [default instance|https://docs.oracle.com/javase/8/docs/api/java/security/SecureRandom.html#SecureRandom-byte:A-] so that the wrapper is usable on all OSes that support the JDK.

> System generator (/dev/random)
> ------------------------------
>
>                 Key: RNG-19
>                 URL: https://issues.apache.org/jira/browse/RNG-19
>             Project: Commons RNG
>          Issue Type: Wish
>            Reporter: Emmanuel Bourg
>            Priority: Minor
>
> Commons RNG could include a random number generator based on the output of /dev/random or /dev/urandom on Unix systems.
> Commons Crypto has an implementation that could be used as a starting point:
> https://github.com/apache/commons-crypto/blob/master/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java



--
This message was sent by Atlassian Jira
(v8.3.2#803003)