1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 21:42:07 +01:00

Improve Javadoc readability by adding separating lines

This commit is contained in:
Paul Schaub 2019-12-13 18:30:43 +01:00
parent 85ff749d89
commit 6d0bf04c1e
12 changed files with 103 additions and 0 deletions

View file

@ -44,6 +44,7 @@ public class SignalCachingOmemoStore extends CachingOmemoStore<IdentityKeyPair,
/**
* Create a new SignalCachingOmemoStore as a caching layer around a persisting OmemoStore
* (eg. a SignalFileBasedOmemoStore).
*
* @param wrappedStore other store implementation that gets wrapped
*/
public SignalCachingOmemoStore(OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,

View file

@ -277,9 +277,12 @@ public final class OmemoManager extends Manager {
/**
* Return a set of all OMEMO capable devices of a contact.
* Note, that this method does not explicitly refresh the device list of the contact, so it might be outdated.
*
* @see #requestDeviceListUpdateFor(BareJid)
*
* @param contact contact we want to get a set of device of.
* @return set of known devices of that contact.
*
* @throws IOException if an I/O error occurred.
*/
public Set<OmemoDevice> getDevicesOf(BareJid contact) throws IOException {
@ -300,6 +303,7 @@ public final class OmemoManager extends Manager {
* @param recipient recipients bareJid
* @param message text to encrypt
* @return encrypted message
*
* @throws CryptoFailedException when something crypto related fails
* @throws UndecidedOmemoIdentityException When there are undecided devices
* @throws InterruptedException if the calling thread was interrupted.
@ -323,6 +327,7 @@ public final class OmemoManager extends Manager {
* @param recipients recipients barejids
* @param message text to encrypt
* @return encrypted message.
*
* @throws CryptoFailedException When something crypto related fails
* @throws UndecidedOmemoIdentityException When there are undecided devices.
* @throws InterruptedException if the calling thread was interrupted.
@ -349,6 +354,7 @@ public final class OmemoManager extends Manager {
* @param muc multiUserChat
* @param message message to send
* @return encrypted message
*
* @throws UndecidedOmemoIdentityException when there are undecided devices.
* @throws CryptoFailedException if the OMEMO cryptography failed.
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
@ -403,6 +409,7 @@ public final class OmemoManager extends Manager {
*
* @param mamQuery The MAM query
* @return list of decrypted OmemoMessages
*
* @throws SmackException.NotLoggedInException if the Manager is not authenticated.
* @throws IOException if an I/O error occurred.
*/
@ -431,6 +438,7 @@ public final class OmemoManager extends Manager {
* Distrust the fingerprint/OmemoDevice tuple.
* The fingerprint must be the lowercase, hexadecimal fingerprint of the identityKey of the device and must
* be of length 64.
*
* @param device device
* @param fingerprint fingerprint
*/
@ -446,6 +454,7 @@ public final class OmemoManager extends Manager {
* Returns true, if the fingerprint/OmemoDevice tuple is trusted, otherwise false.
* The fingerprint must be the lowercase, hexadecimal fingerprint of the identityKey of the device and must
* be of length 64.
*
* @param device device
* @param fingerprint fingerprint
* @return <code>true</code> if this is a trusted OMEMO identity.
@ -462,6 +471,7 @@ public final class OmemoManager extends Manager {
* Returns true, if the fingerprint/OmemoDevice tuple is decided by the user.
* The fingerprint must be the lowercase, hexadecimal fingerprint of the identityKey of the device and must
* be of length 64.
*
* @param device device
* @param fingerprint fingerprint
* @return <code>true</code> if the trust is decided for the identity.
@ -479,6 +489,7 @@ public final class OmemoManager extends Manager {
* secrecy.
*
* @param recipient recipient
*
* @throws CorruptedOmemoKeyException When the used identityKeys are corrupted
* @throws CryptoFailedException When something fails with the crypto
* @throws CannotEstablishOmemoSessionException When we can't establish a session with the recipient
@ -511,6 +522,7 @@ public final class OmemoManager extends Manager {
*
* @param contact contact
* @return true if contact has at least one OMEMO capable device.
*
* @throws SmackException.NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
* @throws SmackException.NoResponseException if there was no response from the remote entity.
@ -551,6 +563,7 @@ public final class OmemoManager extends Manager {
* @param connection XMPPConnection
* @param server domainBareJid of the server to test
* @return true if server supports pep
*
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
* @throws SmackException.NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
@ -614,6 +627,7 @@ public final class OmemoManager extends Manager {
/**
* Return all OmemoFingerprints of active devices of a contact.
* TODO: Make more fail-safe
*
* @param contact contact
* @return Map of all active devices of the contact and their fingerprints.
*
@ -661,6 +675,7 @@ public final class OmemoManager extends Manager {
/**
* Remove an OmemoMessageListener.
*
* @param listener OmemoMessageListener
*/
public void removeOmemoMessageListener(OmemoMessageListener listener) {
@ -678,6 +693,7 @@ public final class OmemoManager extends Manager {
/**
* Remove an OmemoMucMessageListener.
*
* @param listener OmemoMucMessageListener
*/
public void removeOmemoMucMessageListener(OmemoMucMessageListener listener) {
@ -688,6 +704,7 @@ public final class OmemoManager extends Manager {
* Request a deviceList update from contact contact.
*
* @param contact contact we want to obtain the deviceList from.
*
* @throws InterruptedException if the calling thread was interrupted.
* @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
@ -750,6 +767,7 @@ public final class OmemoManager extends Manager {
/**
* Return true, if the given Stanza contains an OMEMO element 'encrypted'.
*
* @param stanza stanza
* @return true if stanza has extension 'encrypted'
*/
@ -812,6 +830,7 @@ public final class OmemoManager extends Manager {
/**
* Set the deviceId of the manager to nDeviceId.
*
* @param nDeviceId new deviceId
*/
synchronized void setDeviceId(int nDeviceId) {

View file

@ -82,6 +82,7 @@ public class OmemoMessage {
/**
* Create a new outgoing OMEMO message.
*
* @param element OmemoElement
* @param key messageKey (or transported key)
* @param iv initialization vector belonging to key
@ -97,6 +98,7 @@ public class OmemoMessage {
/**
* Return a list of all devices the sender originally intended to encrypt the message for.
*
* @return list of intended recipients.
*/
public Set<OmemoDevice> getIntendedDevices() {
@ -105,6 +107,7 @@ public class OmemoMessage {
/**
* Return a map of all skipped recipients and the reasons for skipping.
*
* @return map of skipped recipients and reasons for that.
*/
public HashMap<OmemoDevice, Throwable> getSkippedDevices() {
@ -113,6 +116,7 @@ public class OmemoMessage {
/**
* Determine, if some recipients were skipped during encryption.
*
* @return true if recipients were skipped.
*/
public boolean isMissingRecipients() {
@ -156,6 +160,7 @@ public class OmemoMessage {
/**
* Create a new incoming OMEMO message.
*
* @param element original OmemoElement
* @param key message key (or transported key)
* @param iv respective initialization vector
@ -174,6 +179,7 @@ public class OmemoMessage {
/**
* Return the decrypted body of the message.
*
* @return decrypted body
*/
public String getBody() {
@ -182,6 +188,7 @@ public class OmemoMessage {
/**
* Return the fingerprint of the messages sender device.
*
* @return fingerprint of sender
*/
public OmemoFingerprint getSendersFingerprint() {
@ -199,6 +206,7 @@ public class OmemoMessage {
/**
* Return true, if this message was sent as a preKeyMessage.
*
* @return preKeyMessage or not
*/
boolean isPreKeyMessage() {
@ -208,6 +216,7 @@ public class OmemoMessage {
/**
* Return true, if the message was a KeyTransportMessage.
* A KeyTransportMessage is a OmemoMessage without a payload.
*
* @return keyTransportMessage?
*/
public boolean isKeyTransportMessage() {

View file

@ -86,6 +86,7 @@ public abstract class OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param element omemoElement
* @return tuple of cipher generated from the unpacked message key and the auth-tag
*
* @throws CryptoFailedException if decryption using the double ratchet fails
* @throws NoRawSessionException if we have no session, but the element was NOT a PreKeyMessage
* @throws IOException if an I/O error occurred.
@ -154,6 +155,7 @@ public abstract class OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param element omemoElement containing a payload.
* @param cipherAndAuthTag cipher and authentication tag.
* @return decrypted plain text.
*
* @throws CryptoFailedException if decryption using AES key fails.
*/
static String decryptMessageElement(OmemoElement element, CipherAndAuthTag cipherAndAuthTag)

View file

@ -98,6 +98,7 @@ import org.jxmpp.jid.Jid;
* @param <T_ECPub> Elliptic Curve PublicKey class
* @param <T_Bundle> Bundle class
* @param <T_Ciph> Cipher class
*
* @author Paul Schaub
*/
public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
@ -113,10 +114,12 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
private final HashMap<OmemoManager, OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>> omemoRatchets = new HashMap<>();
protected OmemoService() {
}
/**
* Return the singleton instance of this class. When no instance is set, throw an IllegalStateException instead.
*
* @return instance.
*/
public static OmemoService<?, ?, ?, ?, ?, ?, ?, ?, ?> getInstance() {
@ -226,6 +229,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Initialize OMEMO functionality for the given {@link OmemoManager}.
*
* @param managerGuard OmemoManager we'd like to initialize.
*
* @throws InterruptedException if the calling thread was interrupted.
* @throws CorruptedOmemoKeyException if the OMEMO key is corrupted.
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
@ -266,6 +270,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param managerGuard Logged in OmemoManager
* @param contactsDevice OmemoDevice of the contact
* @return ratchet update message
*
* @throws NoSuchAlgorithmException if AES algorithms are not supported on this system.
* @throws InterruptedException if the calling thread was interrupted.
* @throws SmackException.NoResponseException if there was no response from the remote entity.
@ -428,6 +433,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
/**
* Decrypt an OMEMO message.
*
* @param managerGuard authenticated OmemoManager.
* @param senderJid BareJid of the sender.
* @param omemoElement omemoElement.
@ -477,6 +483,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
/**
* Create an OMEMO KeyTransportElement.
*
* @see <a href="https://xmpp.org/extensions/xep-0384.html#usecases-keysend">XEP-0384: Sending a key</a>.
*
* @param managerGuard Initialized OmemoManager.
@ -572,9 +579,11 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
/**
* Publish the given OMEMO bundle to the server using PubSub.
*
* @param connection our connection.
* @param userDevice our device
* @param bundle the bundle we want to publish
*
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
* @throws SmackException.NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
@ -625,8 +634,10 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
/**
* Publish the given device list to the server.
*
* @param connection authenticated XMPP connection.
* @param deviceList users deviceList.
*
* @throws InterruptedException if the calling thread was interrupted.
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
* @throws SmackException.NotConnectedException if the XMPP connection is not connected.
@ -758,6 +769,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param connection authenticated XMPP connection
* @param userDevice our OmemoDevice
* @param contactsDevice OmemoDevice of a contact.
*
* @throws CannotEstablishOmemoSessionException if we cannot establish a session (because of missing bundle etc.)
* @throws SmackException.NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
@ -794,6 +806,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
/**
* Build sessions with all devices from the set, we don't have a session with yet.
* Return the set of all devices we have a session with afterwards.
*
* @param connection authenticated XMPP connection
* @param userDevice our OmemoDevice
* @param devices set of devices we may want to build a session with if necessary
@ -841,6 +854,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param callback OmemoTrustCallback to query the trust decisions from
* @param devices set of OmemoDevices
* @return set of OmemoDevices which contains all devices from the set devices, which are undecided
*
* @throws IOException if an I/O error occurred.
*/
private Set<OmemoDevice> getUndecidedDevices(OmemoDevice userDevice, OmemoTrustCallback callback, Set<OmemoDevice> devices) throws IOException {
@ -871,6 +885,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param userDevice our OmemoDevice.
* @param contactsDevice OmemoDevice of the contact.
* @return true if userDevice has session with contactsDevice.
*
* @throws IOException if an I/O error occurred.
*/
private boolean hasSession(OmemoDevice userDevice, OmemoDevice contactsDevice) throws IOException {
@ -883,6 +898,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param omemoManager our OmemoManager
* @param contactsBundle bundle of the contact
* @param contactsDevice OmemoDevice of the contact
*
* @throws CorruptedOmemoKeyException if the OMEMO key is corrupted.
*/
protected abstract void processBundle(OmemoManager omemoManager,
@ -895,6 +911,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param userDevice our OmemoDevice
* @return true if rotation is necessary
*
* @throws IOException if an I/O error occurred.
*/
private boolean shouldRotateSignedPreKey(OmemoDevice userDevice) throws IOException {
@ -924,6 +941,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param userDevice our OmemoDevice
* @return our altered deviceList with stale devices marked as inactive.
*
* @throws IOException if an I/O error occurred.
*/
private OmemoCachedDeviceList deleteStaleDevices(OmemoDevice userDevice) throws IOException {
@ -944,6 +962,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param contact subjects BareJid.
* @param contactsDeviceList subjects deviceList.
* @return copy of subjects deviceList with stale devices marked as inactive.
*
* @throws IOException if an I/O error occurred.
*/
private OmemoCachedDeviceList removeStaleDevicesFromDeviceList(OmemoDevice userDevice,
@ -1220,6 +1239,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param stanza stanza
* @param managerGuard authenticated OmemoManager
* @return decrypted OmemoMessage or null
*
* @throws IOException if an I/O error occurred.
*/
OmemoMessage.Received decryptStanza(Stanza stanza, OmemoManager.LoggedInOmemoManager managerGuard) throws IOException {
@ -1301,6 +1321,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param managerGuard authenticated OmemoManager.
* @param brokenDevice device which session broke.
*
* @throws IOException if an I/O error occurred.
*/
private void repairBrokenSessionWithPreKeyMessage(OmemoManager.LoggedInOmemoManager managerGuard,
@ -1356,6 +1377,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
/**
* Return the joined MUC with EntityBareJid jid, or null if its not a room and/or not joined.
*
* @param connection xmpp connection
* @param jid jid (presumably) of the MUC
* @return MultiUserChat or null if not a MUC.
@ -1379,6 +1401,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* Publish a new DeviceList with just our device in it.
*
* @param managerGuard authenticated OmemoManager.
*
* @throws InterruptedException if the calling thread was interrupted.
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
* @throws SmackException.NotConnectedException if the XMPP connection is not connected.

View file

@ -53,6 +53,7 @@ import org.jxmpp.jid.BareJid;
* @param <T_ECPub> Elliptic Curve PublicKey class
* @param <T_Bundle> Bundle class
* @param <T_Ciph> Cipher class
*
* @author Paul Schaub
*/
public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> {
@ -68,6 +69,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
/**
* Returns a sorted set of all the deviceIds, the localUser has had data stored under in the store.
* Basically this returns the deviceIds of all "accounts" of localUser, which are known to the store.
*
* @param localUser BareJid of the user.
* @return set of deviceIds with available data.
*/
@ -79,6 +81,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our current device.
* @param id deviceId to check for.
* @return true if list did not contain our id, else false
*
* @throws IOException if an I/O error occurred.
*/
boolean isAvailableDeviceId(OmemoDevice userDevice, int id) throws IOException {
@ -103,6 +106,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param contact Contact we received the list from.
* @param list List we received.
*
* @throws IOException if an I/O error occurred.
*/
OmemoCachedDeviceList mergeCachedDeviceList(OmemoDevice userDevice, BareJid contact, OmemoDeviceListElement list) throws IOException {
@ -133,6 +137,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* The old signed PreKey should be kept for around a month or so (look it up in the XEP).
*
* @param userDevice our OmemoDevice.
*
* @throws CorruptedOmemoKeyException when our identityKey is invalid.
* @throws IOException if an I/O error occurred.
* @throws IllegalStateException when our IdentityKeyPair is null.
@ -163,6 +168,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* Remove the oldest signedPreKey until there are only MAX_NUMBER_OF_STORED_SIGNED_PREKEYS left.
*
* @param userDevice our OmemoDevice.
*
* @throws IOException if an I/O error occurred.
*/
private void removeOldSignedPreKeys(OmemoDevice userDevice) throws IOException {
@ -266,12 +272,14 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param userDevice our OmemoDevice.
* @param identityKeyPair identityKeyPair
*
* @throws IOException if an I/O error occurred.
*/
public abstract void storeOmemoIdentityKeyPair(OmemoDevice userDevice, T_IdKeyPair identityKeyPair) throws IOException;
/**
* Remove the identityKeyPair of a user.
*
* @param userDevice our device.
*/
public abstract void removeOmemoIdentityKeyPair(OmemoDevice userDevice);
@ -295,6 +303,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param contactsDevice device.
* @param contactsKey identityKey belonging to the contactsDevice.
*
* @throws IOException if an I/O error occurred.
*/
public abstract void storeOmemoIdentityKey(OmemoDevice userDevice, OmemoDevice contactsDevice, T_IdKey contactsKey) throws IOException;
@ -314,6 +323,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our omemoDevice.
* @param contactsDevice device of which we want to set the message counter.
* @param counter counter value.
*
* @throws IOException if an I/O error occurred.
*/
public abstract void storeOmemoMessageCounter(OmemoDevice userDevice, OmemoDevice contactsDevice, int counter) throws IOException;
@ -326,6 +336,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our omemoDevice
* @param contactsDevice device of which we want to get the message counter.
* @return counter value.
*
* @throws IOException if an I/O error occurred.
*/
public abstract int loadOmemoMessageCounter(OmemoDevice userDevice, OmemoDevice contactsDevice) throws IOException;
@ -336,6 +347,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice omemoManager of our device.
* @param contactsDevice device in question
* @param date date of the last received message
*
* @throws IOException if an I/O error occurred.
*/
public abstract void setDateOfLastReceivedMessage(OmemoDevice userDevice, OmemoDevice contactsDevice, Date date) throws IOException;
@ -346,6 +358,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param contactsDevice device in question
* @return date if existent, null
*
* @throws IOException if an I/O error occurred.
*/
public abstract Date getDateOfLastReceivedMessage(OmemoDevice userDevice, OmemoDevice contactsDevice) throws IOException;
@ -357,6 +370,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice
* @param contactsDevice OmemoDevice in question
* @param date date of the last publication after not being published
*
* @throws IOException if an I/O error occurred.
*/
public abstract void setDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice, Date date) throws IOException;
@ -368,6 +382,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice
* @param contactsDevice OmemoDevice in question
* @return date of the last publication after not being published
*
* @throws IOException if an I/O error occurred.
*/
public abstract Date getDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice) throws IOException;
@ -377,6 +392,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param userDevice our OmemoDevice.
* @param date date
*
* @throws IOException if an I/O error occurred.
*/
public abstract void setDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice, Date date) throws IOException;
@ -386,6 +402,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param userDevice our OmemoDevice.
* @return date if existent, otherwise null
*
* @throws IOException if an I/O error occurred.
*/
public abstract Date getDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice) throws IOException;
@ -408,6 +425,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param preKeyId id of the key to be loaded
* @return loaded preKey
*
* @throws IOException if an I/O error occurred.
*/
public abstract T_PreKey loadOmemoPreKey(OmemoDevice userDevice, int preKeyId) throws IOException;
@ -418,6 +436,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param preKeyId id of the key
* @param preKey key
*
* @throws IOException if an I/O error occurred.
*/
public abstract void storeOmemoPreKey(OmemoDevice userDevice, int preKeyId, T_PreKey preKey) throws IOException;
@ -427,6 +446,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param userDevice our OmemoDevice.
* @param preKeyHashMap HashMap of preKeys
*
* @throws IOException if an I/O error occurred.
*/
public void storeOmemoPreKeys(OmemoDevice userDevice, TreeMap<Integer, T_PreKey> preKeyHashMap) throws IOException {
@ -449,6 +469,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param userDevice our OmemoDevice.
* @return Map containing our preKeys
*
* @throws IOException if an I/O error occurred.
*/
public abstract TreeMap<Integer, T_PreKey> loadOmemoPreKeys(OmemoDevice userDevice) throws IOException;
@ -473,6 +494,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @param userDevice our OmemoDevice.
* @return HashMap of our singedPreKeys
*
* @throws IOException if an I/O error occurred.
*/
public abstract TreeMap<Integer, T_SigPreKey> loadOmemoSignedPreKeys(OmemoDevice userDevice) throws IOException;
@ -497,6 +519,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param signedPreKeyId id of the signedPreKey
* @param signedPreKey the key itself
*
* @throws IOException if an I/O error occurred.
*/
public abstract void storeOmemoSignedPreKey(OmemoDevice userDevice, int signedPreKeyId, T_SigPreKey signedPreKey) throws IOException;
@ -515,6 +538,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param contactsDevice device whose session we want to load
* @return crypto related session
*
* @throws IOException if an I/O error occurred.
*/
public abstract T_Sess loadRawSession(OmemoDevice userDevice, OmemoDevice contactsDevice) throws IOException;
@ -525,6 +549,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param contact BareJid of the contact we want to get all sessions from
* @return TreeMap of deviceId and sessions of the contact
*
* @throws IOException if an I/O error occurred.
*/
public abstract HashMap<Integer, T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, BareJid contact) throws IOException;
@ -535,6 +560,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param contactsDevice OmemoDevice whose session we want to store
* @param session session
*
* @throws IOException if an I/O error occurred.
*/
public abstract void storeRawSession(OmemoDevice userDevice, OmemoDevice contactsDevice, T_Sess session) throws IOException;
@ -571,6 +597,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param contact contact we want to get the deviceList of
* @return CachedDeviceList of the contact
*
* @throws IOException if an I/O error occurred.
*/
public abstract OmemoCachedDeviceList loadCachedDeviceList(OmemoDevice userDevice, BareJid contact) throws IOException;
@ -594,6 +621,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param contact Contact
* @param contactsDeviceList list of the contacts devices' ids.
*
* @throws IOException if an I/O error occurred.
*/
public abstract void storeCachedDeviceList(OmemoDevice userDevice,
@ -640,6 +668,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param userDevice our OmemoDevice.
* @param contactsDevice OmemoDevice we want to have the fingerprint for.
* @return fingerprint of the userDevices IdentityKey.
*
* @throws CorruptedOmemoKeyException if the IdentityKey is corrupted.
* @throws NoIdentityKeyException if no IdentityKey for contactsDevice has been found locally.
* @throws IOException if an I/O error occurred.

View file

@ -42,6 +42,7 @@ public class StaleDeviceException extends Exception {
/**
* Return the date on which the last OMEMO message sent from the device was received.
*
* @return last messages date
*/
public Date getLastMessageDate() {
@ -50,6 +51,7 @@ public class StaleDeviceException extends Exception {
/**
* Return the date of the last time the deviceId was republished after being inactive/non-existent before.
*
* @return date of last deviceId (re)publication.
*/
public Date getLastDeviceIdPublicationDate() {
@ -58,6 +60,7 @@ public class StaleDeviceException extends Exception {
/**
* Return the stale OMEMO device.
*
* @return stale device
*/
public OmemoDevice getDevice() {

View file

@ -56,6 +56,7 @@ public class UntrustedOmemoIdentityException extends Exception {
/**
* Return the device which sent the message.
*
* @return omemoDevice.
*/
public OmemoDevice getDevice() {

View file

@ -23,12 +23,14 @@ import org.jivesoftware.smackx.omemo.OmemoMessage;
/**
* Listener interface that allows implementations to receive decrypted OMEMO MUC messages.
*
* @author Paul Schaub
*/
public interface OmemoMucMessageListener {
/**
* Gets called whenever an OMEMO message has been received in a MultiUserChat and successfully decrypted.
*
* @param muc MultiUserChat the message was sent in
* @param stanza Original Stanza
* @param decryptedOmemoMessage decrypted Omemo message

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.omemo.util;
/**
* Some constants related to OMEMO.
*
* @author Paul Schaub
*/
public final class OmemoConstants {

View file

@ -101,6 +101,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param bundle OmemoBundleElement
* @param keyId id of the preKey
* @return the preKey
*
* @throws CorruptedOmemoKeyException when the key cannot be parsed from bytes
*/
public T_ECPub preKeyPublic(OmemoBundleElement bundle, int keyId) throws CorruptedOmemoKeyException {
@ -115,6 +116,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param bundle OmemoBundleElement containing multiple PreKeys
* @param contact Contact that the bundle belongs to
* @return a HashMap with one T_Bundle per preKey and the preKeyId as key
*
* @throws CorruptedOmemoKeyException when one of the keys cannot be parsed
*/
public HashMap<Integer, T_Bundle> bundles(OmemoBundleElement bundle, OmemoDevice contact) throws CorruptedOmemoKeyException {
@ -138,6 +140,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param data byte array
* @return IdentityKeyPair (T_IdKeyPair)
*
* @throws CorruptedOmemoKeyException if the key is damaged of malformed
*/
public abstract T_IdKeyPair identityKeyPairFromBytes(byte[] data) throws CorruptedOmemoKeyException;
@ -147,6 +150,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param data byte array
* @return identityKey (T_IdKey)
*
* @throws CorruptedOmemoKeyException if the key is damaged or malformed
*/
public abstract T_IdKey identityKeyFromBytes(byte[] data) throws CorruptedOmemoKeyException;
@ -164,6 +168,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param data bytes
* @return elliptic curve public key (T_ECPub)
*
* @throws CorruptedOmemoKeyException if the key is damaged or malformed
*/
public abstract T_ECPub ellipticCurvePublicKeyFromBytes(byte[] data) throws CorruptedOmemoKeyException;
@ -193,6 +198,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param bytes byte array
* @return deserialized preKey
*
* @throws IOException when something goes wrong
*/
public abstract T_PreKey preKeyFromBytes(byte[] bytes) throws IOException;
@ -236,6 +242,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param data byte array
* @return deserialized signed preKey
*
* @throws IOException when something goes wrong
*/
public abstract T_SigPreKey signedPreKeyFromBytes(byte[] data) throws IOException;
@ -257,6 +264,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param contact Contact that the bundle belongs to
* @param keyId id of the preKey that will be selected from the OmemoBundleElement and that the PreKeyBundle will contain
* @return PreKeyBundle (T_PreKey)
*
* @throws CorruptedOmemoKeyException if some key is damaged or malformed
*/
public abstract T_Bundle bundleFromOmemoBundle(OmemoBundleElement bundle, OmemoDevice contact, int keyId) throws CorruptedOmemoKeyException;
@ -366,6 +374,7 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @param data bytes
* @return raw OMEMO Session
*
* @throws IOException when something goes wrong
*/
public abstract T_Sess rawSessionFromBytes(byte[] data) throws IOException;

View file

@ -140,9 +140,11 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* Encrypt the message with the aes key.
* Move the AuthTag from the end of the cipherText to the end of the messageKey afterwards.
* This prevents an attacker which compromised one recipient device to switch out the cipherText for other recipients.
*
* @see <a href="https://conversations.im/omemo/audit.pdf">OMEMO security audit</a>.
*
* @param message plaintext message
*
* @throws NoSuchPaddingException if the requested padding mechanism is not availble.
* @throws InvalidAlgorithmParameterException if the provided arguments are invalid.
* @throws InvalidKeyException if the key is invalid.
@ -210,6 +212,7 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* Add a new recipient device to the message.
*
* @param contactsDevice device of the recipient
*
* @throws NoIdentityKeyException if we have no identityKey of that device. Can be fixed by fetching and
* processing the devices bundle.
* @throws CorruptedOmemoKeyException if the identityKey of that device is corrupted.
@ -260,6 +263,7 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param keyType Key Type
* @param keyLength Key Length in bit
* @return new AES key
*
* @throws NoSuchAlgorithmException if no such algorithm is available.
*/
public static byte[] generateKey(String keyType, int keyLength) throws NoSuchAlgorithmException {