mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-30 00:02: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),
|
EC (PublicKeyAlgorithmTags.EC),
|
||||||
ECDH (PublicKeyAlgorithmTags.ECDH),
|
ECDH (PublicKeyAlgorithmTags.ECDH),
|
||||||
ECDSA (PublicKeyAlgorithmTags.ECDSA),
|
ECDSA (PublicKeyAlgorithmTags.ECDSA),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated see https://tools.ietf.org/html/rfc4880#section-13.8
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
ELGAMAL_GENERAL (PublicKeyAlgorithmTags.ELGAMAL_GENERAL),
|
ELGAMAL_GENERAL (PublicKeyAlgorithmTags.ELGAMAL_GENERAL),
|
||||||
DIFFIE_HELLMAN (PublicKeyAlgorithmTags.DIFFIE_HELLMAN),
|
DIFFIE_HELLMAN (PublicKeyAlgorithmTags.DIFFIE_HELLMAN),
|
||||||
EDDSA (PublicKeyAlgorithmTags.EDDSA),
|
EDDSA (PublicKeyAlgorithmTags.EDDSA),
|
||||||
|
|
|
@ -15,18 +15,37 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.generation.type.elgamal;
|
package org.pgpainless.key.generation.type.elgamal;
|
||||||
|
|
||||||
|
import java.security.spec.AlgorithmParameterSpec;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.bouncycastle.jce.spec.ElGamalParameterSpec;
|
||||||
import org.pgpainless.algorithm.PublicKeyAlgorithm;
|
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) {
|
private final ElGamalLength length;
|
||||||
super(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
|
@Override
|
||||||
public PublicKeyAlgorithm getAlgorithm() {
|
public PublicKeyAlgorithm getAlgorithm() {
|
||||||
return PublicKeyAlgorithm.ELGAMAL_ENCRYPT;
|
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.algorithm.PublicKeyAlgorithm;
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
import org.pgpainless.key.generation.type.KeyType;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class ElGamal_GENERAL implements KeyType {
|
public class ElGamal_GENERAL implements KeyType {
|
||||||
|
|
||||||
private final ElGamalLength length;
|
private final ElGamalLength length;
|
||||||
|
|
|
@ -68,6 +68,7 @@ public class EncryptDecryptTest {
|
||||||
"Unfold the imagined happiness that both\n" +
|
"Unfold the imagined happiness that both\n" +
|
||||||
"Receive in either by this dear encounter.";
|
"Receive in either by this dear encounter.";
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void freshKeysRsaToElGamalTest()
|
public void freshKeysRsaToElGamalTest()
|
||||||
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
|
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
|
||||||
|
|
Loading…
Reference in a new issue