Enum Class XdhSpec

java.lang.Object
java.lang.Enum<XdhSpec>
zeroecho.core.alg.xdh.XdhSpec
All Implemented Interfaces:
Serializable, Comparable<XdhSpec>, Constable, Describable, AlgorithmKeySpec, ContextSpec

public enum XdhSpec extends Enum<XdhSpec> implements ContextSpec, AlgorithmKeySpec, Describable
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 ContextSpec to configure context creation, and as an AlgorithmKeySpec to drive key generation.
  • Always apply a KDF to the raw shared secret before use as a symmetric key.
Since:
1.0
  • Enum Constant Details

    • X25519

      public static final XdhSpec X25519
      X25519 Diffie-Hellman over Curve25519.
    • X448

      public static final XdhSpec X448
      X448 Diffie-Hellman over Curve448.
  • Method Details

    • values

      public static XdhSpec[] 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

      public static XdhSpec valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • kpgName

      public String kpgName()
      Returns the canonical JCA name for KeyPairGenerator.
      Returns:
      generator name, e.g. "X25519" or "X448"
    • keyAgreementName

      public String keyAgreementName()
      Returns the canonical JCA name for KeyAgreement.
      Returns:
      agreement algorithm name, typically "XDH"
    • 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