aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java11
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java4
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java10
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java2
-rw-r--r--src/main/java/de/pixart/messenger/utils/CryptoHelper.java1
-rw-r--r--src/main/java/de/pixart/messenger/utils/UIHelper.java2
-rw-r--r--src/main/res/values/strings.xml1
8 files changed, 33 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
index ed432bb9b..f76711857 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
@@ -1372,16 +1372,23 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
return session;
}
- public XmppAxolotlMessage.XmppAxolotlPlaintextMessage processReceivingPayloadMessage(XmppAxolotlMessage message, boolean postponePreKeyMessageHandling) {
+ public XmppAxolotlMessage.XmppAxolotlPlaintextMessage processReceivingPayloadMessage(XmppAxolotlMessage message, boolean postponePreKeyMessageHandling) throws NotEncryptedForThisDeviceException {
XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage = null;
XmppAxolotlSession session = getReceivingSession(message);
+ int ownDeviceId = getOwnDeviceId();
try {
- plaintextMessage = message.decrypt(session, getOwnDeviceId());
+ plaintextMessage = message.decrypt(session, ownDeviceId);
Integer preKeyId = session.getPreKeyIdAndReset();
if (preKeyId != null) {
postPreKeyMessageHandling(session, preKeyId, postponePreKeyMessageHandling);
}
+ } catch (NotEncryptedForThisDeviceException e) {
+ if (account.getJid().asBareJid().equals(message.getFrom().asBareJid()) && message.getSenderDeviceId() == ownDeviceId) {
+ Log.w(Config.LOGTAG, getLogprefix(account) + "Reflected omemo message received");
+ } else {
+ throw e;
+ }
} catch (CryptoFailedException e) {
Log.w(Config.LOGTAG, getLogprefix(account) + "Failed to decrypt message from " + message.getFrom() + ": " + e.getMessage());
}
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java
index 7bf94e599..ee9023c54 100644
--- a/src/main/java/de/pixart/messenger/entities/Message.java
+++ b/src/main/java/de/pixart/messenger/entities/Message.java
@@ -44,6 +44,7 @@ public class Message extends AbstractEntity {
public static final int ENCRYPTION_DECRYPTED = 3;
public static final int ENCRYPTION_DECRYPTION_FAILED = 4;
public static final int ENCRYPTION_AXOLOTL = 5;
+ public static final int ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE = 6;
public static final int TYPE_TEXT = 0;
public static final int TYPE_IMAGE = 1;
@@ -904,6 +905,9 @@ public class Message extends AbstractEntity {
if (encryption == ENCRYPTION_DECRYPTED || encryption == ENCRYPTION_DECRYPTION_FAILED) {
return ENCRYPTION_PGP;
}
+ if (encryption == ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) {
+ return ENCRYPTION_AXOLOTL;
+ }
return encryption;
}
} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 76318e0f2..6c24345e6 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -22,6 +22,7 @@ import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.crypto.OtrService;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
+import de.pixart.messenger.crypto.axolotl.NotEncryptedForThisDeviceException;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Bookmark;
@@ -207,7 +208,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
return null;
}
if (xmppAxolotlMessage.hasPayload()) {
- final XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage = service.processReceivingPayloadMessage(xmppAxolotlMessage, postpone);
+ final XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage;
+ try {
+ plaintextMessage = service.processReceivingPayloadMessage(xmppAxolotlMessage, postpone);
+ } catch (NotEncryptedForThisDeviceException e) {
+ return new Message(conversation, "", Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE, status);
+ }
if (plaintextMessage != null) {
Message finishedMessage = new Message(conversation, plaintextMessage.getPlaintext(), Message.ENCRYPTION_AXOLOTL, status);
finishedMessage.setFingerprint(plaintextMessage.getFingerprint());
@@ -654,6 +660,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
notify = conversation.getAccount().getPgpDecryptionService().decrypt(message, notify);
+ } else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) {
+ notify = false;
}
if (query == null) {
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 8519c30cf..bc3a7c890 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -1325,6 +1325,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
relevantForCorrection = relevantForCorrection.next();
}
if (m.getType() != Message.TYPE_STATUS) {
+
+ if (m.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) {
+ return;
+ }
+
final boolean treatAsFile = m.getType() != Message.TYPE_TEXT
&& m.getType() != Message.TYPE_PRIVATE
&& !(t instanceof TransferablePlaceholder);
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index 0b464e096..2a8aabd8f 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -972,6 +972,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
displayDecryptionFailed(viewHolder, darkBackground);
+ } else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) {
+ displayInfoMessage(viewHolder, activity.getString(R.string.not_encrypted_for_this_device), darkBackground);
} else {
if (message.isGeoUri()) {
displayLocationMessage(viewHolder, message);
diff --git a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java
index f75201b78..8cb68b34d 100644
--- a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java
@@ -240,6 +240,7 @@ public final class CryptoHelper {
case Message.ENCRYPTION_OTR:
return R.string.encryption_choice_otr;
case Message.ENCRYPTION_AXOLOTL:
+ case Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE:
return R.string.encryption_choice_omemo;
case Message.ENCRYPTION_NONE:
return R.string.encryption_choice_unencrypted;
diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java
index 13a08aedd..217425cad 100644
--- a/src/main/java/de/pixart/messenger/utils/UIHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java
@@ -272,6 +272,8 @@ public class UIHelper {
return new Pair<>(context.getString(R.string.pgp_message), true);
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
return new Pair<>(context.getString(R.string.decryption_failed), true);
+ } else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) {
+ return new Pair<>(context.getString(R.string.not_encrypted_for_this_device), true);
} else if (message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) {
if (message.getStatus() == Message.STATUS_RECEIVED) {
return new Pair<>(context.getString(R.string.received_x_file,
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 9b5ebaee2..2bdcd1f56 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -781,4 +781,5 @@
<string name="medium">Medium</string>
<string name="large">Large</string>
<string name="create_shortcut">Create Shortcut</string>
+ <string name="not_encrypted_for_this_device">Message was not encrypted for this device.</string>
</resources>