LegacyBitsOfSecurityConstraint (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.crypto.constraints

## Class LegacyBitsOfSecurityConstraint

- java.lang.Object
- - org.bouncycastle.crypto.constraints.ServicesConstraint
  - - org.bouncycastle.crypto.constraints.LegacyBitsOfSecurityConstraint

- All Implemented Interfaces:
    CryptoServicesConstraints

      public class LegacyBitsOfSecurityConstraint
      extends ServicesConstraint

  Legacy bits of security constraint. By default, legacy algorithms are all acceptable but can only be used for decryption and verification tasks. Algorithms with the required bits of security can be used for anything. If a minimum level of security is given for legacy algorithms, then anything below that will be treated as an error unless it appears in the exception list.

- - ### Field Summary

    - ### Fields inherited from class org.bouncycastle.crypto.constraints.ServicesConstraint

      `LOG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LegacyBitsOfSecurityConstraint(int requiredBitsOfSecurity)` Base constructor, legacy level is set to 0.
    `LegacyBitsOfSecurityConstraint(int requiredBitsOfSecurity, int legacyRequiredBitsOfSecurity)` Provide required bits of security and legacy requirements.
    `LegacyBitsOfSecurityConstraint(int requiredBitsOfSecurity, int legacyRequiredBitsOfSecurity, java.util.Set<java.lang.String> exceptions)` Provide required bits of security, legacy requirements, and a set of exceptions.
    `LegacyBitsOfSecurityConstraint(int requiredBitsOfSecurity, java.util.Set<java.lang.String> exceptions)` Provide required bits of security, and a set of exceptions.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `check(CryptoServiceProperties service)`

    - ### Methods inherited from class org.bouncycastle.crypto.constraints.ServicesConstraint

      `isException`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LegacyBitsOfSecurityConstraint

          public LegacyBitsOfSecurityConstraint(int requiredBitsOfSecurity)

      Base constructor, legacy level is set to 0.
      Parameters:
        `requiredBitsOfSecurity` - required bits of security for encryption and signing operations.

    - #### LegacyBitsOfSecurityConstraint

          public LegacyBitsOfSecurityConstraint(int requiredBitsOfSecurity,
                                                int legacyRequiredBitsOfSecurity)

      Provide required bits of security and legacy requirements.
      Parameters:
        `requiredBitsOfSecurity` - required bits of security for encryption and signing operations.
        `legacyRequiredBitsOfSecurity` - acceptable bits of security for decryption and verification operations.

    - #### LegacyBitsOfSecurityConstraint

          public LegacyBitsOfSecurityConstraint(int requiredBitsOfSecurity,
                                                java.util.Set<java.lang.String> exceptions)

      Provide required bits of security, and a set of exceptions. Legacy requirement will default to 0.
      Parameters:
        `requiredBitsOfSecurity` - required bits of security for encryption and signing operations.
        `exceptions` - set service names which are exceptions to the above rules.

    - #### LegacyBitsOfSecurityConstraint

          public LegacyBitsOfSecurityConstraint(int requiredBitsOfSecurity,
                                                int legacyRequiredBitsOfSecurity,
                                                java.util.Set<java.lang.String> exceptions)

      Provide required bits of security, legacy requirements, and a set of exceptions.
      Parameters:
        `requiredBitsOfSecurity` - required bits of security for encryption and signing operations.
        `legacyRequiredBitsOfSecurity` - acceptable bits of security for decryption and verification operations.
        `exceptions` - set service names which are exceptions to the above rules.

  - ### Method Detail

    - #### check

          public void check(CryptoServiceProperties service)