Class ElgamalEncSpec

java.lang.Object
zeroecho.core.alg.elgamal.ElgamalEncSpec
All Implemented Interfaces:
Describable, ContextSpec

public final class ElgamalEncSpec extends Object implements ContextSpec, Describable

ElGamal Encryption Parameters

Specification for configuring ElGamal encryption contexts.

ElgamalEncSpec selects the padding mode to apply when transforming plaintext into group elements for ElGamal encryption. This affects both security properties and maximum plaintext block size.

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.

Padding modes

  • ElgamalEncSpec.Padding.NOPADDING - raw ElGamal encryption of messages less than the modulus p. Provides minimal security (plaintexts are only randomized by ephemeral exponent) and must not be used directly in modern protocols without additional safeguards (e.g., hybrid encryption or KEM construction).
  • ElgamalEncSpec.Padding.PKCS1 - PKCS#1 v1.5-style padding applied to the plaintext before encryption. Adds structural redundancy and prevents trivial small-subgroup attacks. Still considered outdated for new protocols but available for compatibility.

Usage

Instances are created via the static factories:
ElgamalEncSpec spec = ElgamalEncSpec.pkcs1();
EncryptionContext ctx = algo.createContext(KeyUsage.ENCRYPT, pubKey, spec);

Thread-safety

ElgamalEncSpec is immutable and safe to share across threads.
Since:
1.0
  • Method Details

    • noPadding

      public static ElgamalEncSpec noPadding()
      Returns an ElgamalEncSpec with no padding.
      Returns:
      specification with ElgamalEncSpec.Padding.NOPADDING
    • pkcs1

      public static ElgamalEncSpec pkcs1()
      Returns an ElgamalEncSpec with PKCS#1 v1.5-style padding.
      Returns:
      specification with ElgamalEncSpec.Padding.PKCS1
    • padding

      public ElgamalEncSpec.Padding padding()
      Returns the selected padding mode.
      Returns:
      padding enumeration value
    • description

      public String description()
      Human-readable description of this spec.

      Matches the transformation string used by the JCA provider (e.g., "NOPADDING" or "PKCS1Padding").

      Specified by:
      description in interface Describable
      Returns:
      descriptive string for this padding mode