From 783fd9fc0633a2472fe8bb675aa1b1e6589bd409 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 08:50:26 +0000 Subject: [PATCH 1/3] Bump org.pgpainless:pgpainless-core from 1.7.2 to 1.7.3 Bumps [org.pgpainless:pgpainless-core](https://github.com/pgpainless/pgpainless) from 1.7.2 to 1.7.3. - [Changelog](https://github.com/pgpainless/pgpainless/blob/main/CHANGELOG.md) - [Commits](https://github.com/pgpainless/pgpainless/compare/1.7.2...1.7.3) --- 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.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FlowCrypt/build.gradle.kts b/FlowCrypt/build.gradle.kts index 1059930384..4ad410a46d 100644 --- a/FlowCrypt/build.gradle.kts +++ b/FlowCrypt/build.gradle.kts @@ -468,7 +468,7 @@ dependencies { implementation("org.bitbucket.b_c:jose4j:0.9.6") implementation("org.jsoup:jsoup:1.19.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") - implementation("org.pgpainless:pgpainless-core:1.7.2") + implementation("org.pgpainless:pgpainless-core:1.7.3") implementation("org.eclipse.angus:angus-mail:2.0.3") implementation("org.eclipse.angus:gimap:2.0.3") implementation("commons-io:commons-io:2.18.0") From 401aff32f2be21b6563edfcb2255704d1fc0828f Mon Sep 17 00:00:00 2001 From: denbond7 Date: Thu, 27 Mar 2025 14:22:57 +0200 Subject: [PATCH 2/3] wip --- FlowCrypt/build.gradle.kts | 2 +- .../org/bouncycastle/openpgp/PGPKeyRingExt.kt | 14 +++++++------- .../flowcrypt/email/security/pgp/PgpKeyTest.kt | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/FlowCrypt/build.gradle.kts b/FlowCrypt/build.gradle.kts index 179f47cbbe..455c1fc22e 100644 --- a/FlowCrypt/build.gradle.kts +++ b/FlowCrypt/build.gradle.kts @@ -468,7 +468,7 @@ dependencies { implementation("org.bitbucket.b_c:jose4j:0.9.6") implementation("org.jsoup:jsoup:1.19.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") - implementation("org.pgpainless:pgpainless-core:1.7.3") + implementation("org.pgpainless:pgpainless-core:1.7.5") implementation("org.eclipse.angus:angus-mail:2.0.3") implementation("org.eclipse.angus:gimap:2.0.3") implementation("commons-io:commons-io:2.18.0") diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/extensions/org/bouncycastle/openpgp/PGPKeyRingExt.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/extensions/org/bouncycastle/openpgp/PGPKeyRingExt.kt index 83d7fe0dc2..06f6235b3c 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/extensions/org/bouncycastle/openpgp/PGPKeyRingExt.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/extensions/org/bouncycastle/openpgp/PGPKeyRingExt.kt @@ -38,6 +38,13 @@ import java.time.Instant @Throws(IOException::class) @WorkerThread fun PGPKeyRing.toPgpKeyRingDetails(hideArmorMeta: Boolean = false): PgpKeyRingDetails { + if (containsHashAlgorithmWithSHA1()) { + val sigHashAlgoPolicy = PGPainless.getPolicy().certificationSignatureHashAlgorithmPolicy + if (!sigHashAlgoPolicy.isAcceptable(HashAlgorithm.SHA1)) { + throw PGPException("Unsupported signature(HashAlgorithm = SHA1)") + } + } + val keyRingInfo = KeyRingInfo(this) val algo = Algo( @@ -56,13 +63,6 @@ fun PGPKeyRing.toPgpKeyRingDetails(hideArmorMeta: Boolean = false): PgpKeyRingDe throw IllegalArgumentException("There are no fingerprints") } - if (containsHashAlgorithmWithSHA1()) { - val sigHashAlgoPolicy = PGPainless.getPolicy().certificationSignatureHashAlgorithmPolicy - if (!sigHashAlgoPolicy.isAcceptable(HashAlgorithm.SHA1)) { - throw PGPException("Unsupported signature(HashAlgorithm = SHA1)") - } - } - val privateKey = if (keyRingInfo.isSecretKey) armor(hideArmorMeta = hideArmorMeta) else null val publicKey = if (keyRingInfo.isSecretKey) { (this as PGPSecretKeyRing).toPublicKeyRing().armor(hideArmorMeta = hideArmorMeta) diff --git a/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpKeyTest.kt b/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpKeyTest.kt index c27c825da6..ba95726f26 100644 --- a/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpKeyTest.kt +++ b/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpKeyTest.kt @@ -81,8 +81,13 @@ class PgpKeyTest { ) val parseKeyResult = PgpKey.parseKeys(source = TestKeys.KEYS["rsa1"]!!.publicKey) assertEquals(1, parseKeyResult.getAllKeys().size) - val actual = parseKeyResult.pgpKeyDetailsList.first() - .run { this.copy(publicKey = replaceVersionInKey(this.publicKey)) } + val actual = parseKeyResult.pgpKeyDetailsList.first().copy( + /* + * we replace publicKey source here because it can't be a constant. + * If other fields of [PgpKeyRingDetails] will be the same it means objects are equal + */ + publicKey = expected.publicKey + ) assertEquals(expected, actual) } @@ -122,8 +127,13 @@ class PgpKeyTest { ) val parseKeyResult = PgpKey.parseKeys(source = TestKeys.KEYS["expired"]!!.publicKey) assertEquals(1, parseKeyResult.getAllKeys().size) - val actual = parseKeyResult.pgpKeyDetailsList.first() - .run { this.copy(publicKey = replaceVersionInKey(this.publicKey)) } + val actual = parseKeyResult.pgpKeyDetailsList.first().copy( + /* + * we replace publicKey source here because it can't be a constant. + * If other fields of [PgpKeyRingDetails] will be the same it means objects are equal + */ + publicKey = expected.publicKey + ) assertEquals(expected, actual) } From 8ef5cc00572b04dc9e59afdeb90604963566775c Mon Sep 17 00:00:00 2001 From: denbond7 Date: Thu, 27 Mar 2025 16:05:24 +0200 Subject: [PATCH 3/3] wip --- ...seAndSavePubKeysFragmentInIsolationTest.kt | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/isolation/incontainer/ParseAndSavePubKeysFragmentInIsolationTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/isolation/incontainer/ParseAndSavePubKeysFragmentInIsolationTest.kt index 9e643b2f32..b056961e1c 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/isolation/incontainer/ParseAndSavePubKeysFragmentInIsolationTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/fragment/isolation/incontainer/ParseAndSavePubKeysFragmentInIsolationTest.kt @@ -36,7 +36,6 @@ import com.flowcrypt.email.ui.activity.fragment.ParseAndSavePubKeysFragmentArgs import com.flowcrypt.email.util.PrivateKeysManager import com.flowcrypt.email.util.TestGeneralUtil import com.flowcrypt.email.viewaction.ClickOnViewInRecyclerViewItem -import org.hamcrest.Matchers.allOf import org.junit.Rule import org.junit.Test import org.junit.rules.RuleChain @@ -85,30 +84,7 @@ class ParseAndSavePubKeysFragmentInIsolationTest : BaseTest() { ) onView(withId(R.id.rVPubKeys)) - .check(matches(withRecyclerViewItemCount(6))) - - onView(withId(R.id.rVPubKeys)) - .check( - matches( - hasItem( - withChild( - allOf( - hasSibling( - withText(getResString(R.string.cannot_be_used_for_encryption)) - ), - hasSibling( - withText( - getResString( - R.string.template_message_part_public_key_owner, - "dsa@flowcrypt.test" - ) - ) - ) - ) - ) - ) - ) - ) + .check(matches(withRecyclerViewItemCount(5))) } @Test