1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-26 14:22:05 +01:00

ElGamal: Deprecate GENERAL

This commit is contained in:
Paul Schaub 2020-12-11 18:14:36 +01:00
parent 3c88bdde9b
commit 5f289f4fe1
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 29 additions and 3 deletions

View file

@ -34,6 +34,11 @@ public enum PublicKeyAlgorithm {
EC (PublicKeyAlgorithmTags.EC),
ECDH (PublicKeyAlgorithmTags.ECDH),
ECDSA (PublicKeyAlgorithmTags.ECDSA),
/**
* @deprecated see https://tools.ietf.org/html/rfc4880#section-13.8
*/
@Deprecated
ELGAMAL_GENERAL (PublicKeyAlgorithmTags.ELGAMAL_GENERAL),
DIFFIE_HELLMAN (PublicKeyAlgorithmTags.DIFFIE_HELLMAN),
EDDSA (PublicKeyAlgorithmTags.EDDSA),

View file

@ -15,18 +15,37 @@
*/
package org.pgpainless.key.generation.type.elgamal;
import java.security.spec.AlgorithmParameterSpec;
import javax.annotation.Nonnull;
import org.bouncycastle.jce.spec.ElGamalParameterSpec;
import org.pgpainless.algorithm.PublicKeyAlgorithm;
import org.pgpainless.key.generation.type.KeyType;
public class ElGamal_ENCRYPT extends ElGamal_GENERAL {
public final class ElGamal_ENCRYPT implements KeyType {
ElGamal_ENCRYPT(@Nonnull ElGamalLength length) {
super(length);
private final ElGamalLength length;
private ElGamal_ENCRYPT(@Nonnull ElGamalLength length) {
this.length = length;
}
public static ElGamal_ENCRYPT withLength(ElGamalLength length) {
return new ElGamal_ENCRYPT(length);
}
@Override
public String getName() {
return "ElGamal";
}
@Override
public PublicKeyAlgorithm getAlgorithm() {
return PublicKeyAlgorithm.ELGAMAL_ENCRYPT;
}
@Override
public AlgorithmParameterSpec getAlgorithmSpec() {
return new ElGamalParameterSpec(length.getP(), length.getG());
}
}

View file

@ -22,6 +22,7 @@ import org.bouncycastle.jce.spec.ElGamalParameterSpec;
import org.pgpainless.algorithm.PublicKeyAlgorithm;
import org.pgpainless.key.generation.type.KeyType;
@Deprecated
public class ElGamal_GENERAL implements KeyType {
private final ElGamalLength length;

View file

@ -68,6 +68,7 @@ public class EncryptDecryptTest {
"Unfold the imagined happiness that both\n" +
"Receive in either by this dear encounter.";
@SuppressWarnings("deprecation")
@Test
public void freshKeysRsaToElGamalTest()
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {