Class DhSpec
- All Implemented Interfaces:
Describable, AlgorithmKeySpec, ContextSpec
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
ffdhe2048()- ~112-bit security, suitable minimum baseline.ffdhe3072()- ~128-bit security, recommended general-purpose.ffdhe4096()- ~150-bit security.ffdhe6144()- ~176-bit security.ffdhe8192()- ~192-bit security, high-assurance environments.
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 Summary
Modifier and TypeMethodDescriptionReturns a short, human-readable description of this object.static DhSpecReturns the standard FFDHE-2048 group.static DhSpecReturns the standard FFDHE-3072 group.static DhSpecReturns the standard FFDHE-4096 group.static DhSpecReturns the standard FFDHE-6144 group.static DhSpecReturns the standard FFDHE-8192 group.params()Returns the underlying JCADHParameterSpec.intsizeBits()Returns the effective bit length of this group.
-
Method Details
-
ffdhe2048
Returns the standard FFDHE-2048 group.Provides ~112-bit classical security, the minimum acceptable baseline for modern use per RFC 7919.
- Returns:
- a
DhSpecwrapping FFDHE-2048 parameters
-
ffdhe3072
Returns the standard FFDHE-3072 group.Provides ~128-bit classical security, recommended for general-purpose long-term deployments.
- Returns:
- a
DhSpecwrapping FFDHE-3072 parameters
-
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
DhSpecwrapping FFDHE-4096 parameters
-
ffdhe6144
Returns the standard FFDHE-6144 group.Provides ~176-bit classical security, suitable for high-value environments requiring extra margin.
- Returns:
- a
DhSpecwrapping FFDHE-6144 parameters
-
ffdhe8192
Returns the standard FFDHE-8192 group.Provides ~192-bit classical security, rarely used but suitable for maximum-assurance deployments.
- Returns:
- a
DhSpecwrapping FFDHE-8192 parameters
-
params
Returns the underlying JCADHParameterSpec.- 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
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:
descriptionin interfaceDescribable- Returns:
- non-null descriptive string
-