java.lang.Object
java.util.Random
com.aoapps.io.posix.linux.DevRandom
- All Implemented Interfaces:
Serializable
This class acts as a direct source of Random data from
/dev/random
on Linux
platforms. Many of these calls are platform-specific and use the included libaocode.so
Linux shared library provided as a resource. The source code is also supplied.
Please note that reading will block when random data is not available. Use only
where the highest quality random data is required and possible delays are acceptable.- Author:
- AO Industries, Inc.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The device file path used to obtain and add random data.static final PosixFile
The device file used to obtain and add random data.static final String
The device file path used to obtain the entropy statistics.static final PosixFile
The device file used to obtain the entropy statistics.static final String
The device file path used to obtain the pool size.static final PosixFile
The device file used to obtain the pool size. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addEntropy
(byte[] randomData) Adds random entropy to the kernel.static void
Closes theFileInputStream
that reads from/dev/random
.static int
Gets the number of random bits currently available in the kernel.static int
Gets the number of bits in the random pool in the kernel.static void
Manually adds entropy to the kernel, reads from standard in.protected int
next
(int bits) boolean
void
nextBytes
(byte[] bytes) void
nextBytes
(byte[] bytes, int off, int len) SeenextBytes(byte[])
.static void
nextBytesStatic
(byte[] bytes) Static implementation ofnextBytes(byte[])
.static void
nextBytesStatic
(byte[] bytes, int off, int len) Static implementation ofnextBytes(byte[], int, int)
.int
nextInt()
long
nextLong()
static FileInputStream
Opens theFileInputStream
that reads from/dev/random
.void
setSeed
(long seed) This class does not use this seed value.
-
Field Details
-
DEV_RANDOM_PATH
The device file path used to obtain and add random data.- See Also:
-
devRandomUF
The device file used to obtain and add random data. -
ENTROPY_AVAIL_PATH
The device file path used to obtain the entropy statistics.- See Also:
-
entropyAvailUF
The device file used to obtain the entropy statistics. -
POOL_SIZE_PATH
The device file path used to obtain the pool size.- See Also:
-
poolSizeUF
The device file used to obtain the pool size.
-
-
Constructor Details
-
DevRandom
public DevRandom()
-
-
Method Details
-
openDevRandomIn
Opens theFileInputStream
that reads from/dev/random
.- Throws:
IOException
-
closeDevRandomIn
Closes theFileInputStream
that reads from/dev/random
.- Throws:
IOException
-
getEntropyAvail
Gets the number of random bits currently available in the kernel.- Throws:
IOException
-
getPoolSize
Gets the number of bits in the random pool in the kernel.- Throws:
IOException
-
addEntropy
Adds random entropy to the kernel.- Throws:
IOException
-
setSeed
public void setSeed(long seed) This class does not use this seed value. -
next
protected int next(int bits) -
nextBoolean
public boolean nextBoolean()- Overrides:
nextBoolean
in classRandom
-
nextBytes
public void nextBytes(byte[] bytes) -
nextBytes
public void nextBytes(byte[] bytes, int off, int len) SeenextBytes(byte[])
. -
nextBytesStatic
public static void nextBytesStatic(byte[] bytes) Static implementation ofnextBytes(byte[])
. -
nextBytesStatic
public static void nextBytesStatic(byte[] bytes, int off, int len) Static implementation ofnextBytes(byte[], int, int)
. -
nextInt
public int nextInt() -
nextLong
public long nextLong() -
main
Manually adds entropy to the kernel, reads from standard in.
-