Fix decryption corner case when passphrase is disabled.

This commit is contained in:
Moxie Marlinspike 2014-03-20 14:07:39 -07:00
parent 5a3daf4846
commit 40629a3bcf

View File

@ -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 {