1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-26 05:24:49 +02:00
pgpainless/pgpainless-core/src/main/java/org/pgpainless/key/generation/type/KeyType.java

55 lines
1.6 KiB
Java
Raw Normal View History

/*
* Copyright 2018 Paul Schaub.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pgpainless.key.generation.type;
2018-06-02 21:21:35 +02:00
import java.security.spec.AlgorithmParameterSpec;
2018-06-02 21:21:35 +02:00
import org.pgpainless.algorithm.PublicKeyAlgorithm;
2020-12-11 18:16:31 +01:00
import org.pgpainless.key.generation.type.ecc.EllipticCurve;
import org.pgpainless.key.generation.type.ecc.ecdh.ECDH;
import org.pgpainless.key.generation.type.ecc.ecdsa.ECDSA;
import org.pgpainless.key.generation.type.eddsa.EdDSA;
import org.pgpainless.key.generation.type.eddsa.EdDSACurve;
2020-12-08 20:02:41 +01:00
import org.pgpainless.key.generation.type.rsa.RsaLength;
import org.pgpainless.key.generation.type.rsa.RSA;
2018-06-02 21:21:35 +02:00
public interface KeyType {
2018-06-02 21:21:35 +02:00
String getName();
PublicKeyAlgorithm getAlgorithm();
AlgorithmParameterSpec getAlgorithmSpec();
2020-11-07 18:24:12 +01:00
2020-12-11 18:16:31 +01:00
boolean canCertify();
2020-11-07 18:24:12 +01:00
static KeyType RSA(RsaLength length) {
return RSA.withLength(length);
}
static KeyType ECDH(EllipticCurve curve) {
return ECDH.fromCurve(curve);
}
static KeyType ECDSA(EllipticCurve curve) {
return ECDSA.fromCurve(curve);
}
2020-12-11 18:16:31 +01:00
static KeyType EDDSA(EdDSACurve curve) {
return EdDSA.fromCurve(curve);
}
2018-06-02 21:21:35 +02:00
}