diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/KeyRingTemplates.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/KeyRingTemplates.kt index 521d7a3d..eb8dea2d 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/KeyRingTemplates.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/KeyRingTemplates.kt @@ -30,7 +30,7 @@ class KeyRingTemplates { length: RsaLength, passphrase: Passphrase = Passphrase.emptyPassphrase() ): PGPSecretKeyRing = - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .setPrimaryKey(KeyType.RSA(length), listOf(KeyFlag.CERTIFY_OTHER)) { if (userId != null) { addUserId(userId) @@ -76,7 +76,7 @@ class KeyRingTemplates { length: RsaLength, passphrase: Passphrase = Passphrase.emptyPassphrase() ): PGPSecretKeyRing = - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .setPrimaryKey( KeyType.RSA(length), listOf( @@ -124,7 +124,7 @@ class KeyRingTemplates { userId: CharSequence?, passphrase: Passphrase = Passphrase.emptyPassphrase() ): PGPSecretKeyRing = - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .setPrimaryKey( KeyType.EDDSA(EdDSACurve._Ed25519), listOf(KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA)) { @@ -167,7 +167,7 @@ class KeyRingTemplates { userId: CharSequence?, passphrase: Passphrase = Passphrase.emptyPassphrase() ): PGPSecretKeyRing = - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519), listOf(KeyFlag.CERTIFY_OTHER)) { if (userId != null) { addUserId(userId) diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/OpenPgpKeyGenerator.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/OpenPgpKeyGenerator.kt index 3e088703..7449bb0c 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/OpenPgpKeyGenerator.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/OpenPgpKeyGenerator.kt @@ -58,7 +58,7 @@ class OpenPgpKeyGenerator internal constructor() { * @param preferences suite of algorithm preferences and enabled features */ @JvmStatic - fun buildV4( + fun buildV4Key( policy: Policy = PGPainless.getPolicy(), creationTime: Date = Date(), preferences: AlgorithmSuite = policy.keyGenerationAlgorithmSuite @@ -933,7 +933,7 @@ class OpenPgpKeyTemplates private constructor() { vararg userId: CharSequence, creationTime: Date = Date() ): PGPSecretKeyRing = - OpenPgpKeyGenerator.buildV4(creationTime = creationTime) + OpenPgpKeyGenerator.buildV4Key(creationTime = creationTime) .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { // Add UserIDs userId.forEachIndexed { index, uid -> @@ -977,7 +977,7 @@ class OpenPgpKeyTemplates private constructor() { creationTime: Date = Date(), length: RsaLength = RsaLength._4096 ): PGPSecretKeyRing = - OpenPgpKeyGenerator.buildV4(creationTime = creationTime) + OpenPgpKeyGenerator.buildV4Key(creationTime = creationTime) .setPrimaryKey(KeyType.RSA(length)) { // Add UserIDs userId.forEachIndexed { index, uid -> @@ -1020,7 +1020,7 @@ class OpenPgpKeyTemplates private constructor() { creationTime: Date = Date(), length: RsaLength = RsaLength._4096 ): PGPSecretKeyRing = - OpenPgpKeyGenerator.buildV4(creationTime = creationTime) + OpenPgpKeyGenerator.buildV4Key(creationTime = creationTime) .setPrimaryKey(KeyType.RSA(length)) { userId.forEach { addUserId(it) } addDirectKeySignature( diff --git a/pgpainless-core/src/test/kotlin/org/pgpainless/key/generation/MalformedKeyGenerationTest.kt b/pgpainless-core/src/test/kotlin/org/pgpainless/key/generation/MalformedKeyGenerationTest.kt index c98c551c..e304cefe 100644 --- a/pgpainless-core/src/test/kotlin/org/pgpainless/key/generation/MalformedKeyGenerationTest.kt +++ b/pgpainless-core/src/test/kotlin/org/pgpainless/key/generation/MalformedKeyGenerationTest.kt @@ -24,7 +24,7 @@ class MalformedKeyGenerationTest { fun malformedPrimaryUserIdSubpacket() { val userId = "Alice " val key = - OpenPgpKeyGenerator.buildV4(Policy()) + OpenPgpKeyGenerator.buildV4Key(Policy()) .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { addUserId( userId, @@ -43,7 +43,7 @@ class MalformedKeyGenerationTest { @Test fun malformedExportableSubpacket() { val key = - OpenPgpKeyGenerator.buildV4(Policy()) + OpenPgpKeyGenerator.buildV4Key(Policy()) .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { addUserId( "Alice ", @@ -62,7 +62,7 @@ class MalformedKeyGenerationTest { @Test fun malformedRevocableSubpacket() { val key = - OpenPgpKeyGenerator.buildV4(Policy()) + OpenPgpKeyGenerator.buildV4Key(Policy()) .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { addUserId( "Alice ", @@ -82,7 +82,7 @@ class MalformedKeyGenerationTest { fun primaryUserIdOnDirectKeySig() { val policy = Policy() val key = - OpenPgpKeyGenerator.buildV4(policy) + OpenPgpKeyGenerator.buildV4Key(policy) .setPrimaryKey( KeyType.EDDSA(EdDSACurve._Ed25519), listOf(KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA)) { diff --git a/pgpainless-core/src/test/kotlin/org/pgpainless/key/generation/OpenPgpKeyGeneratorTest.kt b/pgpainless-core/src/test/kotlin/org/pgpainless/key/generation/OpenPgpKeyGeneratorTest.kt index f00de1db..0baaeab7 100644 --- a/pgpainless-core/src/test/kotlin/org/pgpainless/key/generation/OpenPgpKeyGeneratorTest.kt +++ b/pgpainless-core/src/test/kotlin/org/pgpainless/key/generation/OpenPgpKeyGeneratorTest.kt @@ -26,7 +26,7 @@ class OpenPgpKeyGeneratorTest { @Test fun `minimal call with opinionated builder adds a default DK sig but no user info`() { val key = - OpenPgpKeyGenerator.buildV4().setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)).build() + OpenPgpKeyGenerator.buildV4Key().setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)).build() assertFalse(key.publicKey.userIDs.hasNext(), "Key MUST NOT have a UserID") assertFalse(key.publicKey.userAttributes.hasNext(), "Key MUST NOT have a UserAttribute") @@ -41,7 +41,7 @@ class OpenPgpKeyGeneratorTest { @Test fun `minimal call with unopinionated builder does not add a default DK sig`() { val key = - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .unopinionated() .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) .build() @@ -54,7 +54,7 @@ class OpenPgpKeyGeneratorTest { @Test fun `adding a direct-key signature with the opinionated builder omits the default DK sig`() { val key = - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { addDirectKeySignature() // "overwrites" the default dk sig } @@ -68,7 +68,7 @@ class OpenPgpKeyGeneratorTest { @Test fun `adding two user-ids will mark the first one as primary`() { val key = - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { addUserId("Primary ") addUserId("Non Primary ") @@ -82,7 +82,7 @@ class OpenPgpKeyGeneratorTest { @Test fun `adding two user-ids but mark the first as non-primary will mark the second one as primary`() { val key = - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { addUserId( "Non Primary ", @@ -101,7 +101,7 @@ class OpenPgpKeyGeneratorTest { @Test fun testUnopinionatedV4() { // Unopinionated - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .unopinionated() .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { addDirectKeySignature() @@ -116,7 +116,7 @@ class OpenPgpKeyGeneratorTest { fun testOpinionatedV4() { // Opinionated val time = DateUtil.parseUTCDate("2024-01-01 00:00:00 UTC") - OpenPgpKeyGenerator.buildV4(creationTime = time) + OpenPgpKeyGenerator.buildV4Key(creationTime = time) .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519), listOf(KeyFlag.CERTIFY_OTHER)) { addUserId("Alice ") } @@ -149,7 +149,7 @@ class OpenPgpKeyGeneratorTest { @Test fun test() { - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .setPrimaryKey(KeyType.RSA(RsaLength._3072), keyFlags = listOf(KeyFlag.CERTIFY_OTHER)) .build() .toAsciiArmor() @@ -163,7 +163,7 @@ class OpenPgpKeyGeneratorTest { Policy.PublicKeyAlgorithmPolicy(buildMap { put(PublicKeyAlgorithm.RSA_GENERAL, 3072) }) assertThrows { - OpenPgpKeyGenerator.buildV4(policy) + OpenPgpKeyGenerator.buildV4Key(policy) // opinionated builder verifies PK parameters .setPrimaryKey(KeyType.RSA(RsaLength._2048)) // too weak } @@ -175,7 +175,7 @@ class OpenPgpKeyGeneratorTest { policy.publicKeyAlgorithmPolicy = Policy.PublicKeyAlgorithmPolicy(buildMap { put(PublicKeyAlgorithm.RSA_GENERAL, 3072) }) - OpenPgpKeyGenerator.buildV4(policy) + OpenPgpKeyGenerator.buildV4Key(policy) .unopinionated() // unopinionated builder allows for non-compliant configurations .setPrimaryKey(KeyType.RSA(RsaLength._2048)) } @@ -183,7 +183,7 @@ class OpenPgpKeyGeneratorTest { @Test fun `skip default DirectKey signature will not add one`() { val key = - OpenPgpKeyGenerator.buildV4() + OpenPgpKeyGenerator.buildV4Key() .setPrimaryKey(KeyType.EDDSA(EdDSACurve._Ed25519)) { skipDefaultSignature() } .build()