From 58d3b42a60addcd5f656a2d020d9731e166a5d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 14 Jun 2021 17:51:13 +0200 Subject: [PATCH] crypto: Don't allow QR code generation if we or the other can't handle it --- matrix_sdk_crypto/src/verification/requests.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/matrix_sdk_crypto/src/verification/requests.rs b/matrix_sdk_crypto/src/verification/requests.rs index 71ec2463..6ba52aa3 100644 --- a/matrix_sdk_crypto/src/verification/requests.rs +++ b/matrix_sdk_crypto/src/verification/requests.rs @@ -726,6 +726,15 @@ impl RequestState { async fn generate_qr_code(&self) -> Result, CryptoStoreError> { // TODO return an error explaining why we can't generate a QR code? + + // If we didn't state that we support showing QR codes or if the other + // side doesn't support scanning QR codes bail early. + if !self.state.our_methods.contains(&VerificationMethod::MQrCodeShowV1) + || !self.state.their_methods.contains(&VerificationMethod::MQrScanShowV1) + { + return Ok(None); + } + let device = if let Some(device) = self.store.get_device(&self.other_user_id, &self.state.other_device_id).await? {