save otr fingerprint in message
This commit is contained in:
parent
867d0ef191
commit
e074104004
|
@ -773,11 +773,11 @@ public class Message extends AbstractEntity {
|
||||||
public int height = 0;
|
public int height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAxolotlFingerprint(String fingerprint) {
|
public void setFingerprint(String fingerprint) {
|
||||||
this.axolotlFingerprint = fingerprint;
|
this.axolotlFingerprint = fingerprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAxolotlFingerprint() {
|
public String getFingerprint() {
|
||||||
return axolotlFingerprint;
|
return axolotlFingerprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@ import android.util.Pair;
|
||||||
import net.java.otr4j.session.Session;
|
import net.java.otr4j.session.Session;
|
||||||
import net.java.otr4j.session.SessionStatus;
|
import net.java.otr4j.session.SessionStatus;
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
|
import eu.siacs.conversations.crypto.OtrService;
|
||||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
|
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
@ -95,8 +95,11 @@ public class MessageParser extends AbstractParser implements
|
||||||
conversation.setSymmetricKey(CryptoHelper.hexToBytes(key));
|
conversation.setSymmetricKey(CryptoHelper.hexToBytes(key));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
final OtrService otrService = conversation.getAccount().getOtrService();
|
||||||
Message finishedMessage = new Message(conversation, body, Message.ENCRYPTION_OTR, Message.STATUS_RECEIVED);
|
Message finishedMessage = new Message(conversation, body, Message.ENCRYPTION_OTR, Message.STATUS_RECEIVED);
|
||||||
|
finishedMessage.setFingerprint(otrService.getFingerprint(otrSession.getRemotePublicKey()));
|
||||||
conversation.setLastReceivedOtrMessageId(null);
|
conversation.setLastReceivedOtrMessageId(null);
|
||||||
|
|
||||||
return finishedMessage;
|
return finishedMessage;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
conversation.resetOtrSession();
|
conversation.resetOtrSession();
|
||||||
|
@ -111,7 +114,7 @@ public class MessageParser extends AbstractParser implements
|
||||||
XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage = service.processReceivingPayloadMessage(xmppAxolotlMessage);
|
XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage = service.processReceivingPayloadMessage(xmppAxolotlMessage);
|
||||||
if(plaintextMessage != null) {
|
if(plaintextMessage != null) {
|
||||||
finishedMessage = new Message(conversation, plaintextMessage.getPlaintext(), Message.ENCRYPTION_AXOLOTL, status);
|
finishedMessage = new Message(conversation, plaintextMessage.getPlaintext(), Message.ENCRYPTION_AXOLOTL, status);
|
||||||
finishedMessage.setAxolotlFingerprint(plaintextMessage.getFingerprint());
|
finishedMessage.setFingerprint(plaintextMessage.getFingerprint());
|
||||||
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(finishedMessage.getConversation().getAccount())+" Received Message with session fingerprint: "+plaintextMessage.getFingerprint());
|
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(finishedMessage.getConversation().getAccount())+" Received Message with session fingerprint: "+plaintextMessage.getFingerprint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,8 +411,8 @@ public class MessageParser extends AbstractParser implements
|
||||||
message.getStatus() == Message.STATUS_RECEIVED,
|
message.getStatus() == Message.STATUS_RECEIVED,
|
||||||
message.isCarbon());
|
message.isCarbon());
|
||||||
if (replacedMessage != null) {
|
if (replacedMessage != null) {
|
||||||
final boolean fingerprintsMatch = replacedMessage.getAxolotlFingerprint() == null
|
final boolean fingerprintsMatch = replacedMessage.getFingerprint() == null
|
||||||
|| replacedMessage.getAxolotlFingerprint().equals(message.getAxolotlFingerprint());
|
|| replacedMessage.getFingerprint().equals(message.getFingerprint());
|
||||||
final boolean trueCountersMatch = replacedMessage.getTrueCounterpart() != null
|
final boolean trueCountersMatch = replacedMessage.getTrueCounterpart() != null
|
||||||
&& replacedMessage.getTrueCounterpart().equals(message.getTrueCounterpart());
|
&& replacedMessage.getTrueCounterpart().equals(message.getTrueCounterpart());
|
||||||
if (fingerprintsMatch && (trueCountersMatch || conversation.getMode() == Conversation.MODE_SINGLE)) {
|
if (fingerprintsMatch && (trueCountersMatch || conversation.getMode() == Conversation.MODE_SINGLE)) {
|
||||||
|
|
|
@ -931,7 +931,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Message.ENCRYPTION_AXOLOTL:
|
case Message.ENCRYPTION_AXOLOTL:
|
||||||
message.setAxolotlFingerprint(account.getAxolotlService().getOwnFingerprint());
|
message.setFingerprint(account.getAxolotlService().getOwnFingerprint());
|
||||||
if (message.needsUploading()) {
|
if (message.needsUploading()) {
|
||||||
if (account.httpUploadAvailable() || message.fixCounterpart()) {
|
if (account.httpUploadAvailable() || message.fixCounterpart()) {
|
||||||
this.sendFileMessage(message, delay);
|
this.sendFileMessage(message, delay);
|
||||||
|
@ -977,7 +977,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Message.ENCRYPTION_AXOLOTL:
|
case Message.ENCRYPTION_AXOLOTL:
|
||||||
message.setAxolotlFingerprint(account.getAxolotlService().getOwnFingerprint());
|
message.setFingerprint(account.getAxolotlService().getOwnFingerprint());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -468,13 +468,13 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
highlightInConference(user);
|
highlightInConference(user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
activity.switchToContactDetails(message.getContact(), message.getAxolotlFingerprint());
|
activity.switchToContactDetails(message.getContact(), message.getFingerprint());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Account account = message.getConversation().getAccount();
|
Account account = message.getConversation().getAccount();
|
||||||
Intent intent = new Intent(activity, EditAccountActivity.class);
|
Intent intent = new Intent(activity, EditAccountActivity.class);
|
||||||
intent.putExtra("jid", account.getJid().toBareJid().toString());
|
intent.putExtra("jid", account.getJid().toBareJid().toString());
|
||||||
intent.putExtra("fingerprint", message.getAxolotlFingerprint());
|
intent.putExtra("fingerprint", message.getFingerprint());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
|
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
|
||||||
XmppAxolotlSession.Trust trust = message.getConversation()
|
XmppAxolotlSession.Trust trust = message.getConversation()
|
||||||
.getAccount().getAxolotlService().getFingerprintTrust(
|
.getAccount().getAxolotlService().getFingerprintTrust(
|
||||||
message.getAxolotlFingerprint());
|
message.getFingerprint());
|
||||||
|
|
||||||
if(trust == null || (!trust.trusted() && !trust.trustedInactive())) {
|
if(trust == null || (!trust.trusted() && !trust.trustedInactive())) {
|
||||||
viewHolder.indicator.setColorFilter(activity.getWarningTextColor());
|
viewHolder.indicator.setColorFilter(activity.getWarningTextColor());
|
||||||
|
|
|
@ -378,7 +378,7 @@ public class JingleConnection implements Transferable {
|
||||||
message.setEncryption(Message.ENCRYPTION_AXOLOTL);
|
message.setEncryption(Message.ENCRYPTION_AXOLOTL);
|
||||||
this.file.setKey(transportMessage.getKey());
|
this.file.setKey(transportMessage.getKey());
|
||||||
this.file.setIv(transportMessage.getIv());
|
this.file.setIv(transportMessage.getIv());
|
||||||
message.setAxolotlFingerprint(transportMessage.getFingerprint());
|
message.setFingerprint(transportMessage.getFingerprint());
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG,"could not process KeyTransportMessage");
|
Log.d(Config.LOGTAG,"could not process KeyTransportMessage");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue