aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2017-01-12 15:59:13 +0100
committerDaniel Gultsch <daniel@gultsch.de>2017-01-12 15:59:13 +0100
commitbfacc180c5acd368754ae9803426000f68a34c5b (patch)
treeea3f320c3e590fc6488443c9bffd3139277fee16 /src/main/java
parent2c1d3ef96807b56037451278d1be90337666617d (diff)
don't allow to purge keys. offer distrut instead
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java6
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/FingerprintStatus.java10
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/OmemoActivity.java20
4 files changed, 19 insertions, 19 deletions
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 65ac7b0a..99533afb 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
@@ -439,8 +439,10 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
mXmppConnectionService.sendIqPacket(account, publish, null);
}
- public void purgeKey(final String fingerprint) {
- axolotlStore.setFingerprintStatus(fingerprint.replaceAll("\\s", ""), FingerprintStatus.createCompromised());
+ public void distrustFingerprint(final String fingerprint) {
+ final String fp = fingerprint.replaceAll("\\s", "");
+ final FingerprintStatus fingerprintStatus = axolotlStore.getFingerprintStatus(fp);
+ axolotlStore.setFingerprintStatus(fp,fingerprintStatus.toUntrusted());
}
public void publishOwnDeviceIdIfNeeded() {
diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/FingerprintStatus.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/FingerprintStatus.java
index 31b2264b..56f4a5d2 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/FingerprintStatus.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/FingerprintStatus.java
@@ -126,17 +126,17 @@ public class FingerprintStatus implements Comparable<FingerprintStatus> {
return trust;
}
- public static FingerprintStatus createCompromised() {
+ public FingerprintStatus toVerified() {
FingerprintStatus status = new FingerprintStatus();
- status.active = false;
- status.trust = Trust.COMPROMISED;
+ status.active = active;
+ status.trust = Trust.VERIFIED;
return status;
}
- public FingerprintStatus toVerified() {
+ public FingerprintStatus toUntrusted() {
FingerprintStatus status = new FingerprintStatus();
status.active = active;
- status.trust = Trust.VERIFIED;
+ status.trust = Trust.UNTRUSTED;
return status;
}
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 773b6857..938c19a4 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java
@@ -118,6 +118,8 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> {
setTrust(status.toActive());
}
}
+ } else {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+" not encrypting omemo message from fingerprint "+getFingerprint()+" because it was marked as compromised");
}
return plaintext;
}
diff --git a/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java b/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java
index 8ce8c14d..7929e073 100644
--- a/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java
@@ -24,8 +24,6 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
import eu.siacs.conversations.entities.Account;
-import eu.siacs.conversations.ui.TrustKeysActivity;
-import eu.siacs.conversations.ui.XmppActivity;
import eu.siacs.conversations.ui.widget.Switch;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.XmppUri;
@@ -51,16 +49,17 @@ public abstract class OmemoActivity extends XmppActivity {
&& fingerprint instanceof String
&& fingerprintStatus instanceof FingerprintStatus) {
getMenuInflater().inflate(R.menu.omemo_key_context, menu);
- MenuItem purgeItem = menu.findItem(R.id.purge_omemo_key);
+ MenuItem distrust = menu.findItem(R.id.distrust_key);
MenuItem verifyScan = menu.findItem(R.id.verify_scan);
if (this instanceof TrustKeysActivity) {
- purgeItem.setVisible(false);
+ distrust.setVisible(false);
verifyScan.setVisible(false);
} else {
FingerprintStatus status = (FingerprintStatus) fingerprintStatus;
if (!status.isActive() || status.isVerified()) {
verifyScan.setVisible(false);
}
+ distrust.setVisible(status.isVerified());
}
this.mSelectedAccount = (Account) account;
this.mSelectedFingerprint = (String) fingerprint;
@@ -70,7 +69,7 @@ public abstract class OmemoActivity extends XmppActivity {
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.purge_omemo_key:
+ case R.id.distrust_key:
showPurgeKeyDialog(mSelectedAccount,mSelectedFingerprint);
break;
case R.id.copy_omemo_key:
@@ -242,17 +241,14 @@ public abstract class OmemoActivity extends XmppActivity {
public void showPurgeKeyDialog(final Account account, final String fingerprint) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.purge_key));
- builder.setIconAttribute(android.R.attr.alertDialogIcon);
- builder.setMessage(getString(R.string.purge_key_desc_part1)
- + "\n\n" + CryptoHelper.prettifyFingerprint(fingerprint.substring(2))
- + "\n\n" + getString(R.string.purge_key_desc_part2));
+ builder.setTitle(R.string.distrust_omemo_key);
+ builder.setMessage(R.string.distrust_omemo_key_text);
builder.setNegativeButton(getString(R.string.cancel), null);
- builder.setPositiveButton(getString(R.string.purge_key),
+ builder.setPositiveButton(R.string.confirm,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- account.getAxolotlService().purgeKey(fingerprint);
+ account.getAxolotlService().distrustFingerprint(fingerprint);
refreshUi();
}
});