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 fa09f30f8e..ec89cb5f8a 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 @@ -18,10 +18,13 @@ package org.matrix.android.sdk.internal.crypto import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod import org.matrix.android.sdk.api.session.crypto.verification.VerificationService +import org.matrix.android.sdk.internal.crypto.verification.prepareMethods import uniffi.olm.CryptoStoreErrorException import uniffi.olm.Device as InnerDevice import uniffi.olm.OlmMachine +import uniffi.olm.VerificationRequest /** Class representing a device that supports E2EE in the Matrix world * @@ -34,13 +37,31 @@ internal class Device( private val sender: RequestSender, private val listeners: ArrayList, ) { + /** Request an interactive verification to begin + * + * This sends out a m.key.verification.request event over to-device messaging to + * to this device. + */ + @Throws(CryptoStoreErrorException::class) + suspend fun requestVerification(methods: List): VerificationRequest? { + val stringMethods = prepareMethods(methods) + val result = withContext(Dispatchers.IO) { + machine.requestVerificationWithDevice(inner.userId, inner.deviceId, stringMethods) + } + + return if (result != null) { + this.sender.sendVerificationRequest(result.request) + result.verification + } else { + null + } + } + /** Start an interactive verification with this device * * This sends out a m.key.verification.start event with the method set to * m.sas.v1 to this device using to-device messaging. */ - // TODO this has been deprecated in the spec, add a requestVerification() method - // to this class and use that one instead @Throws(CryptoStoreErrorException::class) suspend fun startVerification(): SasVerification? { val result = withContext(Dispatchers.IO) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/QrCodeVerification.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/QrCodeVerification.kt index 7bde4b4b23..d9d914d789 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/QrCodeVerification.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/QrCodeVerification.kt @@ -32,6 +32,7 @@ import uniffi.olm.OutgoingVerificationRequest import uniffi.olm.QrCode import uniffi.olm.Verification +/** Class representing a QR code based verification flow */ internal class QrCodeVerification( private val machine: OlmMachine, private var request: VerificationRequest, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SasVerification.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SasVerification.kt index cd1a7fc188..ad8322a2ab 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SasVerification.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SasVerification.kt @@ -33,6 +33,7 @@ import uniffi.olm.OutgoingVerificationRequest import uniffi.olm.Sas import uniffi.olm.Verification +/** Class representing a short auth string verification flow */ internal class SasVerification( private val machine: OlmMachine, private var inner: Sas,