Package zeroecho.core.alg.common.agreement


package zeroecho.core.alg.common.agreement
Adapters and generic contexts for key agreement built on the core SPI.

This package provides a generic JCA-backed agreement context and a thin adapter that exposes a KEM as a message-based agreement primitive. The goal is to keep provider-specific details encapsulated while presenting clear roles and lifecycles that higher layers can compose.

Scope and responsibilities

  • Expose a generic agreement context that delegates to the JCA KeyAgreement API for algorithms such as ECDH and XDH.
  • Adapt KEM contexts to a two-message agreement API suitable for initiator/ responder protocols.
  • Preserve clear separation between algorithm descriptors, runtime contexts, and higher-level composition utilities.

Components

  • GenericJcaAgreementContext: an AgreementContext backed by KeyAgreement; constructed with a local private key and configured using a JCA algorithm name and optional provider.
  • KemMessageAgreementAdapter: a MessageAgreementContext built on a KemContext, modeling initiator/responder roles and exchanging a single peer message (ciphertext) when required.

Lifecycle and usage notes

  • Agreement contexts should be created with the correct local key and configured before deriving secrets; KDF application remains the caller's responsibility.
  • KEM-based adapters encapsulate or decapsulate depending on role and memoize results for repeated reads within a single exchange.
  • Instances are not thread-safe; synchronize externally if they are shared.
Since:
1.0