aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/crypto
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-05-16 21:43:07 +0200
committerChristian Schneppe <christian@pix-art.de>2018-05-16 21:43:07 +0200
commit0525b1f960f4d7b45940bfe4a88beac99e571363 (patch)
tree73091229ef14a124573b57d351b143bf6adae4f8 /src/main/java/de/pixart/messenger/crypto
parent5786441681e55b31a7e224a5c7ba37a686490909 (diff)
make session completion work with untrusted devices as well
Diffstat (limited to 'src/main/java/de/pixart/messenger/crypto')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java2
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java12
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java4
3 files changed, 11 insertions, 7 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 ebf4e8667..d29d0c034 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
@@ -1436,7 +1436,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
private void completeSession(XmppAxolotlSession session) {
final XmppAxolotlMessage axolotlMessage = new XmppAxolotlMessage(account.getJid().asBareJid(), getOwnDeviceId());
- axolotlMessage.addDevice(session);
+ axolotlMessage.addDevice(session, true);
try {
Jid jid = Jid.of(session.getRemoteAddress().getName());
MessagePacket packet = mXmppConnectionService.getMessageGenerator().generateKeyTransportMessage(jid, axolotlMessage);
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java
index 81bf6754c..0adbbe51f 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java
@@ -215,16 +215,20 @@ public class XmppAxolotlMessage {
return this.from;
}
- public int getSenderDeviceId() {
+ int getSenderDeviceId() {
return sourceDeviceId;
}
- public void addDevice(XmppAxolotlSession session) {
+ void addDevice(XmppAxolotlSession session) {
+ addDevice(session, false);
+ }
+
+ void addDevice(XmppAxolotlSession session, boolean ignoreSessionTrust) {
XmppAxolotlSession.AxolotlKey key;
if (authtagPlusInnerKey != null) {
- key = session.processSending(authtagPlusInnerKey);
+ key = session.processSending(authtagPlusInnerKey, ignoreSessionTrust);
} else {
- key = session.processSending(innerKey);
+ key = session.processSending(innerKey, ignoreSessionTrust);
}
if (key != null) {
keys.put(session.getRemoteAddress().getDeviceId(), key);
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java
index cb84ebc63..09045f032 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java
@@ -118,9 +118,9 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> {
}
@Nullable
- public AxolotlKey processSending(@NonNull byte[] outgoingMessage) {
+ public AxolotlKey processSending(@NonNull byte[] outgoingMessage, boolean ignoreSessionTrust) {
FingerprintStatus status = getTrust();
- if (status.isTrustedAndActive()) {
+ if (ignoreSessionTrust || status.isTrustedAndActive()) {
try {
CiphertextMessage ciphertextMessage = cipher.encrypt(outgoingMessage);
return new AxolotlKey(ciphertextMessage.serialize(), ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE);