Search in sources :

Example 6 with TextSecureSessionStore

use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by WhisperSystems.

the class IdentityUtil method getRemoteIdentityKey.

@UiThread
public static ListenableFuture<Optional<IdentityKey>> getRemoteIdentityKey(final Context context, final MasterSecret masterSecret, final Recipient recipient) {
    final SettableFuture<Optional<IdentityKey>> future = new SettableFuture<>();
    new AsyncTask<Recipient, Void, Optional<IdentityKey>>() {

        @Override
        protected Optional<IdentityKey> doInBackground(Recipient... recipient) {
            SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
            SignalProtocolAddress axolotlAddress = new SignalProtocolAddress(recipient[0].getNumber(), SignalServiceAddress.DEFAULT_DEVICE_ID);
            SessionRecord record = sessionStore.loadSession(axolotlAddress);
            if (record == null) {
                return Optional.absent();
            }
            return Optional.fromNullable(record.getSessionState().getRemoteIdentityKey());
        }

        @Override
        protected void onPostExecute(Optional<IdentityKey> result) {
            future.set(result);
        }
    }.execute(recipient);
    return future;
}
Also used : SettableFuture(org.thoughtcrime.securesms.util.concurrent.SettableFuture) IdentityKey(org.whispersystems.libsignal.IdentityKey) Optional(org.whispersystems.libsignal.util.guava.Optional) Recipient(org.thoughtcrime.securesms.recipients.Recipient) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) SessionStore(org.whispersystems.libsignal.state.SessionStore) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) SignalProtocolAddress(org.whispersystems.libsignal.SignalProtocolAddress) SessionRecord(org.whispersystems.libsignal.state.SessionRecord) UiThread(android.support.annotation.UiThread)

Example 7 with TextSecureSessionStore

use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by signalapp.

the class SessionUtil method archiveSiblingSessions.

public static void archiveSiblingSessions(Context context, SignalProtocolAddress address) {
    TextSecureSessionStore sessionStore = new TextSecureSessionStore(context);
    sessionStore.archiveSiblingSessions(address);
}
Also used : TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore)

Example 8 with TextSecureSessionStore

use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by signalapp.

the class PushDecryptJob method handleSynchronizeSentEndSessionMessage.

private long handleSynchronizeSentEndSessionMessage(@NonNull SentTranscriptMessage message) {
    SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
    Recipient recipient = getSyncMessageDestination(message);
    OutgoingTextMessage outgoingTextMessage = new OutgoingTextMessage(recipient, "", -1);
    OutgoingEndSessionMessage outgoingEndSessionMessage = new OutgoingEndSessionMessage(outgoingTextMessage);
    long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient);
    if (!recipient.isGroupRecipient()) {
        SessionStore sessionStore = new TextSecureSessionStore(context);
        sessionStore.deleteAllSessions(recipient.getAddress().toPhoneString());
        SecurityEvent.broadcastSecurityUpdateEvent(context);
        long messageId = database.insertMessageOutbox(threadId, outgoingEndSessionMessage, false, message.getTimestamp(), null);
        database.markAsSent(messageId, true);
    }
    return threadId;
}
Also used : OutgoingTextMessage(org.thoughtcrime.securesms.sms.OutgoingTextMessage) OutgoingEndSessionMessage(org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage) SessionStore(org.whispersystems.libsignal.state.SessionStore) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) SmsDatabase(org.thoughtcrime.securesms.database.SmsDatabase) Recipient(org.thoughtcrime.securesms.recipients.Recipient)

Example 9 with TextSecureSessionStore

use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by WhisperSystems.

the class ApplicationDependencyProvider method provideProtocolStore.

@Override
@NonNull
public SignalServiceDataStoreImpl provideProtocolStore() {
    ACI localAci = SignalStore.account().getAci();
    PNI localPni = SignalStore.account().getPni();
    if (localAci == null) {
        throw new IllegalStateException("No ACI set!");
    }
    if (localPni == null) {
        throw new IllegalStateException("No PNI set!");
    }
    if (!SignalStore.account().hasPniIdentityKey()) {
        SignalStore.account().generatePniIdentityKeyIfNecessary();
        CreateSignedPreKeyJob.enqueueIfNeeded();
    }
    SignalBaseIdentityKeyStore baseIdentityStore = new SignalBaseIdentityKeyStore(context);
    SignalServiceAccountDataStoreImpl aciStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localAci), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getAciIdentityKey()), new TextSecureSessionStore(localAci), new SignalSenderKeyStore(context));
    SignalServiceAccountDataStoreImpl pniStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localPni), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getPniIdentityKey()), new TextSecureSessionStore(localPni), new SignalSenderKeyStore(context));
    return new SignalServiceDataStoreImpl(context, aciStore, pniStore);
}
Also used : TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) TextSecurePreKeyStore(org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore) ACI(org.whispersystems.signalservice.api.push.ACI) SignalSenderKeyStore(org.thoughtcrime.securesms.crypto.storage.SignalSenderKeyStore) PNI(org.whispersystems.signalservice.api.push.PNI) SignalIdentityKeyStore(org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore) SignalBaseIdentityKeyStore(org.thoughtcrime.securesms.crypto.storage.SignalBaseIdentityKeyStore) SignalServiceAccountDataStoreImpl(org.thoughtcrime.securesms.crypto.storage.SignalServiceAccountDataStoreImpl) SignalServiceDataStoreImpl(org.thoughtcrime.securesms.crypto.storage.SignalServiceDataStoreImpl) NonNull(androidx.annotation.NonNull)

Example 10 with TextSecureSessionStore

use of org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore in project Signal-Android by signalapp.

the class ApplicationDependencyProvider method provideProtocolStore.

@Override
@NonNull
public SignalServiceDataStoreImpl provideProtocolStore() {
    ACI localAci = SignalStore.account().getAci();
    PNI localPni = SignalStore.account().getPni();
    if (localAci == null) {
        throw new IllegalStateException("No ACI set!");
    }
    if (localPni == null) {
        throw new IllegalStateException("No PNI set!");
    }
    if (!SignalStore.account().hasPniIdentityKey()) {
        SignalStore.account().generatePniIdentityKeyIfNecessary();
        CreateSignedPreKeyJob.enqueueIfNeeded();
    }
    SignalBaseIdentityKeyStore baseIdentityStore = new SignalBaseIdentityKeyStore(context);
    SignalServiceAccountDataStoreImpl aciStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localAci), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getAciIdentityKey()), new TextSecureSessionStore(localAci), new SignalSenderKeyStore(context));
    SignalServiceAccountDataStoreImpl pniStore = new SignalServiceAccountDataStoreImpl(context, new TextSecurePreKeyStore(localPni), new SignalIdentityKeyStore(baseIdentityStore, () -> SignalStore.account().getPniIdentityKey()), new TextSecureSessionStore(localPni), new SignalSenderKeyStore(context));
    return new SignalServiceDataStoreImpl(context, aciStore, pniStore);
}
Also used : TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) TextSecurePreKeyStore(org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore) ACI(org.whispersystems.signalservice.api.push.ACI) SignalSenderKeyStore(org.thoughtcrime.securesms.crypto.storage.SignalSenderKeyStore) PNI(org.whispersystems.signalservice.api.push.PNI) SignalIdentityKeyStore(org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore) SignalBaseIdentityKeyStore(org.thoughtcrime.securesms.crypto.storage.SignalBaseIdentityKeyStore) SignalServiceAccountDataStoreImpl(org.thoughtcrime.securesms.crypto.storage.SignalServiceAccountDataStoreImpl) SignalServiceDataStoreImpl(org.thoughtcrime.securesms.crypto.storage.SignalServiceDataStoreImpl) NonNull(androidx.annotation.NonNull)

Aggregations

TextSecureSessionStore (org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore)10 SessionStore (org.whispersystems.libsignal.state.SessionStore)7 SignalProtocolAddress (org.whispersystems.libsignal.SignalProtocolAddress)3 NonNull (androidx.annotation.NonNull)2 SignalBaseIdentityKeyStore (org.thoughtcrime.securesms.crypto.storage.SignalBaseIdentityKeyStore)2 SignalIdentityKeyStore (org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore)2 SignalSenderKeyStore (org.thoughtcrime.securesms.crypto.storage.SignalSenderKeyStore)2 SignalServiceAccountDataStoreImpl (org.thoughtcrime.securesms.crypto.storage.SignalServiceAccountDataStoreImpl)2 SignalServiceDataStoreImpl (org.thoughtcrime.securesms.crypto.storage.SignalServiceDataStoreImpl)2 TextSecurePreKeyStore (org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore)2 EncryptingSmsDatabase (org.thoughtcrime.securesms.database.EncryptingSmsDatabase)2 InsertResult (org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult)2 SmsDatabase (org.thoughtcrime.securesms.database.SmsDatabase)2 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2 IncomingEndSessionMessage (org.thoughtcrime.securesms.sms.IncomingEndSessionMessage)2 IncomingTextMessage (org.thoughtcrime.securesms.sms.IncomingTextMessage)2 OutgoingEndSessionMessage (org.thoughtcrime.securesms.sms.OutgoingEndSessionMessage)2 OutgoingTextMessage (org.thoughtcrime.securesms.sms.OutgoingTextMessage)2 ACI (org.whispersystems.signalservice.api.push.ACI)2 PNI (org.whispersystems.signalservice.api.push.PNI)2