diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index 9005025e90b3c3530413837c9b82ca92a11603b1..58083b67afd1b5cda8485a6df82d89ae5ca25ce6 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -1437,7 +1437,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/eu/siacs/conversations/crypto/axolotl/XmppAxolotlMessage.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlMessage.java index b6273a88d238fbc7ac4331edb4edb80cb0e52dea..587944ff8207bb26d4111b6c1642db9897863bb5 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlMessage.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlMessage.java @@ -218,16 +218,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/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java index 0a7bef569d82a7af8f3184a60b54a0edefb66e37..73af41af69f719c301f756095b42a85896a43826 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java @@ -118,9 +118,9 @@ public class XmppAxolotlSession implements Comparable { } @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);