File tree Expand file tree Collapse file tree 3 files changed +22
-12
lines changed
main/java/com/flowcrypt/email/extensions/org/bouncycastle/openpgp
test/java/com/flowcrypt/email/security/pgp Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -468,7 +468,7 @@ dependencies {
468468 implementation(" org.bitbucket.b_c:jose4j:0.9.6" )
469469 implementation(" org.jsoup:jsoup:1.19.1" )
470470 implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1" )
471- implementation(" org.pgpainless:pgpainless-core:1.7.3 " )
471+ implementation(" org.pgpainless:pgpainless-core:1.7.5 " )
472472 implementation(" org.eclipse.angus:angus-mail:2.0.3" )
473473 implementation(" org.eclipse.angus:gimap:2.0.3" )
474474 implementation(" commons-io:commons-io:2.18.0" )
Original file line number Diff line number Diff line change @@ -38,6 +38,13 @@ import java.time.Instant
3838@Throws(IOException ::class )
3939@WorkerThread
4040fun PGPKeyRing.toPgpKeyRingDetails (hideArmorMeta : Boolean = false): PgpKeyRingDetails {
41+ if (containsHashAlgorithmWithSHA1()) {
42+ val sigHashAlgoPolicy = PGPainless .getPolicy().certificationSignatureHashAlgorithmPolicy
43+ if (! sigHashAlgoPolicy.isAcceptable(HashAlgorithm .SHA1 )) {
44+ throw PGPException (" Unsupported signature(HashAlgorithm = SHA1)" )
45+ }
46+ }
47+
4148 val keyRingInfo = KeyRingInfo (this )
4249
4350 val algo = Algo (
@@ -56,13 +63,6 @@ fun PGPKeyRing.toPgpKeyRingDetails(hideArmorMeta: Boolean = false): PgpKeyRingDe
5663 throw IllegalArgumentException (" There are no fingerprints" )
5764 }
5865
59- if (containsHashAlgorithmWithSHA1()) {
60- val sigHashAlgoPolicy = PGPainless .getPolicy().certificationSignatureHashAlgorithmPolicy
61- if (! sigHashAlgoPolicy.isAcceptable(HashAlgorithm .SHA1 )) {
62- throw PGPException (" Unsupported signature(HashAlgorithm = SHA1)" )
63- }
64- }
65-
6666 val privateKey = if (keyRingInfo.isSecretKey) armor(hideArmorMeta = hideArmorMeta) else null
6767 val publicKey = if (keyRingInfo.isSecretKey) {
6868 (this as PGPSecretKeyRing ).toPublicKeyRing().armor(hideArmorMeta = hideArmorMeta)
Original file line number Diff line number Diff line change @@ -81,8 +81,13 @@ class PgpKeyTest {
8181 )
8282 val parseKeyResult = PgpKey .parseKeys(source = TestKeys .KEYS [" rsa1" ]!! .publicKey)
8383 assertEquals(1 , parseKeyResult.getAllKeys().size)
84- val actual = parseKeyResult.pgpKeyDetailsList.first()
85- .run { this .copy(publicKey = replaceVersionInKey(this .publicKey)) }
84+ val actual = parseKeyResult.pgpKeyDetailsList.first().copy(
85+ /*
86+ * we replace publicKey source here because it can't be a constant.
87+ * If other fields of [PgpKeyRingDetails] will be the same it means objects are equal
88+ */
89+ publicKey = expected.publicKey
90+ )
8691 assertEquals(expected, actual)
8792 }
8893
@@ -122,8 +127,13 @@ class PgpKeyTest {
122127 )
123128 val parseKeyResult = PgpKey .parseKeys(source = TestKeys .KEYS [" expired" ]!! .publicKey)
124129 assertEquals(1 , parseKeyResult.getAllKeys().size)
125- val actual = parseKeyResult.pgpKeyDetailsList.first()
126- .run { this .copy(publicKey = replaceVersionInKey(this .publicKey)) }
130+ val actual = parseKeyResult.pgpKeyDetailsList.first().copy(
131+ /*
132+ * we replace publicKey source here because it can't be a constant.
133+ * If other fields of [PgpKeyRingDetails] will be the same it means objects are equal
134+ */
135+ publicKey = expected.publicKey
136+ )
127137 assertEquals(expected, actual)
128138 }
129139
You can’t perform that action at this time.
0 commit comments