Search in sources :

Example 1 with MasterSecret

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

the class PassphrasePromptActivity method handlePassphrase.

private void handlePassphrase() {
    try {
        Editable text = passphraseText.getText();
        String passphrase = (text == null ? "" : text.toString());
        MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, passphrase);
        setMasterSecret(masterSecret);
    } catch (InvalidPassphraseException ipe) {
        passphraseText.setText("");
        passphraseText.setError(getString(R.string.PassphrasePromptActivity_invalid_passphrase_exclamation));
    }
}
Also used : MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) InvalidPassphraseException(org.thoughtcrime.securesms.crypto.InvalidPassphraseException) Editable(android.text.Editable) SpannableString(android.text.SpannableString)

Example 2 with MasterSecret

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

the class PassphraseRequiredActionBarActivity method onCreate.

@Override
protected final void onCreate(Bundle savedInstanceState) {
    Log.w(TAG, "onCreate(" + savedInstanceState + ")");
    this.networkAccess = new SignalServiceNetworkAccess(this);
    onPreCreate();
    final MasterSecret masterSecret = KeyCachingService.getMasterSecret(this);
    routeApplicationState(masterSecret);
    super.onCreate(savedInstanceState);
    if (!isFinishing()) {
        initializeClearKeyReceiver();
        onCreate(savedInstanceState, masterSecret);
    }
}
Also used : MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) SignalServiceNetworkAccess(org.thoughtcrime.securesms.push.SignalServiceNetworkAccess)

Example 3 with MasterSecret

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

the class PushDecryptJob method onRun.

@Override
public void onRun() throws NoSuchMessageException {
    if (!IdentityKeyUtil.hasIdentityKey(context)) {
        Log.w(TAG, "Skipping job, waiting for migration...");
        return;
    }
    MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);
    PushDatabase database = DatabaseFactory.getPushDatabase(context);
    SignalServiceEnvelope envelope = database.get(messageId);
    Optional<Long> optionalSmsMessageId = smsMessageId > 0 ? Optional.of(smsMessageId) : Optional.<Long>absent();
    MasterSecretUnion masterSecretUnion;
    if (masterSecret == null)
        masterSecretUnion = new MasterSecretUnion(MasterSecretUtil.getAsymmetricMasterSecret(context, null));
    else
        masterSecretUnion = new MasterSecretUnion(masterSecret);
    handleMessage(masterSecretUnion, envelope, optionalSmsMessageId);
    database.delete(messageId);
}
Also used : MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) PushDatabase(org.thoughtcrime.securesms.database.PushDatabase) MasterSecretUnion(org.thoughtcrime.securesms.crypto.MasterSecretUnion) SignalServiceEnvelope(org.whispersystems.signalservice.api.messages.SignalServiceEnvelope)

Example 4 with MasterSecret

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

the class SmsReceiveJob method onRun.

@Override
public void onRun() {
    Log.w(TAG, "onRun()");
    Optional<IncomingTextMessage> message = assembleMessageFragments(pdus, subscriptionId);
    MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);
    MasterSecretUnion masterSecretUnion;
    if (masterSecret == null) {
        masterSecretUnion = new MasterSecretUnion(MasterSecretUtil.getAsymmetricMasterSecret(context, null));
    } else {
        masterSecretUnion = new MasterSecretUnion(masterSecret);
    }
    if (message.isPresent() && !isBlocked(message.get())) {
        Optional<InsertResult> insertResult = storeMessage(masterSecretUnion, message.get());
        if (insertResult.isPresent()) {
            MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId());
        }
    } else if (message.isPresent()) {
        Log.w(TAG, "*** Received blocked SMS, ignoring...");
    } else {
        Log.w(TAG, "*** Failed to assemble message fragments!");
    }
}
Also used : InsertResult(org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult) MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret) MasterSecretUnion(org.thoughtcrime.securesms.crypto.MasterSecretUnion) IncomingTextMessage(org.thoughtcrime.securesms.sms.IncomingTextMessage)

Example 5 with MasterSecret

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

the class MasterSecretJob method onRun.

@Override
public void onRun() throws Exception {
    MasterSecret masterSecret = getMasterSecret();
    onRun(masterSecret);
}
Also used : MasterSecret(org.thoughtcrime.securesms.crypto.MasterSecret)

Aggregations

MasterSecret (org.thoughtcrime.securesms.crypto.MasterSecret)16 MasterCipher (org.thoughtcrime.securesms.crypto.MasterCipher)4 IOException (java.io.IOException)3 InvalidPassphraseException (org.thoughtcrime.securesms.crypto.InvalidPassphraseException)3 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Bitmap (android.graphics.Bitmap)2 InputStream (java.io.InputStream)2 MasterSecretUnion (org.thoughtcrime.securesms.crypto.MasterSecretUnion)2 ThreadDatabase (org.thoughtcrime.securesms.database.ThreadDatabase)2 ComponentName (android.content.ComponentName)1 Cursor (android.database.Cursor)1 BitmapFactory (android.graphics.BitmapFactory)1 Point (android.graphics.Point)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 ParcelFileDescriptor (android.os.ParcelFileDescriptor)1 ChooserTarget (android.service.chooser.ChooserTarget)1 Nullable (android.support.annotation.Nullable)1