mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Refactoring
This commit is contained in:
parent
53b70da90e
commit
9a779ff8aa
17 changed files with 53 additions and 48 deletions
|
@ -34,6 +34,7 @@ import org.jivesoftware.smackx.omemo.exceptions.CannotEstablishOmemoSessionExcep
|
|||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
import org.jivesoftware.smackx.omemo.internal.CachedDeviceList;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.util.OmemoConstants;
|
||||
import org.jivesoftware.smackx.pubsub.PubSubException;
|
||||
import org.jivesoftware.smackx.pubsub.PubSubManager;
|
||||
|
|
|
@ -24,10 +24,10 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.element.OmemoBundleVAxolotlElement;
|
||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.util.OmemoKeyUtil;
|
||||
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoManager;
|
||||
import org.jivesoftware.smackx.omemo.OmemoSessionManager;
|
||||
import org.jivesoftware.smackx.omemo.OmemoRatchet;
|
||||
import org.jivesoftware.smackx.omemo.OmemoStore;
|
||||
import org.jivesoftware.smackx.omemo.element.OmemoElement;
|
||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
|
@ -55,15 +55,15 @@ import org.whispersystems.libsignal.state.PreKeyRecord;
|
|||
import org.whispersystems.libsignal.state.SessionRecord;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||
|
||||
public class SignalOmemoSessionManager
|
||||
extends OmemoSessionManager<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher>
|
||||
public class SignalOmemoRatchet
|
||||
extends OmemoRatchet<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher>
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(OmemoSessionManager.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(OmemoRatchet.class.getName());
|
||||
private final SignalOmemoStoreConnector storeConnector;
|
||||
|
||||
public SignalOmemoSessionManager(OmemoManager.KnownBareJidGuard managerGuard,
|
||||
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
|
||||
SignalOmemoRatchet(OmemoManager.KnownBareJidGuard managerGuard,
|
||||
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord,
|
||||
SessionRecord, SignalProtocolAddress, ECPublicKey, PreKeyBundle,
|
||||
SessionCipher> store)
|
||||
{
|
|
@ -65,12 +65,12 @@ public final class SignalOmemoService
|
|||
private static boolean LICENSE_ACKNOWLEDGED = false;
|
||||
|
||||
@Override
|
||||
protected SignalOmemoSessionManager createOmemoSessionManager(
|
||||
protected SignalOmemoRatchet instantiateOmemoRatchet(
|
||||
OmemoManager.KnownBareJidGuard manager,
|
||||
OmemoStore<IdentityKeyPair, IdentityKey, PreKeyRecord, SignedPreKeyRecord, SessionRecord,
|
||||
SignalProtocolAddress, ECPublicKey, PreKeyBundle, SessionCipher> store)
|
||||
{
|
||||
return new SignalOmemoSessionManager(manager, getOmemoStoreBackend());
|
||||
return new SignalOmemoRatchet(manager, getOmemoStoreBackend());
|
||||
}
|
||||
|
||||
public static void setup()
|
||||
|
|
|
@ -70,6 +70,7 @@ import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
|||
import org.jivesoftware.smackx.omemo.internal.OmemoMessageInformation;
|
||||
import org.jivesoftware.smackx.omemo.listener.OmemoMessageListener;
|
||||
import org.jivesoftware.smackx.omemo.listener.OmemoMucMessageListener;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.trust.TrustCallback;
|
||||
import org.jivesoftware.smackx.omemo.trust.TrustState;
|
||||
import org.jivesoftware.smackx.pep.PEPListener;
|
||||
|
@ -1010,7 +1011,7 @@ public final class OmemoManager extends Manager {
|
|||
// Device List <list>
|
||||
OmemoDeviceListVAxolotlElement omemoDeviceListElement =
|
||||
(OmemoDeviceListVAxolotlElement) payloadItem.getPayload();
|
||||
int ourDeviceId = getDeviceId();
|
||||
Integer ourDeviceId = getDeviceId();
|
||||
|
||||
getOmemoService().getOmemoStoreBackend()
|
||||
.mergeCachedDeviceList(managerGuard.get().getOwnDevice(), from, omemoDeviceListElement);
|
||||
|
|
|
@ -36,14 +36,14 @@ import org.jivesoftware.smackx.omemo.internal.CipherAndAuthTag;
|
|||
import org.jivesoftware.smackx.omemo.internal.CiphertextTuple;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
|
||||
public abstract class OmemoSessionManager<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> {
|
||||
private static final Logger LOGGER = Logger.getLogger(OmemoSessionManager.class.getName());
|
||||
public abstract class OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> {
|
||||
private static final Logger LOGGER = Logger.getLogger(OmemoRatchet.class.getName());
|
||||
|
||||
protected final OmemoManager.KnownBareJidGuard managerGuard;
|
||||
protected final OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> store;
|
||||
|
||||
public OmemoSessionManager(OmemoManager.KnownBareJidGuard managerGuard,
|
||||
OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> store) {
|
||||
public OmemoRatchet(OmemoManager.KnownBareJidGuard managerGuard,
|
||||
OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> store) {
|
||||
this.managerGuard = managerGuard;
|
||||
this.store = store;
|
||||
}
|
|
@ -114,7 +114,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
private static OmemoService<?, ?, ?, ?, ?, ?, ?, ?, ?> INSTANCE;
|
||||
|
||||
protected OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> omemoStore;
|
||||
protected final HashMap<OmemoManager, OmemoSessionManager<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>> sessionManagers = new HashMap<>();
|
||||
protected final HashMap<OmemoManager, OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>> sessionManagers = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Return the singleton instance of this class. When no instance is set, throw an IllegalStateException instead.
|
||||
|
@ -223,7 +223,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
SmackException.NotConnectedException, SmackException.NoResponseException,
|
||||
PubSubException.NotALeafNodeException
|
||||
{
|
||||
sessionManagers.put(managerGuard.get(), createOmemoSessionManager(managerGuard, getOmemoStoreBackend()));
|
||||
sessionManagers.put(managerGuard.get(), instantiateOmemoRatchet(managerGuard, getOmemoStoreBackend()));
|
||||
// Create new keys if necessary and publish to the server.
|
||||
publishBundle(managerGuard);
|
||||
|
||||
|
@ -981,7 +981,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
NoRawSessionException
|
||||
{
|
||||
CipherAndAuthTag transportedKey = decryptTransportedOmemoKey(managerGuard, from, message, information);
|
||||
return OmemoSessionManager.decryptMessageElement(message, transportedKey);
|
||||
return OmemoRatchet.decryptMessageElement(message, transportedKey);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1045,7 +1045,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
builder;
|
||||
try {
|
||||
builder = new OmemoMessageBuilder<>(managerGuard, getOmemoSessionManager(managerGuard), message.getBody());
|
||||
builder = new OmemoMessageBuilder<>(managerGuard, getOmemoRatchet(managerGuard), message.getBody());
|
||||
} catch (UnsupportedEncodingException | BadPaddingException | IllegalBlockSizeException | NoSuchProviderException |
|
||||
NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException e) {
|
||||
throw new CryptoFailedException(e);
|
||||
|
@ -1098,7 +1098,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
builder;
|
||||
try {
|
||||
builder = new OmemoMessageBuilder<>(managerGuard, getOmemoSessionManager(managerGuard), null);
|
||||
builder = new OmemoMessageBuilder<>(managerGuard, getOmemoRatchet(managerGuard), null);
|
||||
|
||||
} catch (UnsupportedEncodingException | BadPaddingException | IllegalBlockSizeException | NoSuchProviderException |
|
||||
NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException e) {
|
||||
|
@ -1135,7 +1135,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
builder;
|
||||
try {
|
||||
builder = new OmemoMessageBuilder<>(managerGuard, getOmemoSessionManager(managerGuard), aesKey, iv);
|
||||
builder = new OmemoMessageBuilder<>(managerGuard, getOmemoRatchet(managerGuard), aesKey, iv);
|
||||
|
||||
} catch (UnsupportedEncodingException | BadPaddingException | IllegalBlockSizeException | NoSuchProviderException |
|
||||
NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException e) {
|
||||
|
@ -1444,16 +1444,16 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract OmemoSessionManager<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
createOmemoSessionManager(OmemoManager.KnownBareJidGuard manager,
|
||||
OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> store);
|
||||
protected abstract OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
instantiateOmemoRatchet(OmemoManager.KnownBareJidGuard manager,
|
||||
OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> store);
|
||||
|
||||
protected OmemoSessionManager<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
getOmemoSessionManager(OmemoManager.KnownBareJidGuard guard) {
|
||||
OmemoSessionManager<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
protected OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
getOmemoRatchet(OmemoManager.KnownBareJidGuard guard) {
|
||||
OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph>
|
||||
sessionManager = sessionManagers.get(guard.get());
|
||||
if (sessionManager == null) {
|
||||
sessionManager = createOmemoSessionManager(guard, omemoStore);
|
||||
sessionManager = instantiateOmemoRatchet(guard, omemoStore);
|
||||
sessionManagers.put(guard.get(), sessionManager);
|
||||
}
|
||||
return sessionManager;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.jivesoftware.smackx.omemo.exceptions.CannotEstablishOmemoSessionExcep
|
|||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
import org.jivesoftware.smackx.omemo.internal.CachedDeviceList;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.util.OmemoKeyUtil;
|
||||
|
||||
import org.jxmpp.jid.BareJid;
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.omemo.exceptions;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
|
||||
/**
|
||||
* Exception that gets thrown when we try to decrypt a message which contains an identityKey that differs from the one
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.omemo.internal;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
|
||||
/**
|
||||
* Class that contains information about a decrypted message (eg. which key was used, if it was a carbon...).
|
||||
|
@ -32,7 +32,7 @@ public class OmemoMessageInformation {
|
|||
/**
|
||||
* Empty constructor.
|
||||
*/
|
||||
// TOOD Move this class into smackx.omemo and make this constructor package protected. -Flow
|
||||
// TODO Move this class into smackx.omemo and make this constructor package protected. -Flow
|
||||
public OmemoMessageInformation() {
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.omemo;
|
||||
package org.jivesoftware.smackx.omemo.trust;
|
||||
|
||||
public class OmemoFingerprint implements CharSequence {
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.omemo.trust;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
|
||||
public interface TrustCallback {
|
||||
|
|
|
@ -23,10 +23,10 @@ import java.util.TreeMap;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.element.OmemoBundleVAxolotlElement;
|
||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
|
|
|
@ -39,9 +39,8 @@ import javax.crypto.spec.SecretKeySpec;
|
|||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.omemo.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.OmemoManager;
|
||||
import org.jivesoftware.smackx.omemo.OmemoSessionManager;
|
||||
import org.jivesoftware.smackx.omemo.OmemoRatchet;
|
||||
import org.jivesoftware.smackx.omemo.element.OmemoVAxolotlElement;
|
||||
import org.jivesoftware.smackx.omemo.exceptions.CannotEstablishOmemoSessionException;
|
||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
|
@ -49,6 +48,8 @@ import org.jivesoftware.smackx.omemo.exceptions.CryptoFailedException;
|
|||
import org.jivesoftware.smackx.omemo.exceptions.UndecidedOmemoIdentityException;
|
||||
import org.jivesoftware.smackx.omemo.internal.CiphertextTuple;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
|
||||
|
||||
/**
|
||||
* Class used to build OMEMO messages.
|
||||
|
@ -65,7 +66,7 @@ import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
|||
* @author Paul Schaub
|
||||
*/
|
||||
public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> {
|
||||
private final OmemoSessionManager<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> sessionManager;
|
||||
private final OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet;
|
||||
private final OmemoManager.KnownBareJidGuard managerGuard;
|
||||
|
||||
private byte[] messageKey = generateKey();
|
||||
|
@ -78,7 +79,7 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
|
|||
* Create a OmemoMessageBuilder.
|
||||
*
|
||||
* @param managerGuard OmemoManager of our device.
|
||||
* @param sessionManager OmemoSessionManager.
|
||||
* @param ratchet OmemoRatchet.
|
||||
* @param aesKey AES key that will be transported to the recipient. This is used eg. to encrypt the body.
|
||||
* @param iv IV
|
||||
* @throws NoSuchPaddingException
|
||||
|
@ -91,12 +92,13 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
|
|||
* @throws InvalidAlgorithmParameterException
|
||||
*/
|
||||
public OmemoMessageBuilder(OmemoManager.KnownBareJidGuard managerGuard,
|
||||
OmemoSessionManager<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> sessionManager,
|
||||
OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet,
|
||||
byte[] aesKey, byte[] iv)
|
||||
throws NoSuchPaddingException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException,
|
||||
throws NoSuchPaddingException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException,
|
||||
IllegalBlockSizeException,
|
||||
UnsupportedEncodingException, NoSuchProviderException, InvalidAlgorithmParameterException {
|
||||
this.managerGuard = managerGuard;
|
||||
this.sessionManager = sessionManager;
|
||||
this.ratchet = ratchet;
|
||||
this.messageKey = aesKey;
|
||||
this.initializationVector = iv;
|
||||
}
|
||||
|
@ -105,7 +107,7 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
|
|||
* Create a new OmemoMessageBuilder with random IV and AES key.
|
||||
*
|
||||
* @param managerGuard omemoManager of our device.
|
||||
* @param sessionManager omemoSessionManager.
|
||||
* @param ratchet omemoSessionManager.
|
||||
* @param message Messages body.
|
||||
* @throws NoSuchPaddingException
|
||||
* @throws BadPaddingException
|
||||
|
@ -117,12 +119,12 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
|
|||
* @throws InvalidAlgorithmParameterException
|
||||
*/
|
||||
public OmemoMessageBuilder(OmemoManager.KnownBareJidGuard managerGuard,
|
||||
OmemoSessionManager<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> sessionManager,
|
||||
OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet,
|
||||
String message)
|
||||
throws NoSuchPaddingException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException,
|
||||
UnsupportedEncodingException, NoSuchProviderException, InvalidAlgorithmParameterException {
|
||||
this.managerGuard = managerGuard;
|
||||
this.sessionManager = sessionManager;
|
||||
this.ratchet = ratchet;
|
||||
this.setMessage(message);
|
||||
}
|
||||
|
||||
|
@ -208,7 +210,7 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
|
|||
|
||||
if (ignoreTrust || managerGuard.get().isTrustedOmemoIdentity(contactsDevice, fingerprint)) {
|
||||
// Encrypt key and save to header
|
||||
CiphertextTuple encryptedKey = sessionManager.doubleRatchetEncrypt(contactsDevice, messageKey);
|
||||
CiphertextTuple encryptedKey = ratchet.doubleRatchetEncrypt(contactsDevice, messageKey);
|
||||
keys.add(new OmemoVAxolotlElement.OmemoHeader.Key(encryptedKey.getCiphertext(), contactsDevice.getDeviceId(), encryptedKey.isPreKeyMessage()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smack.omemo;
|
|||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertNotSame;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@ import java.util.HashSet;
|
|||
import java.util.TreeMap;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.FileBasedOmemoStore;
|
||||
import org.jivesoftware.smackx.omemo.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.OmemoStore;
|
||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
import org.jivesoftware.smackx.omemo.internal.CachedDeviceList;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
@ -44,6 +44,7 @@ import org.junit.rules.TemporaryFolder;
|
|||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
|
||||
public abstract class OmemoStoreTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> {
|
||||
|
||||
protected final OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> store;
|
||||
|
|
|
@ -18,8 +18,8 @@ package org.jivesoftware.smack.omemo.util;
|
|||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.jivesoftware.smackx.omemo.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
|
||||
import org.jivesoftware.smackx.omemo.trust.OmemoFingerprint;
|
||||
import org.jivesoftware.smackx.omemo.trust.TrustCallback;
|
||||
import org.jivesoftware.smackx.omemo.trust.TrustState;
|
||||
|
||||
|
|
Loading…
Reference in a new issue