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
FieldsModifier and TypeFieldDescriptionstatic final StringThe device file path used to obtain and add random data.static final PosixFileThe device file used to obtain and add random data.static final StringThe device file path used to obtain the entropy statistics.static final PosixFileThe device file used to obtain the entropy statistics.static final StringThe device file path used to obtain the pool size.static final PosixFileThe device file used to obtain the pool size. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEntropy(byte[] randomData) Adds random entropy to the kernel.static voidCloses theFileInputStreamthat reads from/dev/random.static intGets the number of random bits currently available in the kernel.static intGets the number of bits in the random pool in the kernel.static voidManually adds entropy to the kernel, reads from standard in.protected intnext(int bits) booleanvoidnextBytes(byte[] bytes) voidnextBytes(byte[] bytes, int off, int len) SeenextBytes(byte[]).static voidnextBytesStatic(byte[] bytes) Static implementation ofnextBytes(byte[]).static voidnextBytesStatic(byte[] bytes, int off, int len) Static implementation ofnextBytes(byte[], int, int).intnextInt()longnextLong()static FileInputStreamOpens theFileInputStreamthat reads from/dev/random.voidsetSeed(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 theFileInputStreamthat reads from/dev/random.- Throws:
IOException
-
closeDevRandomIn
Closes theFileInputStreamthat 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:
nextBooleanin 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.
-
