From 48f01cf8d5504d3d5507fd54585859d7fe0475df Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Wed, 30 Oct 2024 23:50:37 +0100 Subject: [PATCH] Experimental v6 key generation --- .../org/pgpainless/sop/GenerateKeyImpl.kt | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/GenerateKeyImpl.kt b/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/GenerateKeyImpl.kt index 3a7f8406..c7e278f3 100644 --- a/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/GenerateKeyImpl.kt +++ b/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/GenerateKeyImpl.kt @@ -36,10 +36,16 @@ class GenerateKeyImpl : GenerateKey { Profile( "draft-koch-eddsa-for-openpgp-00", "Generate EdDSA / ECDH keys using Curve25519") @JvmField val RSA4096_PROFILE = Profile("rfc4880", "Generate 4096-bit RSA keys") - @JvmField val RFC9580_25519_PROFILE = Profile("rfc9580", "Generate a version 6 EdDSA / ECDH keys using Curve25519") - @JvmField val RFC9580_448_PROFILE = Profile("rfc9580-curve448", "Generate a version 6 EdDSA / ECDH keys using Curve448") + @JvmField + val RFC9580_25519_PROFILE = + Profile("rfc9580", "Generate a version 6 EdDSA / ECDH keys using Curve25519") + @JvmField + val RFC9580_448_PROFILE = + Profile("rfc9580-curve448", "Generate a version 6 EdDSA / ECDH keys using Curve448") - @JvmField val SUPPORTED_PROFILES = listOf(CURVE25519_PROFILE, RSA4096_PROFILE, RFC9580_25519_PROFILE, RFC9580_448_PROFILE) + @JvmField + val SUPPORTED_PROFILES = + listOf(CURVE25519_PROFILE, RSA4096_PROFILE, RFC9580_25519_PROFILE, RFC9580_448_PROFILE) } private val userIds = mutableSetOf() @@ -130,15 +136,14 @@ class GenerateKeyImpl : GenerateKey { } } RFC9580_25519_PROFILE.name -> { - val gen = BcOpenPGPV6KeyGenerator() - .withPrimaryKey(PGPKeyPairGenerator::generateEd25519KeyPair) - .addSigningSubkey(PGPKeyPairGenerator::generateEd25519KeyPair) + val gen = + BcOpenPGPV6KeyGenerator() + .withPrimaryKey(PGPKeyPairGenerator::generateEd25519KeyPair) + .addSigningSubkey(PGPKeyPairGenerator::generateEd25519KeyPair) if (!signingOnly) { gen.addEncryptionSubkey(PGPKeyPairGenerator::generateX25519KeyPair) } - userIds.forEach { - gen.addUserId(it) - } + userIds.forEach { gen.addUserId(it) } if (!passphrase.isEmpty) { return gen.build(passphrase.getChars()) @@ -147,15 +152,14 @@ class GenerateKeyImpl : GenerateKey { } } RFC9580_448_PROFILE.name -> { - val gen = BcOpenPGPV6KeyGenerator() - .withPrimaryKey(PGPKeyPairGenerator::generateEd448KeyPair) - .addSigningSubkey(PGPKeyPairGenerator::generateEd448KeyPair) + val gen = + BcOpenPGPV6KeyGenerator() + .withPrimaryKey(PGPKeyPairGenerator::generateEd448KeyPair) + .addSigningSubkey(PGPKeyPairGenerator::generateEd448KeyPair) if (!signingOnly) { gen.addEncryptionSubkey(PGPKeyPairGenerator::generateX448KeyPair) } - userIds.forEach { - gen.addUserId(it) - } + userIds.forEach { gen.addUserId(it) } if (!passphrase.isEmpty) { return gen.build(passphrase.getChars())