public class Yarrow extends RandomSource implements PersistentRandomSource
This class implements Yarrow-160, a cryptraphically secure PRNG developed by John Kelsey, Bruce Schneier, and Neils Ferguson. It was designed to follow the specification (www.counterpane.com/labs) given in the paper by the same authors, with the following exceptions:
freenet.crypt.Util.makeKey
)Modifier and Type | Field and Description |
---|---|
java.io.File |
seedfile |
Constructor and Description |
---|
Yarrow() |
Yarrow(boolean canBlock) |
Yarrow(java.io.File seed) |
Yarrow(java.io.File seed,
java.lang.String digest,
java.lang.String cipher,
boolean updateSeed,
boolean canBlock) |
Yarrow(java.lang.String seed,
java.lang.String digest,
java.lang.String cipher,
boolean updateSeed,
boolean canBlock) |
Modifier and Type | Method and Description |
---|---|
int |
acceptEntropy(EntropySource source,
long data,
int entropyGuess)
Accepts entropy data from a source
|
int |
acceptEntropyBytes(EntropySource source,
byte[] buf,
int offset,
int length,
double bias)
Accepts larger amounts of entropy data from a source, with a bias
|
int |
acceptTimerEntropy(EntropySource timer)
Accepts entropy in the form of timing data from a source
|
int |
acceptTimerEntropy(EntropySource timer,
double bias)
Accept entropy from a source with a bias
|
void |
close()
If the RandomSource has any resources it wants to close, it can do so
when this method is called
|
static void |
main(java.lang.String[] args)
Test routine
|
protected int |
next(int bits) |
protected void |
readStartupEntropy(EntropySource startupEntropy) |
void |
waitForEntropy(int bits)
If entropy estimation is supported, this method will block until the
specified number of bits of entropy are available.
|
void |
write_seed(boolean force)
Explanation of the purpose of this mechanism is at its interface
PersistentRandomSource . |
nextFullDouble, nextFullFloat
public Yarrow()
public Yarrow(boolean canBlock)
public Yarrow(java.io.File seed)
public Yarrow(java.lang.String seed, java.lang.String digest, java.lang.String cipher, boolean updateSeed, boolean canBlock)
public Yarrow(java.io.File seed, java.lang.String digest, java.lang.String cipher, boolean updateSeed, boolean canBlock)
protected void readStartupEntropy(EntropySource startupEntropy)
public void write_seed(boolean force)
PersistentRandomSource
.write_seed
in interface PersistentRandomSource
force
- If false, the implementation might decide to ignore this function call if the seed file
was written to disk a short time ago already.protected int next(int bits)
next
in class RandomSource
public int acceptEntropy(EntropySource source, long data, int entropyGuess)
RandomSource
acceptEntropy
in class RandomSource
public int acceptEntropyBytes(EntropySource source, byte[] buf, int offset, int length, double bias)
RandomSource
acceptEntropyBytes
in class RandomSource
source
- The source from which the data has come.buf
- The buffer to read bytes from.offset
- The offset to start reading from.length
- The number of bytes to read.bias
- The bias. Value by which we multiply the entropy before counting it.
Must be <= 1.0.public int acceptTimerEntropy(EntropySource timer)
RandomSource
acceptTimerEntropy
in class RandomSource
public int acceptTimerEntropy(EntropySource timer, double bias)
RandomSource
acceptTimerEntropy
in class RandomSource
bias
- Value by which we multiply the entropy before counting it.
Must be <= 1.0.public void waitForEntropy(int bits)
waitForEntropy
in class RandomSource
public void close()
close
in class RandomSource
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception