Package org.bouncycastle.crypto.util
Class EntropyUtil
java.lang.Object
org.bouncycastle.crypto.util.EntropyUtil
Utility methods for making use of EntropySources.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic EntropyUtil.WindowStats
Create an initial stats object.static byte[]
generateSeed
(EntropySource entropySource, int numBytes) Generate numBytes worth of entropy from the passed in entropy source.static String
isNotStuck
(byte prev, byte[] current) SP 800-90B, 4.4.1: Return true if the entropy source is stuck.static String
isProportionate
(EntropyUtil.WindowStats stats, byte[] current) SP 800-90B, 4.4.2: Return true if the entropy is proportionate.
-
Constructor Details
-
EntropyUtil
public EntropyUtil()
-
-
Method Details
-
generateSeed
Generate numBytes worth of entropy from the passed in entropy source.- Parameters:
entropySource
- the entropy source to request the data from.numBytes
- the number of bytes of entropy requested.- Returns:
- a byte array populated with the random data.
-
isNotStuck
SP 800-90B, 4.4.1: Return true if the entropy source is stuck. By default this will be C calculated for alpha=20, with a H value of 8. The default C value can be set using "org.bouncycastle.ent.stkC".- Parameters:
prev
- the last byte of the previous buffer.current
- the current set of entropy samples.- Returns:
- null if there's no issue, an error message if there is.
-
isProportionate
SP 800-90B, 4.4.2: Return true if the entropy is proportionate. By default this will be for alpha=20, with a H value of 8. The C value can be set using "org.bouncycastle.ent.adptC"- Parameters:
current
- the current sampling of entropy to scan.- Returns:
- null if there's no issue, an error message if there is.
-
createStats
Create an initial stats object.- Returns:
- a WindowStats object.
-