From c6bf2d68a89df3006b40a31eba2d6ab815b565bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Jul 2021 04:16:17 +0000 Subject: [PATCH 1/3] Bump pgpainless-core from 0.2.3 to 0.2.4 Bumps [pgpainless-core](https://github.com/pgpainless/pgpainless) from 0.2.3 to 0.2.4. - [Release notes](https://github.com/pgpainless/pgpainless/releases) - [Changelog](https://github.com/pgpainless/pgpainless/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgpainless/pgpainless/compare/0.2.3...0.2.4) --- updated-dependencies: - dependency-name: org.pgpainless:pgpainless-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- FlowCrypt/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FlowCrypt/build.gradle b/FlowCrypt/build.gradle index ef20ad2f38..dfd7578b1a 100644 --- a/FlowCrypt/build.gradle +++ b/FlowCrypt/build.gradle @@ -459,7 +459,7 @@ dependencies { implementation 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20200713.1' implementation 'org.jsoup:jsoup:1.14.1' - implementation ('org.pgpainless:pgpainless-core:0.2.3') { + implementation ('org.pgpainless:pgpainless-core:0.2.4') { //exclude group: 'org.bouncycastle' because we will specify it manually exclude group: 'org.bouncycastle' } From ec9744fac1d9f456eac9df7370da9e17a501b77f Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Wed, 21 Jul 2021 09:53:11 +0300 Subject: [PATCH 2/3] Fixed compilation errors after upgrading to 'org.pgpainless:pgpainless-core:0.2.4'.| #1344 --- .../flowcrypt/email/security/pgp/PgpDecrypt.kt | 9 +++++---- .../com/flowcrypt/email/security/pgp/PgpMsg.kt | 15 +++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpDecrypt.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpDecrypt.kt index 9261f9c56c..83dda3689a 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpDecrypt.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpDecrypt.kt @@ -11,6 +11,7 @@ import com.flowcrypt.email.util.exception.DecryptionException import org.bouncycastle.openpgp.PGPDataValidationException import org.bouncycastle.openpgp.PGPSecretKeyRingCollection import org.pgpainless.PGPainless +import org.pgpainless.decryption_verification.ConsumerOptions import org.pgpainless.decryption_verification.OpenPgpMetadata import org.pgpainless.exception.MessageNotIntegrityProtectedException import org.pgpainless.exception.MissingDecryptionMethodException @@ -41,10 +42,10 @@ object PgpDecrypt { try { val decryptionStream = PGPainless.decryptAndOrVerify() .onInputStream(srcStream) - .decryptWith(protector, pgpSecretKeyRingCollection) - .doNotVerify() - .build() - + .withOptions( + ConsumerOptions() + .addDecryptionKeys(pgpSecretKeyRingCollection, protector) + ) decryptionStream.use { it.copyTo(outStream) } return decryptionStream.result } catch (e: Exception) { diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt index bc5caad830..7e3f3c74d7 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt @@ -43,6 +43,7 @@ import org.json.JSONObject import org.jsoup.Jsoup import org.owasp.html.HtmlPolicyBuilder import org.pgpainless.PGPainless +import org.pgpainless.decryption_verification.ConsumerOptions import org.pgpainless.exception.MessageNotIntegrityProtectedException import org.pgpainless.exception.ModificationDetectionException import org.pgpainless.key.info.KeyRingInfo @@ -249,15 +250,13 @@ object PgpMsg { val exception: Exception? try { - val d = PGPainless.decryptAndOrVerify() - .onInputStream(input) - .decryptWith(UnprotectedKeysProtector(), PGPSecretKeyRingCollection(keyList)) + val consumerOptions = ConsumerOptions() + .addDecryptionKeys(PGPSecretKeyRingCollection(keyList), UnprotectedKeysProtector()) + pgpPublicKeyRingCollection?.let { consumerOptions.addVerificationCerts(it) } - val decryptionStream = if (pgpPublicKeyRingCollection != null) { - d.verifyWith(pgpPublicKeyRingCollection).ignoreMissingPublicKeys().build() - } else { - d.doNotVerify().build() - } + val decryptionStream = PGPainless.decryptAndOrVerify() + .onInputStream(input) + .withOptions(consumerOptions) val output = ByteArrayOutputStream() decryptionStream.use { it.copyTo(output) } From e47edbc1904bfab606e3630d90cbcd4f00997573 Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Wed, 21 Jul 2021 10:18:20 +0300 Subject: [PATCH 3/3] Fixed JUnit tests.| #1344 --- .../com/flowcrypt/email/security/pgp/PgpEncryptTest.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpEncryptTest.kt b/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpEncryptTest.kt index 0c7cdc0368..d0b74c0fb1 100644 --- a/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpEncryptTest.kt +++ b/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpEncryptTest.kt @@ -12,6 +12,7 @@ import org.junit.Assert.assertArrayEquals import org.junit.BeforeClass import org.junit.Test import org.pgpainless.PGPainless +import org.pgpainless.decryption_verification.ConsumerOptions import org.pgpainless.key.protection.KeyRingProtectionSettings import org.pgpainless.key.protection.PasswordBasedSecretKeyRingProtector import org.pgpainless.key.util.KeyRingUtils @@ -97,10 +98,11 @@ class PgpEncryptTest { val decryptionStream = PGPainless.decryptAndOrVerify() .onInputStream(inputStream) - .decryptWith(protector, PGPSecretKeyRingCollection(listOf(pgpSecretKeyRing))) - .verifyWith(pgpPublicKeyRingCollection) - .ignoreMissingPublicKeys() - .build() + .withOptions( + ConsumerOptions() + .addDecryptionKeys(PGPSecretKeyRingCollection(listOf(pgpSecretKeyRing)), protector) + .addVerificationCerts(pgpPublicKeyRingCollection) + ) val outputStreamWithDecryptedData = ByteArrayOutputStream() decryptionStream.use { it.copyTo(outputStreamWithDecryptedData) }