Class QuantumVulnerableConstraint

java.lang.Object
org.bouncycastle.crypto.constraints.ServicesConstraint
org.bouncycastle.crypto.constraints.QuantumVulnerableConstraint
All Implemented Interfaces:
CryptoServicesConstraints

public class QuantumVulnerableConstraint extends ServicesConstraint
A constraint on the quantum-vulnerable public-key algorithms (RSA, DSA, DH, EC and the Edwards/Montgomery curve schemes, and the KEMs and key agreements built on them) following the transition timetable of NIST IR 8547: a quantum-vulnerable service is allowed until the deprecation date, allowed but logged between the deprecation date and the disallow date, and refused after the disallow date except for "legacy use" - verification and decryption of data protected earlier, which SP 800-131A continues to permit.

The no-argument constructor applies the NIST dates: deprecated after 2030, disallowed after 2035. Any other policy is expressed by passing the dates explicitly; a date in the past deprecates or disallows the algorithms immediately, a date far in the future turns that step off. Services named in the exceptions set are not checked at all.

Three fixed policies are available without dates: logOnly() logs every use of a quantum-vulnerable service and refuses nothing, legacyUseOnly() refuses new protection (key generation, signing, encryption and key agreement) while allowing verification and decryption, and rejectAll() refuses every use, legacy use included. One of them, or the NIST timetable, can also be installed as the default constraint through the Properties.CONSTRAINTS_QUANTUM_VULNERABLE property; see forPolicy(String).

Which services count as quantum-vulnerable is decided by ConstraintUtils.isQuantumVulnerable(CryptoServiceProperties); the post-quantum algorithms (ML-KEM, ML-DSA, SLH-DSA, LMS/HSS, XMSS and the candidates) are never affected. Note that a service reporting the purpose CryptoServicePurpose.ANY cannot be told from a legacy use and is treated as one where legacy use is allowed.

  • Field Details

    • NIST_DEPRECATED_AFTER

      public static final Date NIST_DEPRECATED_AFTER
      1 January 2031, 00:00 UTC: NIST IR 8547 deprecates the quantum-vulnerable public-key algorithms after 2030.
    • NIST_DISALLOWED_AFTER

      public static final Date NIST_DISALLOWED_AFTER
      1 January 2036, 00:00 UTC: NIST IR 8547 disallows the quantum-vulnerable public-key algorithms after 2035.
    • POLICY_NIST

      public static final String POLICY_NIST
      The policy name selecting the NIST IR 8547 timetable, QuantumVulnerableConstraint().
      See Also:
    • POLICY_LOG

      public static final String POLICY_LOG
      The policy name selecting logOnly().
      See Also:
    • POLICY_LEGACY

      public static final String POLICY_LEGACY
      The policy name selecting legacyUseOnly().
      See Also:
    • POLICY_REJECT

      public static final String POLICY_REJECT
      The policy name selecting rejectAll().
      See Also:
    • POLICY_NONE

      public static final String POLICY_NONE
      The policy name selecting no constraint at all.
      See Also:
  • Constructor Details

    • QuantumVulnerableConstraint

      public QuantumVulnerableConstraint()
      Apply the NIST IR 8547 timetable: deprecated after 2030, disallowed after 2035.
    • QuantumVulnerableConstraint

      public QuantumVulnerableConstraint(Set<String> exceptions)
      Apply the NIST IR 8547 timetable with a set of service names that are not checked.
      Parameters:
      exceptions - set of service names which are exceptions to the rules.
    • QuantumVulnerableConstraint

      public QuantumVulnerableConstraint(Date deprecatedAfter, Date disallowedAfter)
      Apply an explicit timetable.
      Parameters:
      deprecatedAfter - the instant from which use of a quantum-vulnerable service is logged.
      disallowedAfter - the instant from which a quantum-vulnerable service is refused for anything other than legacy use.
    • QuantumVulnerableConstraint

      public QuantumVulnerableConstraint(Date deprecatedAfter, Date disallowedAfter, Set<String> exceptions)
      Apply an explicit timetable with a set of service names that are not checked.
      Parameters:
      deprecatedAfter - the instant from which use of a quantum-vulnerable service is logged.
      disallowedAfter - the instant from which a quantum-vulnerable service is refused for anything other than legacy use.
      exceptions - set of service names which are exceptions to the rules.
    • QuantumVulnerableConstraint

      public QuantumVulnerableConstraint(Date deprecatedAfter, Date disallowedAfter, boolean allowLegacyUse, Set<String> exceptions)
      Apply an explicit timetable, choosing whether legacy use survives the disallow date.
      Parameters:
      deprecatedAfter - the instant from which use of a quantum-vulnerable service is logged.
      disallowedAfter - the instant from which a quantum-vulnerable service is refused.
      allowLegacyUse - true if verification and decryption are still allowed after the disallow date, false if they are refused along with everything else.
      exceptions - set of service names which are exceptions to the rules.
  • Method Details

    • logOnly

      public static QuantumVulnerableConstraint logOnly()
      Return a constraint that logs every use of a quantum-vulnerable service, at level INFO, and refuses nothing.
      Returns:
      a log-only constraint.
    • logOnly

      public static QuantumVulnerableConstraint logOnly(Set<String> exceptions)
      Return a constraint that logs every use of a quantum-vulnerable service, at level INFO, and refuses nothing.
      Parameters:
      exceptions - set of service names which are not logged.
      Returns:
      a log-only constraint.
    • legacyUseOnly

      public static QuantumVulnerableConstraint legacyUseOnly()
      Return a constraint that refuses a quantum-vulnerable service for key generation, signing, encryption and key agreement, and allows it, logged, for verification and decryption - the SP 800-131A "legacy use".
      Returns:
      a legacy-use-only constraint.
    • legacyUseOnly

      public static QuantumVulnerableConstraint legacyUseOnly(Set<String> exceptions)
      Return a constraint that refuses a quantum-vulnerable service for key generation, signing, encryption and key agreement, and allows it, logged, for verification and decryption - the SP 800-131A "legacy use".
      Parameters:
      exceptions - set of service names which are not checked.
      Returns:
      a legacy-use-only constraint.
    • rejectAll

      public static QuantumVulnerableConstraint rejectAll()
      Return a constraint that refuses every use of a quantum-vulnerable service, verification and decryption included.
      Returns:
      a reject-all constraint.
    • rejectAll

      public static QuantumVulnerableConstraint rejectAll(Set<String> exceptions)
      Return a constraint that refuses every use of a quantum-vulnerable service, verification and decryption included.
      Parameters:
      exceptions - set of service names which are not checked.
      Returns:
      a reject-all constraint.
    • forPolicy

      public static QuantumVulnerableConstraint forPolicy(String policy)
      Return the constraint a policy name selects: POLICY_NIST for the NIST IR 8547 timetable, POLICY_LOG for logOnly(), POLICY_LEGACY for legacyUseOnly(), POLICY_REJECT for rejectAll() and POLICY_NONE for no constraint. The names are case-insensitive and surrounding white space is ignored. This is how the value of the Properties.CONSTRAINTS_QUANTUM_VULNERABLE property is read.
      Parameters:
      policy - the policy name.
      Returns:
      the constraint, or null for POLICY_NONE.
      Throws:
      IllegalArgumentException - if the name is not one of the above.
    • check

      public void check(CryptoServiceProperties service)