Record Class SecurityLevel

java.lang.Object
java.lang.Record
zeroecho.core.SecurityLevel
Record Components:
nistLevel - optional NIST security category, from 1 to 5
classicalBits - positive classical security strength in bits

public record SecurityLevel(OptionalInt nistLevel, int classicalBits) extends Record
Security level of a cryptographic algorithm or parameter set.

Dual representation supports both classical and NIST PQC levels:

  • nistLevel() — NIST PQC security category (1–5), or empty for classical-only algorithms.
  • classicalBits() — equivalent classical security in bits (e.g., 128, 192, 256).

Construction

  • classical(int) — classical algorithms (RSA, AES, ECDSA …) where no NIST PQC category applies.
  • nist(int, int) — post-quantum parameter sets with a defined NIST category.

NIST PQC categories

Level 1 ≈ 128-bit classical  (AES-128 search)
Level 2 ≈ 128-bit (stronger collision requirement)
Level 3 ≈ 192-bit classical  (AES-192 search)
Level 4 ≈ 192-bit (stronger collision requirement)
Level 5 ≈ 256-bit classical  (AES-256 search)
Since:
1.0
  • Constructor Details

    • SecurityLevel

      public SecurityLevel(OptionalInt nistLevel, int classicalBits)
      Validates the record fields on construction.
      Throws:
      NullPointerException - if nistLevel is null
      IllegalArgumentException - if classicalBits is not positive, or if a NIST level is present but not in [1, 5]
  • Method Details

    • classical

      public static SecurityLevel classical(int bits)
      Creates a classical-only security level with no NIST PQC category.
      Parameters:
      bits - classical security strength in bits (must be positive)
      Returns:
      a SecurityLevel with an empty nistLevel
    • nist

      public static SecurityLevel nist(int nistCategory, int classicalBits)
      Creates a post-quantum security level with a NIST PQC category.
      Parameters:
      nistCategory - NIST security category (1–5)
      classicalBits - equivalent classical security in bits (must be positive)
      Returns:
      a SecurityLevel with the given NIST category
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • nistLevel

      public OptionalInt nistLevel()
      Returns the value of the nistLevel record component.
      Returns:
      the value of the nistLevel record component
    • classicalBits

      public int classicalBits()
      Returns the value of the classicalBits record component.
      Returns:
      the value of the classicalBits record component