From 4634b963a259950799867e441e62b3e169f1a102 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 5 Mar 2020 17:55:13 +0100 Subject: [PATCH] Code cleanup --- .../qrcode/DefaultQrCodeVerificationTransaction.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt index fab8ad5d85..46458a2734 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt @@ -77,26 +77,24 @@ internal class DefaultQrCodeVerificationTransaction( } // check master key + val myMasterKey = crossSigningService.getUserCrossSigningKeys(userId)?.masterKey()?.unpaddedBase64PublicKey when (otherQrCodeData) { is QrCodeData.VerifyingAnotherUser -> { - if (otherQrCodeData.otherUserMasterCrossSigningPublicKey - != crossSigningService.getUserCrossSigningKeys(userId)?.masterKey()?.unpaddedBase64PublicKey) { + if (otherQrCodeData.otherUserMasterCrossSigningPublicKey != myMasterKey) { Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.otherUserMasterCrossSigningPublicKey}") cancel(CancelCode.MismatchedKeys) return } else Unit } is QrCodeData.SelfVerifyingMasterKeyTrusted -> { - if (otherQrCodeData.userMasterCrossSigningPublicKey - != crossSigningService.getUserCrossSigningKeys(userId)?.masterKey()?.unpaddedBase64PublicKey) { + if (otherQrCodeData.userMasterCrossSigningPublicKey != myMasterKey) { Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.userMasterCrossSigningPublicKey}") cancel(CancelCode.MismatchedKeys) return } else Unit } is QrCodeData.SelfVerifyingMasterKeyNotTrusted -> { - if (otherQrCodeData.userMasterCrossSigningPublicKey - != crossSigningService.getUserCrossSigningKeys(userId)?.masterKey()?.unpaddedBase64PublicKey) { + if (otherQrCodeData.userMasterCrossSigningPublicKey != myMasterKey) { Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.userMasterCrossSigningPublicKey}") cancel(CancelCode.MismatchedKeys) return @@ -156,7 +154,7 @@ internal class DefaultQrCodeVerificationTransaction( trust(canTrustOtherUserMasterKey, toVerifyDeviceIds.distinct()) } - fun start(remoteSecret: String) { + private fun start(remoteSecret: String) { if (state != VerificationTxState.None) { Timber.e("## Verification QR: start verification from invalid state") // should I cancel?? @@ -219,8 +217,8 @@ internal class DefaultQrCodeVerificationTransaction( } private fun trust(canTrustOtherUserMasterKey: Boolean, toVerifyDeviceIds: List) { - // If not me sign his MSK and upload the signature if (canTrustOtherUserMasterKey) { + // If not me sign his MSK and upload the signature if (otherUserId != userId) { // we should trust this master key // And check verification MSK -> SSK?