diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-11-21 13:42:25 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-11-21 13:42:25 +0100 |
commit | de0b36fc7866324a48f94f3e22ac89e4f43b9ff5 (patch) | |
tree | 8fe2fec857c28df68fc002949a3c2b05411d6386 | |
parent | 92ad4cb73650b95f0888afabe60f179d282e4e06 (diff) |
verify contacts key only on initiating side of smp
4 files changed, 20 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/crypto/OtrEngine.java b/src/main/java/eu/siacs/conversations/crypto/OtrEngine.java index 8b2b704a..642d0ed0 100644 --- a/src/main/java/eu/siacs/conversations/crypto/OtrEngine.java +++ b/src/main/java/eu/siacs/conversations/crypto/OtrEngine.java @@ -20,6 +20,7 @@ import eu.siacs.conversations.Config; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.services.XmppConnectionService; +import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; @@ -249,14 +250,17 @@ public class OtrEngine implements OtrEngineHost { } @Override - public void verify(SessionID id, String arg1, boolean arg2) { + public void verify(SessionID id, String fingerprint, boolean approved) { + Log.d(Config.LOGTAG,"OtrEngine.verify("+id.toString()+","+fingerprint+","+String.valueOf(approved)+")"); try { final Jid jid = Jid.fromSessionID(id); Conversation conversation = this.mXmppConnectionService.find(this.account,jid); if (conversation!=null) { + if (approved) { + conversation.getContact().addOtrFingerprint(CryptoHelper.prettifyFingerprint(fingerprint)); + } conversation.smp().hint = null; - conversation.smp().status = Conversation.Smp.STATUS_VERIFIED; - conversation.verifyOtrFingerprint(); + conversation.smp().status = Conversation.Smp.STATUS_FINISHED; mXmppConnectionService.updateConversationUi(); mXmppConnectionService.syncRosterToDisk(conversation.getAccount()); } diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 4801fe12..81bdb4c7 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -529,7 +529,7 @@ public class Conversation extends AbstractEntity { public static final int STATUS_CONTACT_REQUESTED = 1; public static final int STATUS_WE_REQUESTED = 2; public static final int STATUS_FAILED = 3; - public static final int STATUS_VERIFIED = 4; + public static final int STATUS_FINISHED = 4; public String secret = null; public String hint = null; diff --git a/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java b/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java index 233a5e99..e5775ab0 100644 --- a/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java @@ -285,14 +285,21 @@ public class VerifyOTRActivity extends XmppActivity implements XmppConnectionSer this.mStatusMessage.setVisibility(View.VISIBLE); this.mStatusMessage.setText(R.string.secrets_do_not_match); this.mStatusMessage.setTextColor(getWarningTextColor()); - } else if (smp.status == Conversation.Smp.STATUS_VERIFIED) { + } else if (smp.status == Conversation.Smp.STATUS_FINISHED) { + this.mSharedSecretHint.setText(""); this.mSharedSecretHint.setVisibility(View.GONE); + this.mSharedSecretSecret.setText(""); this.mSharedSecretSecret.setVisibility(View.GONE); this.mStatusMessage.setVisibility(View.VISIBLE); - this.mStatusMessage.setText(R.string.verified); this.mStatusMessage.setTextColor(getPrimaryColor()); deactivateButton(mButtonSharedSecretNegative, R.string.cancel); - activateButton(mButtonSharedSecretPositive, R.string.finish, mFinishListener); + if (mConversation.isOtrFingerprintVerified()) { + activateButton(mButtonSharedSecretPositive, R.string.finish, mFinishListener); + this.mStatusMessage.setText(R.string.verified); + } else { + activateButton(mButtonSharedSecretPositive,R.string.reset,mRetrySharedSecretListener); + this.mStatusMessage.setText(R.string.secret_accepted); + } } else if (session != null && session.isSmpInProgress()) { deactivateButton(mButtonSharedSecretPositive, R.string.in_progress); activateButton(mButtonSharedSecretNegative, R.string.cancel, mCancelSharedSecretListener); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 1bb0ef75..7e235f68 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -356,4 +356,6 @@ <string name="no_conference_server_found">No conference server found</string> <string name="conference_creation_failed">Conference creation failed!</string> <string name="conference_created">Conference created!</string> + <string name="secret_accepted">Secret accepted!</string> + <string name="reset">Reset</string> </resources> |