1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-22 10:57:58 +01:00

Experimental v6 key generation

This commit is contained in:
Paul Schaub 2024-10-30 23:50:37 +01:00
parent 0eca62f5a2
commit 48f01cf8d5
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -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<String>()
@ -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())