handle pre key messages in dtls verification

This commit is contained in:
Daniel Gultsch 2021-03-03 14:03:08 +01:00
parent c5f801c1fe
commit 5848013a1e
2 changed files with 8 additions and 2 deletions

View File

@ -102,6 +102,7 @@ public final class Config {
public static final boolean REMOVE_BROKEN_DEVICES = false; public static final boolean REMOVE_BROKEN_DEVICES = false;
public static final boolean OMEMO_PADDING = false; public static final boolean OMEMO_PADDING = false;
public static final boolean PUT_AUTH_TAG_INTO_KEY = true; public static final boolean PUT_AUTH_TAG_INTO_KEY = true;
public static final boolean AUTOMATICALLY_COMPLETE_SESSIONS = true;
public static final boolean USE_BOOKMARKS2 = false; public static final boolean USE_BOOKMARKS2 = false;

View File

@ -1264,6 +1264,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
new RtpContentMap.DescriptionTransport(descriptionTransport.description, decryptedTransport.payload) new RtpContentMap.DescriptionTransport(descriptionTransport.description, decryptedTransport.payload)
); );
} }
processPostponed();
return new OmemoVerifiedPayload<>( return new OmemoVerifiedPayload<>(
omemoVerification, omemoVerification,
new RtpContentMap(omemoVerifiedRtpContentMap.group, descriptionTransportBuilder.build()) new RtpContentMap(omemoVerifiedRtpContentMap.group, descriptionTransportBuilder.build())
@ -1283,6 +1284,10 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
final XmppAxolotlMessage xmppAxolotlMessage = XmppAxolotlMessage.fromElement(encrypted, from.asBareJid()); final XmppAxolotlMessage xmppAxolotlMessage = XmppAxolotlMessage.fromElement(encrypted, from.asBareJid());
final XmppAxolotlSession session = getReceivingSession(xmppAxolotlMessage); final XmppAxolotlSession session = getReceivingSession(xmppAxolotlMessage);
final XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintext = xmppAxolotlMessage.decrypt(session, getOwnDeviceId()); final XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintext = xmppAxolotlMessage.decrypt(session, getOwnDeviceId());
final Integer preKeyId = session.getPreKeyIdAndReset();
if (preKeyId != null) {
postponedSessions.add(session);
}
fingerprint.setContent(plaintext.getPlaintext()); fingerprint.setContent(plaintext.getPlaintext());
omemoVerification.setDeviceId(session.getRemoteAddress().getDeviceId()); omemoVerification.setDeviceId(session.getRemoteAddress().getDeviceId());
omemoVerification.setSessionFingerprint(plaintext.getFingerprint()); omemoVerification.setSessionFingerprint(plaintext.getFingerprint());
@ -1414,7 +1419,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
} else { } else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": nothing to flush. Not republishing key"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": nothing to flush. Not republishing key");
} }
if (trustedOrPreviouslyResponded(session)) { if (trustedOrPreviouslyResponded(session) && Config.AUTOMATICALLY_COMPLETE_SESSIONS) {
completeSession(session); completeSession(session);
} }
} }
@ -1429,7 +1434,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
final Iterator<XmppAxolotlSession> iterator = postponedSessions.iterator(); final Iterator<XmppAxolotlSession> iterator = postponedSessions.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
final XmppAxolotlSession session = iterator.next(); final XmppAxolotlSession session = iterator.next();
if (trustedOrPreviouslyResponded(session)) { if (trustedOrPreviouslyResponded(session) && Config.AUTOMATICALLY_COMPLETE_SESSIONS) {
completeSession(session); completeSession(session);
} }
iterator.remove(); iterator.remove();