mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-14 00:12:06 +01:00
Kotlin conversion: EdDSA
This commit is contained in:
parent
7db56ca800
commit
5ed5016675
3 changed files with 21 additions and 58 deletions
|
@ -1,50 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2020 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.key.generation.type.eddsa;
|
||||
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import org.bouncycastle.jce.spec.ECNamedCurveGenParameterSpec;
|
||||
import org.pgpainless.algorithm.PublicKeyAlgorithm;
|
||||
import org.pgpainless.key.generation.type.KeyType;
|
||||
|
||||
/**
|
||||
* Edwards-curve Digital Signature Algorithm (EdDSA).
|
||||
*
|
||||
* @see <a href="https://datatracker.ietf.org/doc/draft-koch-eddsa-for-openpgp/">EdDSA for OpenPGP</a>
|
||||
*/
|
||||
public final class EdDSA implements KeyType {
|
||||
|
||||
private final EdDSACurve curve;
|
||||
|
||||
private EdDSA(EdDSACurve curve) {
|
||||
this.curve = curve;
|
||||
}
|
||||
|
||||
public static EdDSA fromCurve(EdDSACurve curve) {
|
||||
return new EdDSA(curve);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "EdDSA";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicKeyAlgorithm getAlgorithm() {
|
||||
return PublicKeyAlgorithm.EDDSA;
|
||||
}
|
||||
|
||||
@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 EdDSA.
|
||||
*/
|
||||
package org.pgpainless.key.generation.type.eddsa;
|
|
@ -0,0 +1,21 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.key.generation.type.eddsa
|
||||
|
||||
import org.bouncycastle.jce.spec.ECNamedCurveGenParameterSpec
|
||||
import org.pgpainless.algorithm.PublicKeyAlgorithm
|
||||
import org.pgpainless.key.generation.type.KeyType
|
||||
|
||||
class EdDSA private constructor(val curve: EdDSACurve) : KeyType {
|
||||
override val name = "EdDSA"
|
||||
override val algorithm = PublicKeyAlgorithm.EDDSA
|
||||
override val bitStrength = curve.bitStrength
|
||||
override val algorithmSpec = ECNamedCurveGenParameterSpec(curve.curveName)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromCurve(curve: EdDSACurve) = EdDSA(curve)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue