aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/crypto
diff options
context:
space:
mode:
authorAndreas Straub <andy@strb.org>2015-07-07 19:36:22 +0200
committerAndreas Straub <andy@strb.org>2015-07-19 22:17:55 +0200
commit7049904c326e6dabc02138fa436d209bf724e0bc (patch)
treeeabe92e13928450df08ce5b9f33eae8165e1a0fa /src/main/java/eu/siacs/conversations/crypto
parent968410ae33f7ed341868847f3fedbd03ebd54f2b (diff)
Add basic PEP managemend UI to EditAccountActivity
EditAccountActivity now show own fingerprint, and gives an option to regenerate local keying material (and wipe all sessions associated with the old keys in the process). It also now displays a list of other own devices, and gives an option to remove all but the current device.
Diffstat (limited to 'src/main/java/eu/siacs/conversations/crypto')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java33
1 files changed, 33 insertions, 0 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 2b0954c6..ec4eb7c5 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
@@ -176,6 +176,13 @@ public class AxolotlService {
return reg_id;
}
+ public void regenerate() {
+ mXmppConnectionService.databaseBackend.wipeAxolotlDb(account);
+ account.setKey(JSONKEY_CURRENT_PREKEY_ID, Integer.toString(0));
+ identityKeyPair = loadIdentityKeyPair();
+ currentPreKeyId = 0;
+ mXmppConnectionService.updateAccountUi();
+ }
/**
* Get the local client's identity key pair.
@@ -602,6 +609,10 @@ public class AxolotlService {
this.ownDeviceId = axolotlStore.getLocalRegistrationId();
}
+ public IdentityKey getOwnPublicKey() {
+ return axolotlStore.getIdentityKeyPair().getPublicKey();
+ }
+
public void trustSession(AxolotlAddress counterpart) {
XmppAxolotlSession session = sessions.get(counterpart);
if (session != null) {
@@ -635,10 +646,19 @@ public class AxolotlService {
return sessions.hasAny(contactAddress);
}
+ public void regenerateKeys() {
+ axolotlStore.regenerate();
+ publishBundlesIfNeeded();
+ }
+
public int getOwnDeviceId() {
return ownDeviceId;
}
+ public Set<Integer> getOwnDeviceIds() {
+ return this.deviceIds.get(account.getJid().toBareJid());
+ }
+
public void registerDevices(final Jid jid, @NonNull final Set<Integer> deviceIds) {
if(deviceIds.contains(getOwnDeviceId())) {
Log.d(Config.LOGTAG, "Skipping own Device ID:"+ jid + ":"+getOwnDeviceId());
@@ -651,6 +671,19 @@ public class AxolotlService {
publishOwnDeviceIdIfNeeded();
}
+ public void wipeOtherPepDevices() {
+ Set<Integer> deviceIds = new HashSet<>();
+ deviceIds.add(getOwnDeviceId());
+ IqPacket publish = mXmppConnectionService.getIqGenerator().publishDeviceIds(deviceIds);
+ Log.d(Config.LOGTAG, "Wiping all other devices from Pep:" + publish);
+ mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
+ @Override
+ public void onIqPacketReceived(Account account, IqPacket packet) {
+ // TODO: implement this!
+ }
+ });
+ }
+
public void publishOwnDeviceIdIfNeeded() {
IqPacket packet = mXmppConnectionService.getIqGenerator().retrieveDeviceIds(account.getJid().toBareJid());
mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {