Class RandomValueVerifier

java.lang.Object
com.digicert.validation.random.RandomValueVerifier

public class RandomValueVerifier extends Object
Verifies the validity and entropy of random values.

This class ensures that random values meet the required entropy and are within the validity period.

  • Field Details

    • MIN_ALLOWED_ENTROPY_VALUE

      private static final int MIN_ALLOWED_ENTROPY_VALUE
      BR version 1.3.8 requires 112 bits of entropy

      This constant defines the minimum entropy value required for a random value to be considered secure. The value is based on the Baseline Requirements (BR) version 1.3.8, which mandates a minimum of 112 bits of entropy for cryptographic security.

      See Also:
    • perCharacterEntropy

      private final double perCharacterEntropy
      Calculate and cache the entropy per character in the constructor to save time when validating random values

      This field stores the entropy per character, which is calculated once during the construction of the object.

    • randomValueValidityPeriod

      private final int randomValueValidityPeriod
      Default validity period for random value is 30 days

      This field defines the default validity period for a random value, which is set to 30 days.

  • Constructor Details

    • RandomValueVerifier

      public RandomValueVerifier(DcvContext dcvContext)
      Constructs a new RandomValueVerifier with the specified configuration.
      Parameters:
      dcvContext - context where we can find the needed dependencies / configuration

      This constructor initializes the RandomValueVerifier with the given DCV context.

  • Method Details

    • verifyRandomValue

      public void verifyRandomValue(String randomValue, Instant prepareTime) throws DcvException
      Verifies the given random value for validity and entropy.
      Parameters:
      randomValue - The random value to verify.
      prepareTime - The time when the random value was prepared.
      Throws:
      DcvException - If the random value is invalid or has insufficient entropy.
    • calculatePerCharacterEntropy

      private double calculatePerCharacterEntropy(RandomValueGenerator randomValueGenerator)
      Calculates the entropy per character for the given random value generator.
      Parameters:
      randomValueGenerator - The random value generator to use for calculating entropy.
      Returns:
      The entropy per character.
    • isEntropySufficient

      private boolean isEntropySufficient(String randomValue)
      Checks if the given random value has sufficient entropy.
      Parameters:
      randomValue - The random value to check.
      Returns:
      True if the random value has sufficient entropy, false otherwise.

      This method evaluates whether the provided random value has sufficient entropy to meet security requirements.