diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/CreateMessageActivityTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/CreateMessageActivityTest.kt index d0bf52971c..48a20a6250 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/CreateMessageActivityTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/CreateMessageActivityTest.kt @@ -615,7 +615,8 @@ class CreateMessageActivityTest : BaseCreateMessageActivityTest() { } @Test - fun testShowWarningIfFoundNotUsableKeySHA1() { + //fun testShowWarningIfFoundNotUsableKeySHA1() { + fun testAcceptIfFoundKeySHA1() { val keyWithSHA1Algo = TestGeneralUtil.readFileFromAssetsAsString("pgp/sha1@flowcrypt.test_pub.asc") val contact = PgpContact( @@ -639,18 +640,20 @@ class CreateMessageActivityTest : BaseCreateMessageActivityTest() { contact.email, UIUtil.getColor( getTargetContext(), - CustomChipSpanChipCreator.CHIP_COLOR_RES_ID_PGP_NOT_USABLE + CustomChipSpanChipCreator.CHIP_COLOR_RES_ID_PGP_EXISTS ) ) ) ) + /* + temporary disabled due too https://github.com/FlowCrypt/flowcrypt-android/issues/1478 onView(withId(R.id.menuActionSend)) .check(matches(isDisplayed())) .perform(click()) onView(withText(R.string.warning_one_of_pub_keys_is_not_usable)) .check(matches(isDisplayed())) - .perform(click()) + .perform(click())*/ } @Test diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/ImportPrivateKeyActivityFromSettingsTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/ImportPrivateKeyActivityFromSettingsTest.kt index e1d31deb2d..936cd48930 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/ImportPrivateKeyActivityFromSettingsTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/ImportPrivateKeyActivityFromSettingsTest.kt @@ -43,6 +43,7 @@ import org.hamcrest.Matchers.hasItem import org.junit.AfterClass import org.junit.Assert import org.junit.BeforeClass +import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.rules.RuleChain @@ -121,6 +122,9 @@ class ImportPrivateKeyActivityFromSettingsTest : BaseTest() { @Test @DependsOnMailServer + @Ignore( + "Temporary disabled due to https://github.com/FlowCrypt/flowcrypt-android/issues/1478" + ) fun testShowErrorWhenImportingKeyFromFileSHA1() { val prvKeyAsString = TestGeneralUtil.readFileFromAssetsAsString( "pgp/sha1@flowcrypt.test_prv_default.asc" diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/FlowCryptApplication.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/FlowCryptApplication.kt index 6fe2000d84..a72d25f486 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/FlowCryptApplication.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/FlowCryptApplication.kt @@ -30,6 +30,9 @@ import org.acra.config.httpSender import org.acra.data.StringFormat import org.acra.ktx.initAcra import org.acra.sender.HttpSender +import org.pgpainless.PGPainless +import org.pgpainless.algorithm.HashAlgorithm +import org.pgpainless.policy.Policy.HashAlgorithmPolicy import java.util.Calendar import java.util.Locale import java.util.concurrent.TimeUnit @@ -45,6 +48,7 @@ import java.util.concurrent.TimeUnit class FlowCryptApplication : Application(), Configuration.Provider { override fun onCreate() { super.onCreate() + enableDeprecatedSHA1ForPGPainlessPolicy() setupKeysStorage() initPerInstallationSharedPrefs() CacheManager.init(this) @@ -65,6 +69,25 @@ class FlowCryptApplication : Application(), Configuration.Provider { .setJobSchedulerJobIdRange(JobIdManager.JOB_MAX_ID, JobIdManager.JOB_MAX_ID + 10000) .build() + /** + * Allow sha1 for all builds except enterprise. It's a temporary solution. + * More details here https://github.com/FlowCrypt/flowcrypt-android/issues/1478 and here + * https://github.com/pgpainless/pgpainless/issues/158 + */ + private fun enableDeprecatedSHA1ForPGPainlessPolicy() { + if (BuildConfig.FLAVOR != Constants.FLAVOR_NAME_ENTERPRISE) { + PGPainless.getPolicy().signatureHashAlgorithmPolicy = HashAlgorithmPolicy( + HashAlgorithm.SHA512, listOf( + HashAlgorithm.SHA512, + HashAlgorithm.SHA384, + HashAlgorithm.SHA256, + HashAlgorithm.SHA224, + HashAlgorithm.SHA1 + ) + ) + } + } + private fun setupKeysStorage() { val keysStorage = KeysStorageImpl.getInstance(this) keysStorage.secretKeyRingsLiveData.observeForever {