mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-23 04:42:06 +01:00
ElGamal: Deprecate GENERAL
This commit is contained in:
parent
3c88bdde9b
commit
5f289f4fe1
4 changed files with 29 additions and 3 deletions
|
@ -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),
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue