Class ElgamalAlgorithm
ElGamal Asymmetric Encryption Algorithm
ConcreteCryptoAlgorithm for the ElGamal public-key
encryption scheme.
ElGamal is an asymmetric cryptosystem based on the hardness of the discrete
logarithm problem in a finite cyclic group. It provides semantic security
under chosen-plaintext attacks when combined with proper padding (e.g.,
PKCS#1 style). This implementation delegates to the Bouncy Castle provider
("BC") for underlying primitives and parameter generation.
Note: OAEP is not offered for ElGamal; for modern IND-CCA security prefer KEM or KEM-DEM constructions such as DHIES, ECIES, or Cramer-Shoup, or use a KEM provided elsewhere in the catalog.
Declared capabilities
KeyUsage.ENCRYPTusing aPublicKeyand producing anEncryptionContext.KeyUsage.DECRYPTusing aPrivateKeyand producing anEncryptionContext.
Key material
ElgamalParamSpec- wrapper for explicit ElGamal group/domain parameters. Registered with a default ofElgamalParamSpec.ffdhe2048().ElgamalPublicKeySpec- X.509-encoded public key import.ElgamalPrivateKeySpec- PKCS#8-encoded private key import.ElgamalKeyGenSpechas no registered generator because random parameter generation is slow; generator lookup rejects it withIllegalArgumentException. Use standardizedElgamalParamSpecinstances.
Provider requirements
This implementation requires the Bouncy Castle JCE provider to be registered under the name"BC". If unavailable,
ensureBC() will throw a
NoSuchProviderException.
Thread-safety
Instances ofElgamalAlgorithm are immutable
and may be safely shared across threads. Generated
CryptoContext instances are not necessarily
thread-safe.
Example
CryptoAlgorithm algo = new ElgamalAlgorithm();
KeyPair kp = algo.asymmetricKeyPairGenerator(ElgamalParamSpec.class)
.generateKeyPair(ElgamalParamSpec.ffdhe2048());
EncryptionContext enc = algo.createContext(KeyUsage.ENCRYPT, kp.getPublic(),
ElgamalEncSpec.pkcs1());
EncryptionContext dec = algo.createContext(KeyUsage.DECRYPT, kp.getPrivate(),
ElgamalEncSpec.pkcs1());
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new ElGamal algorithm instance bound to the"ElGamal"identifier and backed by the Bouncy Castle provider. -
Method Summary
Modifier and TypeMethodDescriptionList<ParameterSetDescriptor<? extends AlgorithmKeySpec>> Returns the discoverable parameter sets (or parameterized templates) supported by this algorithm.Methods inherited from class AbstractCryptoAlgorithm
capabilityMethods inherited from class CryptoAlgorithm
addCapability, asymmetricKeyPairGenerator, bindContext, createContext, displayName, id, keyOperations, listCapabilities, priority, privateKeyImporter, providerName, publicKeyImporter, registerAsymmetricKeyPairGenerator, registerPrivateKeyImporter, registerPublicKeyImporter, registerSymmetricKeyGenerator, registerSymmetricKeyImporter, requiresStatefulSigning, roles, supports, symmetricKeyGenerator, symmetricKeyImporter
-
Constructor Details
-
ElgamalAlgorithm
public ElgamalAlgorithm()Constructs a new ElGamal algorithm instance bound to the"ElGamal"identifier and backed by the Bouncy Castle provider.During construction, the algorithm registers:
- Encryption and decryption capabilities,
- Key builders for parameter-based, public, and private key specs,
- Default parameter spec suppliers (e.g., ffdhe2048).
-
-
Method Details
-
parameterSets
Description copied from class:CryptoAlgorithmReturns the discoverable parameter sets (or parameterized templates) supported by this algorithm.Callers (UIs, provisioning tools, policy engines) use this list to present users with valid, named key-generation options without prior knowledge of the concrete algorithm. Each entry is either a pre-built
ParameterSetDescriptor.Concrete(ready spec) or aParameterSetDescriptor.Template(user-supplied arguments produce the spec).The default implementation returns an empty list. Algorithms with finite, enumerable parameter sets should override this method. Overrides must return immutable lists in stable order, with unique nonblank descriptor identifiers. Registry loading validates a snapshot; external providers remain responsible for maintaining the contract on subsequent calls. Implementations may use
ParameterSetDescriptor.snapshot(List)to validate and copy their list.- Overrides:
parameterSetsin classCryptoAlgorithm- Returns:
- immutable list of parameter set descriptors; never
null
-