diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/verification/VerificationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/verification/VerificationService.kt index e7d8e6d91c..000dd17916 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/verification/VerificationService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/verification/VerificationService.kt @@ -45,6 +45,18 @@ interface VerificationService { fun getExistingVerificationRequestInRoom(roomId: String, tid: String?): PendingVerificationRequest? + + /** + * Request an interactive verification to begin + * + * This sends out a m.key.verification.request event over to-device messaging to + * to this device. + * + * If no specific device should be verified, but we would like to request + * verification from all our devices, use [requestSelfKeyVerification] instead. + */ + suspend fun requestDeviceVerification(methods: List, otherUserId: String, otherDeviceId: String): PendingVerificationRequest? + /** * Request key verification with another user via room events (instead of the to-device API). */ diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/Device.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/Device.kt index 90bf533d58..e248d11360 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/Device.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/Device.kt @@ -28,7 +28,6 @@ import org.matrix.android.sdk.internal.crypto.verification.prepareMethods import uniffi.olm.CryptoStoreException 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 @@ -71,10 +70,15 @@ internal class Device( val result = withContext(coroutineDispatchers.io) { machine.requestVerificationWithDevice(inner.userId, inner.deviceId, stringMethods) } - return if (result != null) { sender.sendVerificationRequest(result.request) - result.verification + VerificationRequest( + machine = machine, + inner = result.verification, + sender = sender, + coroutineDispatchers = coroutineDispatchers, + listeners = listeners + ) } else { null } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/RustVerificationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/RustVerificationService.kt index 3e5f200edc..dd0d526055 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/RustVerificationService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/RustVerificationService.kt @@ -254,6 +254,14 @@ internal class RustVerificationService @Inject constructor(private val olmMachin return verification.toPendingVerificationRequest() } + + override suspend fun requestDeviceVerification(methods: List, otherUserId: String, otherDeviceId: String): PendingVerificationRequest? { + olmMachine.ensureUsersKeys(listOf(otherUserId)) + val otherDevice = olmMachine.getDevice(otherUserId, otherDeviceId) + val verificationRequest = otherDevice?.requestVerification(methods) + return verificationRequest?.toPendingVerificationRequest() + } + override suspend fun readyPendingVerification( methods: List, otherUserId: String,