1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-22 19:08:00 +01:00

Kotlin conversion: ECDSA

This commit is contained in:
Paul Schaub 2023-09-07 15:03:06 +02:00
parent 9e7a25ffe1
commit 89b73895f5
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 22 additions and 64 deletions

View file

@ -1,48 +0,0 @@
// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.key.generation.type.ecc.ecdsa;
import java.security.spec.AlgorithmParameterSpec;
import javax.annotation.Nonnull;
import org.bouncycastle.jce.spec.ECNamedCurveGenParameterSpec;
import org.pgpainless.algorithm.PublicKeyAlgorithm;
import org.pgpainless.key.generation.type.ecc.EllipticCurve;
import org.pgpainless.key.generation.type.KeyType;
public final class ECDSA implements KeyType {
private final EllipticCurve curve;
private ECDSA(@Nonnull EllipticCurve curve) {
this.curve = curve;
}
public static ECDSA fromCurve(@Nonnull EllipticCurve curve) {
return new ECDSA(curve);
}
@Override
public String getName() {
return "ECDSA";
}
@Override
public PublicKeyAlgorithm getAlgorithm() {
return PublicKeyAlgorithm.ECDSA;
}
@Override
public int getBitStrength() {
return curve.getBitStrength();
}
@Override
public AlgorithmParameterSpec getAlgorithmSpec() {
return new ECNamedCurveGenParameterSpec(curve.getName());
}
}

View file

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

View file

@ -1,8 +0,0 @@
// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
/**
* Classes describing different OpenPGP key types based on elliptic curves.
*/
package org.pgpainless.key.generation.type.ecc;

View file

@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.key.generation.type.ecc.ecdsa
import org.bouncycastle.jce.spec.ECNamedCurveGenParameterSpec
import org.pgpainless.algorithm.PublicKeyAlgorithm
import org.pgpainless.key.generation.type.KeyType
import org.pgpainless.key.generation.type.ecc.EllipticCurve
class ECDSA private constructor(val curve: EllipticCurve) : KeyType {
override val name = "ECDSA"
override val algorithm = PublicKeyAlgorithm.ECDSA
override val bitStrength = curve.bitStrength
override val algorithmSpec = ECNamedCurveGenParameterSpec(curve.curveName)
companion object {
@JvmStatic
fun fromCurve(curve: EllipticCurve) = ECDSA(curve)
}
}