[
https://issues.apache.org/jira/browse/RNG-19?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16920903#comment-16920903
]
Alex D Herbert commented on RNG-19:
-----------------------------------
I was under the impression that the wrapper would pass all output from Random
through to the Commons RNG API.
>From UniformRandomProvider the only new methods are nextLong(long) and
>nextBytes(byte[], int, int). The current nextLong(long) algorithm matches
>that in the JDK (for ThreadLocalRandom/SplittableRandom) using the modulus
>operator with rejection. The nextBytes(byte[], int, int) method is just
>writing the output from nextBytes(byte[]) to a different array. All other
>methods from UniformRandomProvider are directly supported by Random and so
>will be passed through unchanged.
If you extend IntProvider then you only pass through the 32-bit int output.
This may not be the primary output. In the case of SecureRandom built to read
from {{/dev/urandom}} then the primary output is a byte stream.
Also you would not be able to support save/restore without knowing how the
input Random was created. So no support for RestoreableUniformRandomProvider. A
wrapper does just what it says. It wraps the instance and passes everything
through unchanged.
This would be as follows:
||Name||Source of randomness||API||Notes||Functionality (implementation)||
|JDKRandom|java.util.Random
(nextInt)|RestorableUniformRandomProvider|Synchronized|Commons RNG|
|JDKRandomBridge|Commons RNG
(RandomSource+seed)|java.util.Random|Synchronized|Commons RNG|
|JDKRandomWrapper|java.util.Random |UniformRandomProvider| |java.util.Random |
Note that any use of java.util.Random is synchronized. This is mimicked in the
JDKRandomBridge using a synchronized block. This would not be specified in the
JDKRandomWrapper. It delegates to an underlying Random and so synchronization
will depend on the underlying implementation.
> 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
> Time Spent: 20m
> Remaining Estimate: 0h
>
> 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)