From e3c60973c4703f8dbdcaa6cc476d55a60371e2cf Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 25 Jun 2024 08:11:30 +0200 Subject: [PATCH] WIP: v6 signature creation --- .../org/pgpainless/encryption_signing/SigningOptions.kt | 9 +++++++-- .../src/main/kotlin/org/pgpainless/policy/Policy.kt | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/encryption_signing/SigningOptions.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/encryption_signing/SigningOptions.kt index e0fe2972..1e8cd545 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/encryption_signing/SigningOptions.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/encryption_signing/SigningOptions.kt @@ -383,7 +383,11 @@ class SigningOptions { } val generator: PGPSignatureGenerator = - createSignatureGenerator(signingSubkey, hashAlgorithm, signatureType) + createSignatureGenerator( + signingSubkey, + signingKey.getPublicKey(signingSubkey.keyID).version, + hashAlgorithm, + signatureType) // Subpackets val hashedSubpackets = @@ -425,6 +429,7 @@ class SigningOptions { @Throws(PGPException::class) private fun createSignatureGenerator( privateKey: PGPPrivateKey, + signatureVersion: Int, hashAlgorithm: HashAlgorithm, signatureType: DocumentSignatureType ): PGPSignatureGenerator { @@ -432,7 +437,7 @@ class SigningOptions { .getPGPContentSignerBuilder( privateKey.publicKeyPacket.algorithm, hashAlgorithm.algorithmId) .let { csb -> - PGPSignatureGenerator(csb).also { + PGPSignatureGenerator(csb, signatureVersion).also { it.init(signatureType.signatureType.code, privateKey) } } diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/policy/Policy.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/policy/Policy.kt index 7c6bb2d3..93c6c19f 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/policy/Policy.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/policy/Policy.kt @@ -379,6 +379,10 @@ class Policy( put(PublicKeyAlgorithm.DIFFIE_HELLMAN, 2000) // ยง7.2.2 put(PublicKeyAlgorithm.ECDH, 250) + put(PublicKeyAlgorithm.ED25519, 0) + put(PublicKeyAlgorithm.ED448, 0) + put(PublicKeyAlgorithm.X25519, 0) + put(PublicKeyAlgorithm.X448, 0) }) } }