Enum Class XdhSpec
- All Implemented Interfaces:
Serializable, Comparable<XdhSpec>, Constable, Describable, AlgorithmKeySpec, ContextSpec
Specification for X25519 and X448 Diffie-Hellman over Montgomery-form
elliptic curves.
XdhSpec enumerates the parameter sets supported by the JCA "XDH"
interface: X25519 and X448. Each constant binds a
KeyPairGenerator name (for key generation and import) and a
KeyAgreement name (for computing shared secrets).
Usage
// Generate a key pair for X25519
KeyPair kp = session.keyBuilders().asymmetric().generateKeyPair("XDH", XdhSpec.X25519);
// Perform key agreement
AgreementContext ctx = session.createContext("XDH", KeyUsage.AGREEMENT,
kp.getPrivate(), XdhSpec.X25519);
ctx.setPeerPublic(peerPublicKey);
byte[] sharedSecret = ctx.deriveSecret();
Design notes
- Both variants share the JCA key-agreement name
"XDH", but have distinct keypair generator names:"X25519"and"X448". - The spec acts as a
ContextSpecto configure context creation, and as anAlgorithmKeySpecto drive key generation. - Always apply a KDF to the raw shared secret before use as a symmetric key.
- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionReturns a short, human-readable description of this object.Returns the canonical JCA name forKeyAgreement.kpgName()Returns the canonical JCA name forKeyPairGenerator.static XdhSpecReturns the enum constant of this class with the specified name.static XdhSpec[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
X25519
X25519 Diffie-Hellman over Curve25519. -
X448
X448 Diffie-Hellman over Curve448.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
kpgName
Returns the canonical JCA name forKeyPairGenerator.- Returns:
- generator name, e.g.
"X25519"or"X448"
-
keyAgreementName
Returns the canonical JCA name forKeyAgreement.- Returns:
- agreement algorithm name, typically
"XDH"
-
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
-