2018-06-13 17:26:48 +02:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2018-07-18 18:23:06 +02:00
|
|
|
package org.pgpainless.key.generation.type;
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2018-06-04 14:50:09 +02:00
|
|
|
import java.security.spec.AlgorithmParameterSpec;
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
import org.pgpainless.algorithm.PublicKeyAlgorithm;
|
2020-12-08 20:02:41 +01:00
|
|
|
import org.pgpainless.key.generation.type.ecdh.ECDH;
|
|
|
|
import org.pgpainless.key.generation.type.ecdsa.ECDSA;
|
|
|
|
import org.pgpainless.key.generation.type.rsa.RsaLength;
|
|
|
|
import org.pgpainless.key.generation.type.rsa.RSA;
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2018-06-04 14:50:09 +02:00
|
|
|
public interface KeyType {
|
2018-06-02 21:21:35 +02:00
|
|
|
|
|
|
|
String getName();
|
|
|
|
|
|
|
|
PublicKeyAlgorithm getAlgorithm();
|
2018-06-04 14:50:09 +02:00
|
|
|
|
|
|
|
AlgorithmParameterSpec getAlgorithmSpec();
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Decide, if we want to add ElGamal here as well?
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|