aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/crypto/axolotl/AxolotlService.java
blob: 49cd60339124ed99e07b4ce9a4288719d4435913 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package de.thedevstack.conversationsplus.crypto.axolotl;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import org.whispersystems.libaxolotl.AxolotlAddress;
import org.whispersystems.libaxolotl.IdentityKey;
import org.whispersystems.libaxolotl.state.PreKeyRecord;
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;

import java.security.cert.X509Certificate;
import java.util.List;
import java.util.Set;

import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.entities.Contact;
import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.xmpp.OnAdvancedStreamFeaturesLoaded;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;

/**
 * Created by tzur on 02.03.2016.
 */
public interface AxolotlService extends OnAdvancedStreamFeaturesLoaded {

	String LOGPREFIX = "AxolotlService";

	String PEP_PREFIX = "eu.siacs.conversations.axolotl";
	String PEP_DEVICE_LIST = PEP_PREFIX + ".devicelist";
	String PEP_BUNDLES = PEP_PREFIX + ".bundles";
	String PEP_VERIFICATION = PEP_PREFIX + ".verification";

    int NUM_KEYS_TO_PUBLISH = 100;

	enum FetchStatus {
		PENDING,
		SUCCESS,
		SUCCESS_VERIFIED,
		TIMEOUT,
		ERROR
	}

	String getOwnFingerprint();

	Set<IdentityKey> getKeysWithTrust(XmppAxolotlSession.Trust trust);


	Set<String> getFingerprintsForOwnSessions();

	Set<String> getFingerprintsForContact(Contact contact);

	boolean isPepBroken();

	void regenerateKeys(boolean wipeOther);

	int getOwnDeviceId();

	Set<Integer> getOwnDeviceIds();

	void registerDevices(Jid jid, @NonNull Set<Integer> deviceIds);

	void wipeOtherPepDevices();

	void purgeKey(String fingerprint);

	void publishOwnDeviceIdIfNeeded();

	void publishOwnDeviceId(Set<Integer> deviceIds);

	void publishDeviceVerificationAndBundle(SignedPreKeyRecord signedPreKeyRecord,
											Set<PreKeyRecord> preKeyRecords,
											boolean announceAfter,
											boolean wipe);

	void publishBundlesIfNeeded(boolean announce, boolean wipe);

	XmppAxolotlSession.Trust getFingerprintTrust(String fingerprint);

	X509Certificate getFingerprintCertificate(String fingerprint);

	void setFingerprintTrust(String fingerprint, XmppAxolotlSession.Trust trust);

	Set<AxolotlAddress> findDevicesWithoutSession(Conversation conversation);

	boolean createSessionsIfNeeded(Conversation conversation);

	boolean trustedSessionVerified(Conversation conversation);

	@Nullable
	XmppAxolotlMessage encrypt(Message message);

	void preparePayloadMessage(Message message, boolean delay);

	XmppAxolotlMessage fetchAxolotlMessageFromCache(Message message);

	XmppAxolotlMessage.XmppAxolotlPlaintextMessage processReceivingPayloadMessage(XmppAxolotlMessage message);

	XmppAxolotlMessage.XmppAxolotlKeyTransportMessage processReceivingKeyTransportMessage(XmppAxolotlMessage message);

	boolean fetchMapHasErrors(List<Jid> jids);

	Set<IdentityKey> getKeysWithTrust(XmppAxolotlSession.Trust trust, Jid jid);

	Set<IdentityKey> getKeysWithTrust(XmppAxolotlSession.Trust trust, List<Jid> jids);

	long getNumTrustedKeys(Jid jid);

	boolean anyTargetHasNoTrustedKeys(List<Jid> jids);

	boolean isConversationAxolotlCapable(Conversation conversation);

	List<Jid> getCryptoTargets(Conversation conversation);

	boolean hasPendingKeyFetches(Account account, List<Jid> jids);

	void prepareKeyTransportMessage(Conversation conversation, OnMessageCreatedCallback onMessageCreatedCallback);
}