From 40629a3bcff1cf6f06e53501ef182b8774efd540 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Thu, 20 Mar 2014 14:07:39 -0700 Subject: [PATCH] Fix decryption corner case when passphrase is disabled. --- .../securesms/service/SendReceiveService.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/org/thoughtcrime/securesms/service/SendReceiveService.java b/src/org/thoughtcrime/securesms/service/SendReceiveService.java index 91b0b98b6d..a1ba4b0555 100644 --- a/src/org/thoughtcrime/securesms/service/SendReceiveService.java +++ b/src/org/thoughtcrime/securesms/service/SendReceiveService.java @@ -215,6 +215,16 @@ public class SendReceiveService extends Service { CanonicalSessionMigrator.migrateSessions(this); } + private MasterSecret getPlaceholderSecret() { + try { + return MasterSecretUtil.getMasterSecret(SendReceiveService.this, + MasterSecretUtil.UNENCRYPTED_PASSPHRASE); + } catch (InvalidPassphraseException e) { + Log.w("SendReceiveService", e); + return null; + } + } + private void scheduleIntent(int what, Intent intent) { Runnable work = new SendReceiveWorkItem(intent, what); @@ -228,6 +238,10 @@ public class SendReceiveService extends Service { Runnable work = new SendReceiveWorkItem(intent, what); synchronized (workQueue) { + if (!hasSecret && TextSecurePreferences.isPasswordDisabled(SendReceiveService.this)) { + initializeWithMasterSecret(getPlaceholderSecret()); + } + if (hasSecret) { workQueue.add(work); workQueue.notifyAll(); @@ -266,16 +280,6 @@ public class SendReceiveService extends Service { case DOWNLOAD_AVATAR: avatarDownloader.process(masterSecret, intent); return; } } - - private MasterSecret getPlaceholderSecret() { - try { - return MasterSecretUtil.getMasterSecret(SendReceiveService.this, - MasterSecretUtil.UNENCRYPTED_PASSPHRASE); - } catch (InvalidPassphraseException e) { - Log.w("SendReceiveService", e); - return null; - } - } } public class ToastHandler extends Handler {