Search in sources :

Example 1 with TextSecureSessionStore

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

the class SessionUtil method hasSession.

public static boolean hasSession(Context context, MasterSecret masterSecret, @NonNull String number) {
    SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
    SignalProtocolAddress axolotlAddress = new SignalProtocolAddress(number, SignalServiceAddress.DEFAULT_DEVICE_ID);
    return sessionStore.containsSession(axolotlAddress);
}
Also used : 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)

Example 2 with TextSecureSessionStore

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

the class SessionUtil method hasSession.

public static boolean hasSession(Context context, @NonNull Address address) {
    SessionStore sessionStore = new TextSecureSessionStore(context);
    SignalProtocolAddress axolotlAddress = new SignalProtocolAddress(address.serialize(), SignalServiceAddress.DEFAULT_DEVICE_ID);
    return sessionStore.containsSession(axolotlAddress);
}
Also used : 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)

Example 3 with TextSecureSessionStore

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

the class PushDecryptJob method handleEndSessionMessage.

private void handleEndSessionMessage(@NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceDataMessage message, @NonNull Optional<Long> smsMessageId) {
    SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context);
    IncomingTextMessage incomingTextMessage = new IncomingTextMessage(Address.fromExternal(context, envelope.getSource()), envelope.getSourceDevice(), message.getTimestamp(), "", Optional.absent(), 0);
    Long threadId;
    if (!smsMessageId.isPresent()) {
        IncomingEndSessionMessage incomingEndSessionMessage = new IncomingEndSessionMessage(incomingTextMessage);
        Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(incomingEndSessionMessage);
        if (insertResult.isPresent())
            threadId = insertResult.get().getThreadId();
        else
            threadId = null;
    } else {
        smsDatabase.markAsEndSession(smsMessageId.get());
        threadId = smsDatabase.getThreadIdForMessage(smsMessageId.get());
    }
    if (threadId != null) {
        SessionStore sessionStore = new TextSecureSessionStore(context);
        sessionStore.deleteAllSessions(envelope.getSource());
        SecurityEvent.broadcastSecurityUpdateEvent(context);
        MessageNotifier.updateNotification(context, threadId);
    }
}
Also used : InsertResult(org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult) SessionStore(org.whispersystems.libsignal.state.SessionStore) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) IncomingEndSessionMessage(org.thoughtcrime.securesms.sms.IncomingEndSessionMessage) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) IncomingTextMessage(org.thoughtcrime.securesms.sms.IncomingTextMessage) SmsDatabase(org.thoughtcrime.securesms.database.SmsDatabase)

Example 4 with TextSecureSessionStore

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

the class PushDecryptJob method handleSynchronizeSentEndSessionMessage.

private long handleSynchronizeSentEndSessionMessage(@NonNull MasterSecretUnion masterSecret, @NonNull SentTranscriptMessage message, @NonNull Optional<Long> smsMessageId) {
    EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
    Recipients recipients = getSyncMessageDestination(message);
    OutgoingTextMessage outgoingTextMessage = new OutgoingTextMessage(recipients, "", -1);
    OutgoingEndSessionMessage outgoingEndSessionMessage = new OutgoingEndSessionMessage(outgoingTextMessage);
    long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
    if (recipients.isSingleRecipient() && !recipients.isGroupRecipient()) {
        SessionStore sessionStore = new TextSecureSessionStore(context);
        sessionStore.deleteAllSessions(recipients.getPrimaryRecipient().getNumber());
        SecurityEvent.broadcastSecurityUpdateEvent(context);
        long messageId = database.insertMessageOutbox(masterSecret, threadId, outgoingEndSessionMessage, false, message.getTimestamp());
        database.markAsSent(messageId, true);
    }
    if (smsMessageId.isPresent()) {
        database.deleteMessage(smsMessageId.get());
    }
    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) Recipients(org.thoughtcrime.securesms.recipients.Recipients) EncryptingSmsDatabase(org.thoughtcrime.securesms.database.EncryptingSmsDatabase)

Example 5 with TextSecureSessionStore

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

the class PushDecryptJob method handleEndSessionMessage.

private void handleEndSessionMessage(@NonNull MasterSecretUnion masterSecret, @NonNull SignalServiceEnvelope envelope, @NonNull SignalServiceDataMessage message, @NonNull Optional<Long> smsMessageId) {
    EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);
    IncomingTextMessage incomingTextMessage = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(), message.getTimestamp(), "", Optional.<SignalServiceGroup>absent(), 0);
    Long threadId;
    if (!smsMessageId.isPresent()) {
        IncomingEndSessionMessage incomingEndSessionMessage = new IncomingEndSessionMessage(incomingTextMessage);
        Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(masterSecret, incomingEndSessionMessage);
        if (insertResult.isPresent())
            threadId = insertResult.get().getThreadId();
        else
            threadId = null;
    } else {
        smsDatabase.markAsEndSession(smsMessageId.get());
        threadId = smsDatabase.getThreadIdForMessage(smsMessageId.get());
    }
    if (threadId != null) {
        SessionStore sessionStore = new TextSecureSessionStore(context);
        sessionStore.deleteAllSessions(envelope.getSource());
        SecurityEvent.broadcastSecurityUpdateEvent(context);
        MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), threadId);
    }
}
Also used : InsertResult(org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult) SessionStore(org.whispersystems.libsignal.state.SessionStore) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) IncomingEndSessionMessage(org.thoughtcrime.securesms.sms.IncomingEndSessionMessage) TextSecureSessionStore(org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore) EncryptingSmsDatabase(org.thoughtcrime.securesms.database.EncryptingSmsDatabase) IncomingTextMessage(org.thoughtcrime.securesms.sms.IncomingTextMessage)

Aggregations

TextSecureSessionStore (org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore)9 SessionStore (org.whispersystems.libsignal.state.SessionStore)7 SignalProtocolAddress (org.whispersystems.libsignal.SignalProtocolAddress)3 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 UiThread (android.support.annotation.UiThread)1 NonNull (androidx.annotation.NonNull)1 SignalBaseIdentityKeyStore (org.thoughtcrime.securesms.crypto.storage.SignalBaseIdentityKeyStore)1 SignalIdentityKeyStore (org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore)1 SignalSenderKeyStore (org.thoughtcrime.securesms.crypto.storage.SignalSenderKeyStore)1 SignalServiceAccountDataStoreImpl (org.thoughtcrime.securesms.crypto.storage.SignalServiceAccountDataStoreImpl)1 SignalServiceDataStoreImpl (org.thoughtcrime.securesms.crypto.storage.SignalServiceDataStoreImpl)1 TextSecurePreKeyStore (org.thoughtcrime.securesms.crypto.storage.TextSecurePreKeyStore)1 Recipients (org.thoughtcrime.securesms.recipients.Recipients)1