Merge pull request #5871 from vector-im/feature/bca/fix_freeze_setup_recovery
fix doing password stretching on main thread
This commit is contained in:
commit
271eb31162
1
changelog.d/5871.bugfix
Normal file
1
changelog.d/5871.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix UX freezing when creating secure backup
|
@ -66,7 +66,7 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
|
||||
key: SsssKeySpec?,
|
||||
keyName: String,
|
||||
keySigner: KeySigner?): SsssKeyCreationInfo {
|
||||
return withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.main) {
|
||||
return withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.computation) {
|
||||
val bytes = (key as? RawBytesKeySpec)?.privateKey
|
||||
?: ByteArray(32).also {
|
||||
SecureRandom().nextBytes(it)
|
||||
@ -99,7 +99,7 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
|
||||
passphrase: String,
|
||||
keySigner: KeySigner,
|
||||
progressListener: ProgressListener?): SsssKeyCreationInfo {
|
||||
return withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.main) {
|
||||
return withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.computation) {
|
||||
val privatePart = generatePrivateKeyWithPassword(passphrase, progressListener)
|
||||
|
||||
val storageKeyContent = SecretStorageKeyContent(
|
||||
@ -158,7 +158,7 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
|
||||
}
|
||||
|
||||
override suspend fun storeSecret(name: String, secretBase64: String, keys: List<SharedSecretStorageService.KeyRef>) {
|
||||
withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.main) {
|
||||
withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.computation) {
|
||||
val encryptedContents = HashMap<String, EncryptedSecretContent>()
|
||||
keys.forEach {
|
||||
val keyId = it.keyId
|
||||
@ -316,7 +316,7 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
|
||||
val algorithm = key.keyInfo.content
|
||||
if (SSSS_ALGORITHM_CURVE25519_AES_SHA2 == algorithm.algorithm) {
|
||||
val keySpec = secretKey as? RawBytesKeySpec ?: throw SharedSecretStorageError.BadKeyFormat
|
||||
return withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.main) {
|
||||
return withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.computation) {
|
||||
// decrypt from recovery key
|
||||
withOlmDecryption { olmPkDecryption ->
|
||||
olmPkDecryption.setPrivateKey(keySpec.privateKey)
|
||||
@ -331,7 +331,7 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
|
||||
}
|
||||
} else if (SSSS_ALGORITHM_AES_HMAC_SHA2 == algorithm.algorithm) {
|
||||
val keySpec = secretKey as? RawBytesKeySpec ?: throw SharedSecretStorageError.BadKeyFormat
|
||||
return withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.main) {
|
||||
return withContext(cryptoCoroutineScope.coroutineContext + coroutineDispatchers.computation) {
|
||||
decryptAesHmacSha2(keySpec, name, secretContent)
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user