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
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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 {
Expand Down