Class EntropyUtil

java.lang.Object
org.bouncycastle.crypto.util.EntropyUtil

public class EntropyUtil extends Object
Utility methods for making use of EntropySources.
  • Constructor Details

    • EntropyUtil

      public EntropyUtil()
  • Method Details

    • generateSeed

      public static byte[] generateSeed(EntropySource entropySource, int numBytes)
      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

      public static String isNotStuck(byte prev, byte[] current)
      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

      public static String isProportionate(EntropyUtil.WindowStats stats, byte[] current)
      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

      public static EntropyUtil.WindowStats createStats()
      Create an initial stats object.
      Returns:
      a WindowStats object.