mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-23 11:27:57 +01:00
Kotlin conversion: ECDSA
This commit is contained in:
parent
9e7a25ffe1
commit
89b73895f5
4 changed files with 22 additions and 64 deletions
|
@ -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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
|
@ -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;
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue