From 833484450c983f931ed1dcbe4b2a065def219f52 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 24 Jul 2025 11:49:38 +0200 Subject: [PATCH 1/2] Add overridden @Deprecated annotations --- .../CachingBcPublicKeyDataDecryptorFactory.kt | 1 + .../decryption_verification/HardwareSecurity.kt | 1 + .../signature/subpackets/SignatureSubpackets.kt | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/decryption_verification/CachingBcPublicKeyDataDecryptorFactory.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/decryption_verification/CachingBcPublicKeyDataDecryptorFactory.kt index 9bafa6da..1da0a42d 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/decryption_verification/CachingBcPublicKeyDataDecryptorFactory.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/decryption_verification/CachingBcPublicKeyDataDecryptorFactory.kt @@ -46,6 +46,7 @@ class CachingBcPublicKeyDataDecryptorFactory( return decryptorFactory.createDataDecryptor(p0, p1) } + @Deprecated("Deprecated in Java") override fun recoverSessionData( keyAlgorithm: Int, secKeyData: Array, diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/decryption_verification/HardwareSecurity.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/decryption_verification/HardwareSecurity.kt index b6e2bd17..27f53bc6 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/decryption_verification/HardwareSecurity.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/decryption_verification/HardwareSecurity.kt @@ -102,6 +102,7 @@ class HardwareSecurity { return factory.createDataDecryptor(seipd, sessionKey) } + @Deprecated("Deprecated in Java") override fun recoverSessionData( keyAlgorithm: Int, secKeyData: Array, diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/signature/subpackets/SignatureSubpackets.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/signature/subpackets/SignatureSubpackets.kt index 2a5ea016..28f9ee82 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/signature/subpackets/SignatureSubpackets.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/signature/subpackets/SignatureSubpackets.kt @@ -292,15 +292,18 @@ class SignatureSubpackets( } } + @Deprecated("Use of this subpacket is discouraged.") override fun addRevocationKey(revocationKey: PGPPublicKey): SignatureSubpackets = apply { addRevocationKey(true, revocationKey) } + @Deprecated("Use of this subpacket is discouraged.") override fun addRevocationKey( isCritical: Boolean, revocationKey: PGPPublicKey ): SignatureSubpackets = apply { addRevocationKey(isCritical, false, revocationKey) } + @Deprecated("Use of this subpacket is discouraged.") override fun addRevocationKey( isCritical: Boolean, isSensitive: Boolean, @@ -311,10 +314,12 @@ class SignatureSubpackets( RevocationKey(isCritical, clazz, revocationKey.algorithm, revocationKey.fingerprint)) } + @Deprecated("Use of this subpacket is discouraged.") override fun addRevocationKey(revocationKey: RevocationKey): SignatureSubpackets = apply { subpacketsGenerator.addCustomSubpacket(revocationKey) } + @Deprecated("Use of this subpacket is discouraged.") override fun clearRevocationKeys(): SignatureSubpackets = apply { subpacketsGenerator.removePacketsOfType(SignatureSubpacketTags.REVOCATION_KEY) } @@ -450,15 +455,18 @@ class SignatureSubpackets( } } + @Deprecated("Usage of subpacket is discouraged") override fun setSignerUserId(userId: CharSequence): SignatureSubpackets = apply { setSignerUserId(false, userId) } + @Deprecated("Usage of subpacket is discouraged") override fun setSignerUserId(isCritical: Boolean, userId: CharSequence): SignatureSubpackets = apply { setSignerUserId(SignerUserID(isCritical, userId.toString())) } + @Deprecated("Usage of subpacket is discouraged") override fun setSignerUserId(signerUserID: SignerUserID?): SignatureSubpackets = apply { subpacketsGenerator.removePacketsOfType(SignatureSubpacketTags.SIGNER_USER_ID) signerUserID?.let { subpacketsGenerator.setSignerUserID(it.isCritical, it.rawID) } From 6ca9b6f4ed8c2474eb6a2f8c5dd19455985dbb1c Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 24 Jul 2025 11:49:47 +0200 Subject: [PATCH 2/2] Turn var into val --- .../main/kotlin/org/pgpainless/key/generation/KeyRingBuilder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/KeyRingBuilder.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/KeyRingBuilder.kt index 1c3d7df0..cd703ace 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/KeyRingBuilder.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/key/generation/KeyRingBuilder.kt @@ -191,7 +191,7 @@ class KeyRingBuilder(private val version: OpenPGPKeyVersion, private val api: PG private fun addSubKeys(primaryKey: PGPKeyPair, ringGenerator: PGPKeyRingGenerator) { for (subKeySpec in subKeySpecs) { val subKey = generateKeyPair(subKeySpec, version, api.implementation) - var hashedSignatureSubpackets: SignatureSubpackets = + val hashedSignatureSubpackets: SignatureSubpackets = SignatureSubpackets.createHashedSubpackets(subKey.publicKey).apply { setKeyFlags(subKeySpec.keyFlags) subKeySpec.preferredHashAlgorithmsOverride?.let {