1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-26 14:22:05 +01:00

Thin out and rename profiles of generate-key

This commit is contained in:
Paul Schaub 2023-04-17 12:49:23 +02:00
parent f3a4a01d19
commit 702fdf085c
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -33,16 +33,15 @@ import sop.operation.GenerateKey;
*/ */
public class GenerateKeyImpl implements GenerateKey { public class GenerateKeyImpl implements GenerateKey {
public static final Profile DEFAULT_PROFILE = new Profile("default", "Generate keys based on XDH and EdDSA"); public static final Profile CURVE25519_PROFILE = new Profile("draft-koch-eddsa-for-openpgp-00", "Generate EdDSA / ECDH keys using Curve25519");
public static final Profile RSA3072_PROFILE = new Profile("rfc4880-rsa3072@pgpainless.org", "Generate 3072-bit RSA keys"); public static final Profile RSA4096_PROFILE = new Profile("rfc4880", "Generate 4096-bit RSA keys");
public static final Profile RSA4096_PROFILE = new Profile("rfc4880-rsa4096@pgpainless.org", "Generate 4096-bit RSA keys");
public static final List<Profile> SUPPORTED_PROFILES = Arrays.asList(DEFAULT_PROFILE, RSA3072_PROFILE, RSA4096_PROFILE); public static final List<Profile> SUPPORTED_PROFILES = Arrays.asList(CURVE25519_PROFILE, RSA4096_PROFILE);
private boolean armor = true; private boolean armor = true;
private final Set<String> userIds = new LinkedHashSet<>(); private final Set<String> userIds = new LinkedHashSet<>();
private Passphrase passphrase = Passphrase.emptyPassphrase(); private Passphrase passphrase = Passphrase.emptyPassphrase();
private String profile = DEFAULT_PROFILE.getName(); private String profile = CURVE25519_PROFILE.getName();
@Override @Override
public GenerateKey noArmor() { public GenerateKey noArmor() {
@ -117,14 +116,11 @@ public class GenerateKeyImpl implements GenerateKey {
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
PGPSecretKeyRing key; PGPSecretKeyRing key;
// XDH + EdDSA // XDH + EdDSA
if (profile.equals(DEFAULT_PROFILE.getName())) { if (profile.equals(CURVE25519_PROFILE.getName())) {
key = PGPainless.generateKeyRing() key = PGPainless.generateKeyRing()
.modernKeyRing(primaryUserId, passphrase); .modernKeyRing(primaryUserId, passphrase);
} }
else if (profile.equals(RSA3072_PROFILE.getName())) { // RSA 4096
key = PGPainless.generateKeyRing()
.simpleRsaKeyRing(primaryUserId, RsaLength._3072, passphrase);
}
else if (profile.equals(RSA4096_PROFILE.getName())) { else if (profile.equals(RSA4096_PROFILE.getName())) {
key = PGPainless.generateKeyRing() key = PGPainless.generateKeyRing()
.simpleRsaKeyRing(primaryUserId, RsaLength._4096, passphrase); .simpleRsaKeyRing(primaryUserId, RsaLength._4096, passphrase);