Package zeroecho.core.alg.elgamal
package zeroecho.core.alg.elgamal
ElGamal asymmetric encryption integration.
This package provides the ElGamal algorithm descriptor, a streaming cipher context, configuration specifications for padding and parameters, and encoded key specifications for import/export. Provider-specific details are kept behind small factories while roles and metadata remain explicit to higher layers.
Scope and responsibilities
- Register ElGamal under a canonical identifier and declare
KeyUsage.ENCRYPTandKeyUsage.DECRYPTroles. - Offer a streaming
EncryptionContextthat performs block-wise ElGamal transforms with selectable padding. - Expose specifications for padding modes and for explicit domain parameters, plus utility specs for encoded key import.
- Encapsulate JCA/JCE interop and provider checks inside the algorithm descriptor and builders.
Components
- ElgamalAlgorithm: algorithm descriptor that wires roles to the streaming cipher context and registers key builders for explicit parameter sets and encoded keys.
- ElgamalCipherContext: streaming context that encrypts or decrypts data using ElGamal with block geometry derived from the modulus size and selected padding.
- ElgamalEncSpec: immutable padding specification selecting either no padding or PKCS#1 v1.5-style padding.
- ElgamalParamSpec: immutable wrapper for explicit domain parameters (modulus and generator), including a predefined RFC 7919 FFDHE2048 set.
- ElgamalKeyGenSpec: parameters for generating fresh domain parameters and key pairs; typically disabled in favor of predefined parameter sets.
- ElgamalPublicKeySpec / ElgamalPrivateKeySpec: encoded key specifications (X.509 and PKCS#8) with defensive copying and compact marshalling helpers; the private-key form is destroyable.
Design notes
- Algorithm descriptors are immutable and thread-safe; cipher contexts are stateful and not thread-safe.
- Padding choice affects plaintext-per-block and security properties; modern protocols should prefer KEM-based constructions for IND-CCA security.
- Encoded key specs clone input and output arrays to avoid leaking internal state.
- Since:
- 1.0
-
ClassDescriptionElGamal Asymmetric Encryption AlgorithmStreaming ElGamal cipher context that adapts an upstream stream into an encrypted or decrypted stream.ElGamal Encryption ParametersSupported padding modes for ElGamal encryption.ElGamal Key Generation SpecificationElGamal Parameter SpecificationElGamal Private Key SpecificationElGamal Public Key Specification