mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 21:48:50 +03:00
Kotlin optimization form #1435
This commit is contained in:
parent
8fb3c68573
commit
9ce1222fd0
3 changed files with 3 additions and 7 deletions
|
@ -38,7 +38,6 @@ import org.matrix.android.sdk.internal.task.TaskThread
|
||||||
import org.matrix.android.sdk.internal.task.configureWith
|
import org.matrix.android.sdk.internal.task.configureWith
|
||||||
import org.matrix.android.sdk.internal.util.JsonCanonicalizer
|
import org.matrix.android.sdk.internal.util.JsonCanonicalizer
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import org.matrix.android.sdk.internal.util.withoutPrefix
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
||||||
|
@ -444,7 +443,7 @@ internal class DefaultCrossSigningService @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
// Maybe it's signed by a locally trusted device?
|
// Maybe it's signed by a locally trusted device?
|
||||||
myMasterKey.signatures?.get(userId)?.forEach { (key, value) ->
|
myMasterKey.signatures?.get(userId)?.forEach { (key, value) ->
|
||||||
val potentialDeviceId = key.withoutPrefix("ed25519:")
|
val potentialDeviceId = key.removePrefix("ed25519:")
|
||||||
val potentialDevice = myDevices?.firstOrNull { it.deviceId == potentialDeviceId } // cryptoStore.getUserDevice(userId, potentialDeviceId)
|
val potentialDevice = myDevices?.firstOrNull { it.deviceId == potentialDeviceId } // cryptoStore.getUserDevice(userId, potentialDeviceId)
|
||||||
if (potentialDevice != null && potentialDevice.isVerified) {
|
if (potentialDevice != null && potentialDevice.isVerified) {
|
||||||
// Check signature validity?
|
// Check signature validity?
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequestManager
|
||||||
import org.matrix.android.sdk.internal.crypto.actions.SetDeviceVerificationAction
|
import org.matrix.android.sdk.internal.crypto.actions.SetDeviceVerificationAction
|
||||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||||
import org.matrix.android.sdk.internal.extensions.toUnsignedInt
|
import org.matrix.android.sdk.internal.extensions.toUnsignedInt
|
||||||
import org.matrix.android.sdk.internal.util.withoutPrefix
|
|
||||||
import org.matrix.olm.OlmSAS
|
import org.matrix.olm.OlmSAS
|
||||||
import org.matrix.olm.OlmUtility
|
import org.matrix.olm.OlmUtility
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
@ -250,7 +249,7 @@ internal abstract class SASDefaultVerificationTransaction(
|
||||||
|
|
||||||
// cannot be empty because it has been validated
|
// cannot be empty because it has been validated
|
||||||
theirMacSafe.mac.keys.forEach {
|
theirMacSafe.mac.keys.forEach {
|
||||||
val keyIDNoPrefix = it.withoutPrefix("ed25519:")
|
val keyIDNoPrefix = it.removePrefix("ed25519:")
|
||||||
val otherDeviceKey = otherUserKnownDevices?.get(keyIDNoPrefix)?.fingerprint()
|
val otherDeviceKey = otherUserKnownDevices?.get(keyIDNoPrefix)?.fingerprint()
|
||||||
if (otherDeviceKey == null) {
|
if (otherDeviceKey == null) {
|
||||||
Timber.w("## SAS Verification: Could not find device $keyIDNoPrefix to verify")
|
Timber.w("## SAS Verification: Could not find device $keyIDNoPrefix to verify")
|
||||||
|
@ -273,7 +272,7 @@ internal abstract class SASDefaultVerificationTransaction(
|
||||||
if (otherCrossSigningMasterKeyPublic != null) {
|
if (otherCrossSigningMasterKeyPublic != null) {
|
||||||
// Did the user signed his master key
|
// Did the user signed his master key
|
||||||
theirMacSafe.mac.keys.forEach {
|
theirMacSafe.mac.keys.forEach {
|
||||||
val keyIDNoPrefix = it.withoutPrefix("ed25519:")
|
val keyIDNoPrefix = it.removePrefix("ed25519:")
|
||||||
if (keyIDNoPrefix == otherCrossSigningMasterKeyPublic) {
|
if (keyIDNoPrefix == otherCrossSigningMasterKeyPublic) {
|
||||||
// Check the signature
|
// Check the signature
|
||||||
val mac = macUsingAgreedMethod(otherCrossSigningMasterKeyPublic, baseInfo + it)
|
val mac = macUsingAgreedMethod(otherCrossSigningMasterKeyPublic, baseInfo + it)
|
||||||
|
|
|
@ -50,8 +50,6 @@ fun convertFromUTF8(s: String): String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.withoutPrefix(prefix: String) = if (startsWith(prefix)) substringAfter(prefix) else this
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a string contains an occurrence of another, as a standalone word, regardless of case.
|
* Returns whether a string contains an occurrence of another, as a standalone word, regardless of case.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue