mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-19 02:42:05 +01:00
Kotlin conversion: XDH
This commit is contained in:
parent
521424c23a
commit
ad734ca1b4
5 changed files with 21 additions and 69 deletions
|
@ -1,8 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Classes related to OpenPGP key generation.
|
||||
*/
|
||||
package org.pgpainless.key.generation;
|
|
@ -1,8 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2018 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Classes describing different OpenPGP key types.
|
||||
*/
|
||||
package org.pgpainless.key.generation.type;
|
|
@ -1,45 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2020 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.key.generation.type.xdh;
|
||||
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import org.bouncycastle.jce.spec.ECNamedCurveGenParameterSpec;
|
||||
import org.pgpainless.algorithm.PublicKeyAlgorithm;
|
||||
import org.pgpainless.key.generation.type.KeyType;
|
||||
|
||||
public final class XDH implements KeyType {
|
||||
|
||||
private final XDHSpec spec;
|
||||
|
||||
private XDH(XDHSpec spec) {
|
||||
this.spec = spec;
|
||||
}
|
||||
|
||||
public static XDH fromSpec(XDHSpec spec) {
|
||||
return new XDH(spec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "XDH";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicKeyAlgorithm getAlgorithm() {
|
||||
return PublicKeyAlgorithm.ECDH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBitStrength() {
|
||||
return spec.getBitStrength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlgorithmParameterSpec getAlgorithmSpec() {
|
||||
return new ECNamedCurveGenParameterSpec(spec.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2020 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Classes related to Diffie-Hellman on the X25519 curve.
|
||||
*/
|
||||
package org.pgpainless.key.generation.type.xdh;
|
|
@ -0,0 +1,21 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.key.generation.type.xdh
|
||||
|
||||
import org.bouncycastle.jce.spec.ECNamedCurveGenParameterSpec
|
||||
import org.pgpainless.algorithm.PublicKeyAlgorithm
|
||||
import org.pgpainless.key.generation.type.KeyType
|
||||
|
||||
class XDH private constructor(spec: XDHSpec): KeyType {
|
||||
override val name = "XDH"
|
||||
override val algorithm = PublicKeyAlgorithm.ECDH
|
||||
override val bitStrength = spec.bitStrength
|
||||
override val algorithmSpec = ECNamedCurveGenParameterSpec(spec.algorithmName)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromSpec(spec: XDHSpec) = XDH(spec)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue