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
KeyAgreementAPI 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
AgreementContextbacked byKeyAgreement; constructed with a local private key and configured using a JCA algorithm name and optional provider. - KemMessageAgreementAdapter: a
MessageAgreementContextbuilt on aKemContext, 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
-
ClassDescriptionGeneric JCA-based Key Agreement ContextAdapter: using a KEM as a message-based agreement primitiveBuilder for
KemMessageAgreementAdapter.Role of the adapter: initiator or responder.