diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/qrcode/VerificationTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/qrcode/VerificationTest.kt index e5ffc2ae01..d5e9e25b02 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/qrcode/VerificationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/qrcode/VerificationTest.kt @@ -24,7 +24,7 @@ import im.vector.matrix.android.common.CommonTestHelper import im.vector.matrix.android.common.CryptoTestHelper import im.vector.matrix.android.common.TestConstants import im.vector.matrix.android.internal.crypto.model.rest.UserPasswordAuth -import im.vector.matrix.android.internal.crypto.verification.PendingVerificationRequest +import im.vector.matrix.android.api.session.crypto.verification.PendingVerificationRequest import org.amshove.kluent.shouldBe import org.junit.FixMethodOrder import org.junit.Test diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/PendingVerificationRequest.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/PendingVerificationRequest.kt similarity index 93% rename from matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/PendingVerificationRequest.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/PendingVerificationRequest.kt index 8f7b4ad641..55f0738325 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/PendingVerificationRequest.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/PendingVerificationRequest.kt @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.matrix.android.internal.crypto.verification +package im.vector.matrix.android.api.session.crypto.verification import im.vector.matrix.android.api.extensions.orFalse -import im.vector.matrix.android.api.session.crypto.verification.CancelCode import im.vector.matrix.android.internal.crypto.model.rest.VERIFICATION_METHOD_QR_CODE_SCAN import im.vector.matrix.android.internal.crypto.model.rest.VERIFICATION_METHOD_QR_CODE_SHOW import im.vector.matrix.android.internal.crypto.model.rest.VERIFICATION_METHOD_SAS @@ -24,7 +23,6 @@ import java.util.UUID /** * Stores current pending verification requests - * TODO We should not expose this whole object to the app. Create an interface */ data class PendingVerificationRequest( val ageLocalTs: Long, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/ValidVerificationInfoReady.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/ValidVerificationInfoReady.kt new file mode 100644 index 0000000000..818e491d88 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/ValidVerificationInfoReady.kt @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.matrix.android.api.session.crypto.verification + +data class ValidVerificationInfoReady( + val transactionID: String, + val fromDevice: String, + val methods: List +) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/ValidVerificationInfoRequest.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/ValidVerificationInfoRequest.kt new file mode 100644 index 0000000000..720e6fb29c --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/ValidVerificationInfoRequest.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.matrix.android.api.session.crypto.verification + +data class ValidVerificationInfoRequest( + val transactionID: String, + val fromDevice: String, + val methods: List, + val timestamp: Long? +) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/VerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/VerificationService.kt index d65bd7bb6a..5cad8d985c 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/VerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/verification/VerificationService.kt @@ -18,7 +18,6 @@ package im.vector.matrix.android.api.session.crypto.verification import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.session.events.model.LocalEcho -import im.vector.matrix.android.internal.crypto.verification.PendingVerificationRequest /** * https://matrix.org/docs/spec/client_server/r0.5.0#key-verification-framework diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationStart.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationStart.kt index ff857591ea..4872e126c8 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationStart.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationStart.kt @@ -26,7 +26,7 @@ import im.vector.matrix.android.internal.util.JsonCanonicalizer @JsonClass(generateAdapter = true) internal data class KeyVerificationStart( @Json(name = "from_device") override val fromDevice: String? = null, - override val method: String? = null, + @Json(name = "method") override val method: String? = null, @Json(name = "transaction_id") override val transactionID: String? = null, @Json(name = "key_agreement_protocols") override val keyAgreementProtocols: List? = null, @Json(name = "hashes") override val hashes: List? = null, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt index 94dafb29c7..e549863e17 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt @@ -213,7 +213,7 @@ internal class DefaultIncomingSASDefaultVerificationTransaction( state = VerificationTxState.ShortCodeReady } - override fun onKeyVerificationMac(vKey: ValidVerificationInfoMac) { + override fun onKeyVerificationMac(vMac: ValidVerificationInfoMac) { Timber.v("## SAS I: received mac for request id:$transactionId") // Check for state? if (state != VerificationTxState.SendingKey @@ -226,7 +226,7 @@ internal class DefaultIncomingSASDefaultVerificationTransaction( cancel(CancelCode.UnexpectedMessage) return } - theirMac = vKey + theirMac = vMac // Do I have my Mac? if (myMac != null) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt index 2c592523fe..e7dd6d632e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt @@ -94,7 +94,7 @@ internal class DefaultOutgoingSASDefaultVerificationTransaction( KNOWN_MACS, KNOWN_SHORT_CODES ) -kk + startReq = startMessage.asValidObject() as? ValidVerificationInfoStart.SasVerificationInfoStart state = VerificationTxState.SendingStart @@ -206,7 +206,7 @@ kk } } - override fun onKeyVerificationMac(vKey: ValidVerificationInfoMac) { + override fun onKeyVerificationMac(vMac: ValidVerificationInfoMac) { Timber.v("## SAS O: onKeyVerificationMac id:$transactionId") if (state != VerificationTxState.OnKeyReceived && state != VerificationTxState.ShortCodeReady @@ -218,7 +218,7 @@ kk return } - theirMac = vKey + theirMac = vMac // Do I have my Mac? if (myMac != null) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt index f3fdc47513..9d2f7403aa 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt @@ -20,6 +20,8 @@ import android.os.Handler import android.os.Looper import dagger.Lazy import im.vector.matrix.android.api.MatrixCallback +import im.vector.matrix.android.api.session.crypto.verification.PendingVerificationRequest +import im.vector.matrix.android.api.session.crypto.verification.ValidVerificationInfoReady import im.vector.matrix.android.api.session.crypto.CryptoService import im.vector.matrix.android.api.session.crypto.crosssigning.CrossSigningService import im.vector.matrix.android.api.session.crypto.verification.CancelCode diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt index f5166a6945..9be40a6e34 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt @@ -207,7 +207,7 @@ internal abstract class SASDefaultVerificationTransaction( abstract fun onKeyVerificationKey(vKey: ValidVerificationInfoKey) - abstract fun onKeyVerificationMac(vKey: ValidVerificationInfoMac)vMac + abstract fun onKeyVerificationMac(vMac: ValidVerificationInfoMac) protected fun verifyMacs() { Timber.v("## SAS verifying macs for id:$transactionId") diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationInfoReady.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationInfoReady.kt index 35bc2fcafe..41062484e3 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationInfoReady.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationInfoReady.kt @@ -15,6 +15,8 @@ */ package im.vector.matrix.android.internal.crypto.verification +import im.vector.matrix.android.api.session.crypto.verification.ValidVerificationInfoReady + /** * A new event type is added to the key verification framework: m.key.verification.ready, * which may be sent by the target of the m.key.verification.request message, upon receipt of the m.key.verification.request event. @@ -53,8 +55,3 @@ internal interface MessageVerificationReadyFactory { fun create(tid: String, methods: List, fromDevice: String): VerificationInfoReady } -internal data class ValidVerificationInfoReady( - val transactionID: String, - val fromDevice: String, - val methods: List -) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationInfoRequest.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationInfoRequest.kt index b1ee9a46b8..8cb55f2987 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationInfoRequest.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationInfoRequest.kt @@ -15,6 +15,8 @@ */ package im.vector.matrix.android.internal.crypto.verification +import im.vector.matrix.android.api.session.crypto.verification.ValidVerificationInfoRequest + internal interface VerificationInfoRequest : VerificationInfo { /** @@ -48,9 +50,3 @@ internal interface VerificationInfoRequest : VerificationInfo, - val timestamp: Long? -) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransport.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransport.kt index e5f9258a92..db3255a28f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransport.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransport.kt @@ -15,6 +15,7 @@ */ package im.vector.matrix.android.internal.crypto.verification +import im.vector.matrix.android.api.session.crypto.verification.ValidVerificationInfoRequest import im.vector.matrix.android.api.session.crypto.verification.CancelCode import im.vector.matrix.android.api.session.crypto.verification.VerificationTxState diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportRoomMessage.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportRoomMessage.kt index c226d6ad9f..09330d1ad7 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportRoomMessage.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportRoomMessage.kt @@ -22,6 +22,7 @@ import androidx.work.ExistingWorkPolicy import androidx.work.Operation import androidx.work.WorkInfo import im.vector.matrix.android.R +import im.vector.matrix.android.api.session.crypto.verification.ValidVerificationInfoRequest import im.vector.matrix.android.api.session.crypto.verification.CancelCode import im.vector.matrix.android.api.session.crypto.verification.VerificationTxState import im.vector.matrix.android.api.session.events.model.Content diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportToDevice.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportToDevice.kt index 7172a27a2b..3284d79152 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportToDevice.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/VerificationTransportToDevice.kt @@ -16,6 +16,7 @@ package im.vector.matrix.android.internal.crypto.verification import im.vector.matrix.android.api.MatrixCallback +import im.vector.matrix.android.api.session.crypto.verification.ValidVerificationInfoRequest import im.vector.matrix.android.api.session.crypto.verification.CancelCode import im.vector.matrix.android.api.session.crypto.verification.VerificationTxState import im.vector.matrix.android.api.session.events.model.EventType diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt index 2a19dd8784..e7e26f52a4 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt @@ -20,7 +20,7 @@ import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.crypto.verification.VerificationService import im.vector.matrix.android.api.session.crypto.verification.VerificationTransaction import im.vector.matrix.android.api.session.crypto.verification.VerificationTxState -import im.vector.matrix.android.internal.crypto.verification.PendingVerificationRequest +import im.vector.matrix.android.api.session.crypto.verification.PendingVerificationRequest import im.vector.riotx.R import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.features.home.room.detail.RoomDetailActivity diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt index d161f6d6fc..5bf358dfa8 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt @@ -44,7 +44,7 @@ import im.vector.matrix.android.api.util.MatrixItem import im.vector.matrix.android.api.util.toMatrixItem import im.vector.matrix.android.internal.crypto.crosssigning.fromBase64 import im.vector.matrix.android.internal.crypto.crosssigning.isVerified -import im.vector.matrix.android.internal.crypto.verification.PendingVerificationRequest +import im.vector.matrix.android.api.session.crypto.verification.PendingVerificationRequest import im.vector.riotx.core.extensions.exhaustive import im.vector.riotx.core.platform.VectorViewModel import timber.log.Timber diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt index 7845c69b78..c7fdf77123 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt @@ -26,7 +26,7 @@ import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.crypto.verification.QrCodeVerificationTransaction import im.vector.matrix.android.api.session.crypto.verification.VerificationService import im.vector.matrix.android.api.session.crypto.verification.VerificationTransaction -import im.vector.matrix.android.internal.crypto.verification.PendingVerificationRequest +import im.vector.matrix.android.api.session.crypto.verification.PendingVerificationRequest import im.vector.riotx.core.di.HasScreenInjector import im.vector.riotx.core.platform.EmptyAction import im.vector.riotx.core.platform.EmptyViewEvents