Class DhSpec

java.lang.Object
zeroecho.core.alg.dh.DhSpec
All Implemented Interfaces:
Describable, AlgorithmKeySpec, ContextSpec

public final class DhSpec extends Object implements ContextSpec, AlgorithmKeySpec, Describable

Diffie-Hellman parameter specification

Immutable container for Diffie-Hellman (DH) group parameters and their effective key size.

A DhSpec acts both as a ContextSpec for agreement contexts and as an AlgorithmKeySpec for key generation. Instances wrap a standard DHParameterSpec with a declared bit length. They are typically constructed via the provided factory methods for the RFC 7919 finite-field DH (FFDHE) groups.

Predefined groups

These correspond exactly to the safe-prime groups defined in RFC 7919. Using well-standardized groups avoids parameter negotiation pitfalls and ensures interoperability.

Thread-safety

DhSpec instances are immutable and can be shared freely.

Example

// Create a key pair in the FFDHE-3072 group
KeyPair kp = session.keyBuilders().asymmetric().generateKeyPair("DH", DhSpec.ffdhe3072());

// Establish an agreement context
AgreementContext ctx = session.createContext(
    "DH", KeyUsage.AGREEMENT, kp.getPrivate(), DhSpec.ffdhe3072());
Since:
1.0
  • Method Details

    • ffdhe2048

      public static DhSpec ffdhe2048()
      Returns the standard FFDHE-2048 group.

      Provides ~112-bit classical security, the minimum acceptable baseline for modern use per RFC 7919.

      Returns:
      a DhSpec wrapping FFDHE-2048 parameters
    • ffdhe3072

      public static DhSpec ffdhe3072()
      Returns the standard FFDHE-3072 group.

      Provides ~128-bit classical security, recommended for general-purpose long-term deployments.

      Returns:
      a DhSpec wrapping FFDHE-3072 parameters
    • ffdhe4096

      public static DhSpec ffdhe4096()
      Returns the standard FFDHE-4096 group.

      Provides ~150-bit classical security. Chosen when a moderate increase over 128-bit strength is required.

      Returns:
      a DhSpec wrapping FFDHE-4096 parameters
    • ffdhe6144

      public static DhSpec ffdhe6144()
      Returns the standard FFDHE-6144 group.

      Provides ~176-bit classical security, suitable for high-value environments requiring extra margin.

      Returns:
      a DhSpec wrapping FFDHE-6144 parameters
    • ffdhe8192

      public static DhSpec ffdhe8192()
      Returns the standard FFDHE-8192 group.

      Provides ~192-bit classical security, rarely used but suitable for maximum-assurance deployments.

      Returns:
      a DhSpec wrapping FFDHE-8192 parameters
    • params

      public DHParameterSpec params()
      Returns the underlying JCA DHParameterSpec.
      Returns:
      the DH parameters (prime modulus and generator)
    • sizeBits

      public int sizeBits()
      Returns the effective bit length of this group.

      This value reflects the size of the prime modulus p.

      Returns:
      size of the group modulus in bits
    • description

      public String description()
      Returns a short, human-readable description of this object.

      The description should be concise and stable enough for logging or display purposes, while avoiding exposure of any sensitive information.

      Specified by:
      description in interface Describable
      Returns:
      non-null descriptive string