public final class ElGamalEngine extends Object
Note: ECIES or post-quantum schemes are preferred for new applications, but this engine remains in active use by existing code.
The encryption process:
| Constructor and Description |
|---|
ElGamalEngine(I2PAppContext context)The ElGamal engine should only be constructed and accessed through the
application context. |
| Modifier and Type | Method and Description |
|---|---|
byte[] | decrypt(byte[] encrypted,
PrivateKey privateKey)Decrypt the data |
byte[] | encrypt(byte[] data,
PublicKey publicKey)encrypt the data to the public key |
void | restart()This is now a noop. |
void | shutdown()Note that this stops the precalc thread and it cannot be restarted. |
public ElGamalEngine(I2PAppContext context)
public byte[] decrypt(byte[] encrypted,
PrivateKey privateKey)encrypted - encrypted data, must be exactly 514 bytes
Contains the two-part encrypted data starting at bytes 0 and 257.
If the encrypted parts are smaller than 257 bytes, they must be
padded with leading zeros.privateKey - private key to decrypt withpublic byte[] encrypt(byte[] data,
PublicKey publicKey)data - data to encrypt, must be 222 bytes or lesspublicKey - public key encrypt to
As the encrypted data may contain a substantial number of zeros if the
cleartext is smaller than 222 bytes, it is recommended that the caller pad
the cleartext to 222 bytes with random data.public void restart()
public void shutdown()