mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-14 16:32:06 +01:00
Kotlin conversion: ECDH
This commit is contained in:
parent
ab22aefe82
commit
f1352862f1
3 changed files with 22 additions and 54 deletions
|
@ -1,46 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2020 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.key.generation.type.ecc.ecdh;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
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;
|
||||
|
||||
public final class ECDH implements KeyType {
|
||||
|
||||
private final EllipticCurve curve;
|
||||
|
||||
private ECDH(EllipticCurve curve) {
|
||||
this.curve = curve;
|
||||
}
|
||||
|
||||
public static ECDH fromCurve(@Nonnull EllipticCurve curve) {
|
||||
return new ECDH(curve);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ECDH";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicKeyAlgorithm getAlgorithm() {
|
||||
return PublicKeyAlgorithm.ECDH;
|
||||
}
|
||||
|
||||
@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 ECDH.
|
||||
*/
|
||||
package org.pgpainless.key.generation.type.ecc.ecdh;
|
|
@ -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.ecdh
|
||||
|
||||
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 ECDH private constructor(val curve: EllipticCurve) : KeyType {
|
||||
override val name = "ECDH"
|
||||
override val algorithm = PublicKeyAlgorithm.ECDH
|
||||
override val bitStrength = curve.bitStrength
|
||||
override val algorithmSpec = ECNamedCurveGenParameterSpec(curve.curveName)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromCurve(curve: EllipticCurve) = ECDH(curve)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue