This commit is contained in:
Valere 2021-11-19 15:16:29 +01:00
parent 9e055d9793
commit c01998ddd3
12 changed files with 20 additions and 27 deletions

View file

@ -105,7 +105,7 @@ interface CrossSigningService {
fun trustDevice(deviceId: String,
callback: MatrixCallback<Unit>)
suspend fun shieldForGroup(userIds: List<String>) : RoomEncryptionTrustLevel
suspend fun shieldForGroup(userIds: List<String>): RoomEncryptionTrustLevel
/**
* Check if a device is trusted

View file

@ -41,7 +41,6 @@ import org.matrix.android.sdk.api.listeners.ProgressListener
import org.matrix.android.sdk.api.session.crypto.CryptoService
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
import org.matrix.android.sdk.api.session.crypto.keyshare.GossipingRequestListener
import org.matrix.android.sdk.api.session.events.model.Content
import org.matrix.android.sdk.api.session.events.model.Event
@ -310,7 +309,7 @@ internal class DefaultCryptoService @Inject constructor(
setRustLogger()
Timber.v(
"## CRYPTO | Successfully started up an Olm machine for " +
"${userId}, ${deviceId}, identity keys: ${this.olmMachine.identityKeys()}")
"$userId, $deviceId, identity keys: ${this.olmMachine.identityKeys()}")
} catch (throwable: Throwable) {
Timber.v("Failed create an Olm machine: $throwable")
}
@ -408,7 +407,7 @@ internal class DefaultCryptoService @Inject constructor(
override fun getLiveCryptoDeviceInfo(userIds: List<String>): LiveData<List<CryptoDeviceInfo>> {
return runBlocking {
this@DefaultCryptoService.olmMachine.getLiveDevices(userIds) //?: LiveDevice(userIds, deviceObserver)
this@DefaultCryptoService.olmMachine.getLiveDevices(userIds) // ?: LiveDevice(userIds, deviceObserver)
}
}
@ -626,9 +625,9 @@ internal class DefaultCryptoService @Inject constructor(
cryptoCoroutineScope.launch {
olmMachine.updateTrackedUsers(listOf(userId))
}
} else if (membership == Membership.INVITE
&& shouldEncryptForInvitedMembers(roomId)
&& isEncryptionEnabledForInvitedUser()) {
} else if (membership == Membership.INVITE &&
shouldEncryptForInvitedMembers(roomId) &&
isEncryptionEnabledForInvitedUser()) {
// track the deviceList for this invited user.
// Caution: there's a big edge case here in that federated servers do not
// know what other servers are in the room at the time they've been invited.
@ -1010,7 +1009,7 @@ internal class DefaultCryptoService @Inject constructor(
// where we would download the fresh info from the server.
this@DefaultCryptoService.olmMachine.getUserDevicesMap(userIds) // ?: MXUsersDevicesMap()
} else {
this@DefaultCryptoService.olmMachine.getUserDevicesMap(userIds) //?: MXUsersDevicesMap()
this@DefaultCryptoService.olmMachine.getUserDevicesMap(userIds) // ?: MXUsersDevicesMap()
}
}.foldToCallback(callback)
}

View file

@ -25,10 +25,10 @@ import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.internal.crypto.model.rest.UnsignedDeviceInfo
import org.matrix.android.sdk.internal.crypto.verification.prepareMethods
import uniffi.olm.CryptoStoreException
import uniffi.olm.Device as InnerDevice
import uniffi.olm.OlmMachine
import uniffi.olm.SignatureException
import uniffi.olm.VerificationRequest
import uniffi.olm.Device as InnerDevice
/** Class representing a device that supports E2EE in the Matrix world
*

View file

@ -22,7 +22,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.listeners.ProgressListener
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
@ -771,7 +770,6 @@ internal class OlmMachine(
suspend fun exportCrossSigningKeys(): PrivateKeysInfo? {
val export = withContext(Dispatchers.IO) {
inner.exportCrossSigningKeys()
} ?: return null
return PrivateKeysInfo(export.masterKey, export.selfSigningKey, export.userSigningKey)

View file

@ -174,8 +174,7 @@ internal class QrCodeVerification(
*/
@Throws(CryptoStoreException::class)
private suspend fun confirm() {
val result = withContext(Dispatchers.IO)
{
val result = withContext(Dispatchers.IO) {
machine.confirmVerification(request.otherUser(), request.flowId())
}

View file

@ -168,8 +168,8 @@ internal class RequestSender @Inject constructor(
try {
uploadSigningKeysTask.execute(uploadSigningKeysParams)
} catch (failure: Throwable) {
if (interactiveAuthInterceptor == null
|| !handleUIA(
if (interactiveAuthInterceptor == null ||
!handleUIA(
failure = failure,
interceptor = interactiveAuthInterceptor,
retryBlock = { authUpdate ->
@ -218,8 +218,8 @@ internal class RequestSender @Inject constructor(
getKeysBackupLastVersionTask.execute(Unit)
}
} catch (failure: Throwable) {
if (failure is Failure.ServerError
&& failure.error.code == MatrixError.M_NOT_FOUND) {
if (failure is Failure.ServerError &&
failure.error.code == MatrixError.M_NOT_FOUND) {
null
} else {
throw failure

View file

@ -37,7 +37,6 @@ import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupStateListener
import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM_BACKUP
import org.matrix.android.sdk.internal.crypto.MegolmSessionData
import org.matrix.android.sdk.internal.crypto.OlmMachine
import org.matrix.android.sdk.internal.crypto.OlmMachineProvider
import org.matrix.android.sdk.internal.crypto.RequestSender
import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupVersionTrust

View file

@ -73,8 +73,8 @@ internal interface VerificationInfoStart : VerificationInfo<ValidVerificationInf
val validHashes = hashes?.takeIf { it.contains("sha256") } ?: return null
val validMessageAuthenticationCodes = messageAuthenticationCodes
?.takeIf {
it.contains(SAS_MAC_SHA256)
|| it.contains(SAS_MAC_SHA256_LONGKDF)
it.contains(SAS_MAC_SHA256) ||
it.contains(SAS_MAC_SHA256_LONGKDF)
}
?: return null
val validShortAuthenticationStrings = shortAuthenticationStrings?.takeIf { it.contains(SasMode.DECIMAL) } ?: return null

View file

@ -117,7 +117,7 @@ internal interface SessionComponent {
fun taskExecutor(): TaskExecutor
fun olmMachineProvider() : OlmMachineProvider
fun olmMachineProvider(): OlmMachineProvider
fun inject(worker: SendEventWorker)

View file

@ -174,13 +174,13 @@ internal class CreateRoomBodyBuilder @Inject constructor(
}
private suspend fun canEnableEncryption(params: CreateRoomParams): Boolean {
return params.enableEncryptionIfInvitedUsersSupportIt
return params.enableEncryptionIfInvitedUsersSupportIt &&
// Parity with web, enable if users have encryption ready devices
// for now remove checks on cross signing and 3pid invites
// && crossSigningService.isCrossSigningVerified()
&& params.invite3pids.isEmpty()
&& params.invitedUserIds.isNotEmpty()
&& params.invitedUserIds.let { userIds ->
params.invite3pids.isEmpty() &&
params.invitedUserIds.isNotEmpty() &&
params.invitedUserIds.let { userIds ->
val keys = olmMachineProvider.olmMachine.getUserDevicesMap(userIds)
// deviceListManager.downloadKeys(userIds, forceDownload = false)

View file

@ -62,7 +62,6 @@ import org.matrix.android.sdk.internal.session.room.accountdata.RoomAccountDataD
import org.matrix.android.sdk.internal.session.room.membership.RoomDisplayNameResolver
import org.matrix.android.sdk.internal.session.room.membership.RoomMemberHelper
import org.matrix.android.sdk.internal.session.room.relationship.RoomChildRelationInfo
import org.matrix.android.sdk.internal.util.Normalizer
import timber.log.Timber
import javax.inject.Inject
import kotlin.system.measureTimeMillis

View file

@ -88,7 +88,6 @@ import im.vector.app.features.widgets.WidgetActivity
import im.vector.app.features.widgets.WidgetArgsBuilder
import im.vector.app.space
import org.matrix.android.sdk.api.session.crypto.verification.SasVerificationTransaction
import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction
import org.matrix.android.sdk.api.session.permalinks.PermalinkData
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom
import org.matrix.android.sdk.api.session.terms.TermsService