Search in sources :

Example 56 with SignalProtocolAddress

use of org.whispersystems.libsignal.SignalProtocolAddress in project Signal-Android by WhisperSystems.

the class TextSecureSessionStore method archiveSiblingSessions.

public void archiveSiblingSessions(@NonNull SignalProtocolAddress address) {
    synchronized (LOCK) {
        List<SessionDatabase.SessionRow> sessions = SignalDatabase.sessions().getAllFor(accountId, address.getName());
        for (SessionDatabase.SessionRow row : sessions) {
            if (row.getDeviceId() != address.getDeviceId()) {
                row.getRecord().archiveCurrentState();
                storeSession(new SignalProtocolAddress(row.getAddress(), row.getDeviceId()), row.getRecord());
            }
        }
    }
}
Also used : SessionDatabase(org.thoughtcrime.securesms.database.SessionDatabase) SignalProtocolAddress(org.whispersystems.libsignal.SignalProtocolAddress)

Example 57 with SignalProtocolAddress

use of org.whispersystems.libsignal.SignalProtocolAddress in project Signal-Android by WhisperSystems.

the class SignalServiceMessageSender method handleMismatchedDevices.

private void handleMismatchedDevices(PushServiceSocket socket, SignalServiceAddress recipient, MismatchedDevices mismatchedDevices) throws IOException, UntrustedIdentityException {
    try {
        Log.w(TAG, "[handleMismatchedDevices] Address: " + recipient.getIdentifier() + ", ExtraDevices: " + mismatchedDevices.getExtraDevices() + ", MissingDevices: " + mismatchedDevices.getMissingDevices());
        archiveSessions(recipient, mismatchedDevices.getExtraDevices());
        for (int missingDeviceId : mismatchedDevices.getMissingDevices()) {
            PreKeyBundle preKey = socket.getPreKey(recipient, missingDeviceId);
            try {
                SignalSessionBuilder sessionBuilder = new SignalSessionBuilder(sessionLock, new SessionBuilder(store, new SignalProtocolAddress(recipient.getIdentifier(), missingDeviceId)));
                sessionBuilder.process(preKey);
            } catch (org.whispersystems.libsignal.UntrustedIdentityException e) {
                throw new UntrustedIdentityException("Untrusted identity key!", recipient.getIdentifier(), preKey.getIdentityKey());
            }
        }
    } catch (InvalidKeyException e) {
        throw new IOException(e);
    }
}
Also used : PreKeyBundle(org.whispersystems.libsignal.state.PreKeyBundle) SignalSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalSessionBuilder) UntrustedIdentityException(org.whispersystems.signalservice.api.crypto.UntrustedIdentityException) SignalGroupSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalGroupSessionBuilder) GroupSessionBuilder(org.whispersystems.libsignal.groups.GroupSessionBuilder) SessionBuilder(org.whispersystems.libsignal.SessionBuilder) SignalSessionBuilder(org.whispersystems.signalservice.api.crypto.SignalSessionBuilder) IOException(java.io.IOException) InvalidKeyException(org.whispersystems.libsignal.InvalidKeyException) ContentHint(org.whispersystems.signalservice.api.crypto.ContentHint) SignalProtocolAddress(org.whispersystems.libsignal.SignalProtocolAddress)

Aggregations

SignalProtocolAddress (org.whispersystems.libsignal.SignalProtocolAddress)57 InvalidKeyException (org.whispersystems.libsignal.InvalidKeyException)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 PreKeyBundle (org.whispersystems.libsignal.state.PreKeyBundle)7 HashMap (java.util.HashMap)6 Recipient (org.thoughtcrime.securesms.recipients.Recipient)6 IdentityKey (org.whispersystems.libsignal.IdentityKey)6 IOException (java.io.IOException)5 SessionBuilder (org.whispersystems.libsignal.SessionBuilder)5 SessionRecord (org.whispersystems.libsignal.state.SessionRecord)5 Optional (org.whispersystems.libsignal.util.guava.Optional)5 UntrustedIdentityException (org.whispersystems.signalservice.api.crypto.UntrustedIdentityException)5 File (java.io.File)4 List (java.util.List)4 Map (java.util.Map)4 SessionStore (org.whispersystems.libsignal.state.SessionStore)4 DistributionId (org.whispersystems.signalservice.api.push.DistributionId)4 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)4 ByteString (com.google.protobuf.ByteString)3