From d52c46d58249feb4a80d1cb81054ae201b1ef623 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 3 Mar 2021 12:55:27 +0100 Subject: [PATCH] use omemo verification only if omemo is enabled in conversation --- .../xmpp/jingle/JingleRtpConnection.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index aff365247..523d8d5cd 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -669,7 +669,15 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web this.message.setServerMsgId(serverMsgId); } this.message.setTime(timestamp); - this.omemoVerification.setDeviceId(proceed.getDeviceId()); + final Integer remoteDeviceId = proceed.getDeviceId(); + if (isOmemoEnabled()) { + this.omemoVerification.setDeviceId(remoteDeviceId); + } else { + if (remoteDeviceId != null) { + Log.d(Config.LOGTAG, id.account.getJid().asBareJid()+": remote party signaled support for OMEMO verification but we have OMEMO disabled"); + } + this.omemoVerification.setDeviceId(null); + } this.sendSessionInitiate(media, State.SESSION_INITIALIZED_PRE_APPROVED); } else { Log.d(Config.LOGTAG, String.format("%s: ignoring proceed because already in %s", id.account.getJid().asBareJid(), this.state)); @@ -1126,16 +1134,24 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web final Element intent = messagePacket.addChild(action, Namespace.JINGLE_MESSAGE).setAttribute("id", id.sessionId); if ("proceed".equals(action)) { messagePacket.setId(JINGLE_MESSAGE_PROCEED_ID_PREFIX + id.sessionId); - - //TODO only do this if OMEMO is enable so we have an easy way to opt out - final int deviceId = id.account.getAxolotlService().getOwnDeviceId(); - final Element device = intent.addChild("device", Namespace.OMEMO_DTLS_SRTP_VERIFICATION); - device.setAttribute("id", deviceId); + if (isOmemoEnabled()) { + final int deviceId = id.account.getAxolotlService().getOwnDeviceId(); + final Element device = intent.addChild("device", Namespace.OMEMO_DTLS_SRTP_VERIFICATION); + device.setAttribute("id", deviceId); + } } messagePacket.addChild("store", "urn:xmpp:hints"); xmppConnectionService.sendMessagePacket(id.account, messagePacket); } + private boolean isOmemoEnabled() { + final Conversational conversational = message.getConversation(); + if (conversational instanceof Conversation) { + return ((Conversation) conversational).getNextEncryption() == Message.ENCRYPTION_AXOLOTL; + } + return false; + } + private void acceptCallFromSessionInitialized() { xmppConnectionService.getNotificationService().cancelIncomingCallNotification(); sendSessionAccept();