Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FlowCrypt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down