Package zeroecho.core.alg.xdh


package zeroecho.core.alg.xdh
XDH (X25519/X448) Diffie-Hellman key agreement integration.

This package provides the XDH algorithm descriptor, an agreement context backed by the JCA KeyAgreement API, a key-pair generator, and encoded key specifications for import and export. It focuses on safe defaults and clear separation between algorithm metadata, runtime contexts, and key builders.

Scope and responsibilities

  • Register a canonical XDH algorithm and declare the KeyUsage.AGREEMENT role.
  • Expose a runtime agreement context that derives raw shared secrets suitable for KDF input.
  • Provide key builders for generating key pairs and importing encoded public/private keys.
  • Offer key specifications that defensively copy encoded material and support compact marshalling; private-key specifications are destroyable.

Components

  • XdhAlgorithm: algorithm descriptor that binds the agreement role to a generic JCA-backed context and wires key builders.
  • XdhKeyGenBuilder: key-pair generator using KeyPairGenerator with names supplied by the spec.
  • XdhSpec: enumeration of supported variants (X25519, X448) acting as both context spec and key-gen spec.
  • XdhPublicKeySpec / XdhPrivateKeySpec: wrappers over X.509 and PKCS#8 encodings with defensive copying and simple marshalling helpers.

Behavior and notes

  • Agreement contexts require a local private key and a peer public key before deriving the shared secret; callers must apply a KDF.
  • Algorithm descriptors are immutable and safe to share; contexts are stateful and not thread-safe.
  • Provider selection follows standard JCA lookup unless a specific provider is configured upstream.
Since:
1.0
  • Class
    Description
    Algorithm definition for XDH (elliptic curve Diffie-Hellman) key agreement, backed by the JCA KeyAgreement API.
    KeyPair generator for XDH curves using the JCA KeyPairGenerator SPI.
    Key specification for an XDH (elliptic curve Diffie-Hellman) private key.
    Key specification for an XDH (elliptic curve Diffie-Hellman) public key.
    Specification for X25519 and X448 Diffie-Hellman over Montgomery-form elliptic curves.