1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-16 17:32:06 +01:00

Kotlin conversion: ElGamal

This commit is contained in:
Paul Schaub 2023-09-07 15:18:06 +02:00
parent 978d702b5b
commit b76c0461fa
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 28 additions and 60 deletions

View file

@ -1,52 +0,0 @@
// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
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;
/**
* ElGamal encryption only key type.
*
* @deprecated the use of ElGamal is not recommended anymore.
*/
@Deprecated
public final class ElGamal implements KeyType {
private final ElGamalLength length;
private ElGamal(@Nonnull ElGamalLength length) {
this.length = length;
}
public static ElGamal withLength(ElGamalLength length) {
return new ElGamal(length);
}
@Override
public String getName() {
return "ElGamal";
}
@Override
public PublicKeyAlgorithm getAlgorithm() {
return PublicKeyAlgorithm.ELGAMAL_ENCRYPT;
}
@Override
public int getBitStrength() {
return length.getLength();
}
@Override
public AlgorithmParameterSpec getAlgorithmSpec() {
return new ElGamalParameterSpec(length.getP(), length.getG());
}
}

View file

@ -1,8 +0,0 @@
// SPDX-FileCopyrightText: 2020 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
/**
* Classes related to ElGamal.
*/
package org.pgpainless.key.generation.type.elgamal;

View file

@ -0,0 +1,28 @@
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.key.generation.type.elgamal
import org.bouncycastle.jce.spec.ElGamalParameterSpec
import org.pgpainless.algorithm.PublicKeyAlgorithm
import org.pgpainless.key.generation.type.KeyType
/**
* ElGamal encryption only key type.
*
* @deprecated the use of ElGamal is not recommended anymore.
*/
@Deprecated("The use of ElGamal is not recommended anymore.")
class ElGamal private constructor(length: ElGamalLength) : KeyType {
override val name = "ElGamal"
override val algorithm = PublicKeyAlgorithm.ELGAMAL_ENCRYPT
override val bitStrength = length.length
override val algorithmSpec = ElGamalParameterSpec(length.p, length.g)
companion object {
@JvmStatic
fun withLength(length: ElGamalLength) = ElGamal(length)
}
}