From e6b4249cf3522ef4d577760302c77cdd59161454 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Thu, 17 Jan 2019 15:36:53 -0800 Subject: [PATCH] Deprecate usage of the signaling key. --- .../thoughtcrime/securesms/DatabaseUpgradeActivity.java | 9 +++++++++ src/org/thoughtcrime/securesms/RegistrationActivity.java | 5 +---- .../securesms/jobs/RefreshAttributesJob.java | 3 +-- .../securesms/util/TextSecurePreferences.java | 4 ---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java b/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java index ed705b1b7d..c1512aa341 100644 --- a/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java +++ b/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java @@ -95,6 +95,7 @@ public class DatabaseUpgradeActivity extends BaseActivity { public static final int WORKMANAGER_MIGRATION = 408; public static final int COLOR_MIGRATION = 412; public static final int UNIDENTIFIED_DELIVERY = 422; + public static final int SIGNALING_KEY_DEPRECATION = 447; private static final SortedSet UPGRADE_VERSIONS = new TreeSet() {{ add(NO_MORE_KEY_EXCHANGE_PREFIX_VERSION); @@ -121,6 +122,7 @@ public class DatabaseUpgradeActivity extends BaseActivity { add(WORKMANAGER_MIGRATION); add(COLOR_MIGRATION); add(UNIDENTIFIED_DELIVERY); + add(SIGNALING_KEY_DEPRECATION); }}; private MasterSecret masterSecret; @@ -371,6 +373,13 @@ public class DatabaseUpgradeActivity extends BaseActivity { .add(new RefreshAttributesJob(context)); } + if (params[0] < SIGNALING_KEY_DEPRECATION) { + Log.i(TAG, "Scheduling a RefreshAttributesJob to remove the signaling key remotely."); + ApplicationContext.getInstance(context) + .getJobManager() + .add(new RefreshAttributesJob(context)); + } + return null; } diff --git a/src/org/thoughtcrime/securesms/RegistrationActivity.java b/src/org/thoughtcrime/securesms/RegistrationActivity.java index 10d01c8ad0..7dae4c66fa 100644 --- a/src/org/thoughtcrime/securesms/RegistrationActivity.java +++ b/src/org/thoughtcrime/securesms/RegistrationActivity.java @@ -713,9 +713,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements Verif TextSecurePreferences.setLocalRegistrationId(RegistrationActivity.this, registrationId); SessionUtil.archiveAllSessions(RegistrationActivity.this); - String signalingKey = Util.getSecret(52); - - accountManager.verifyAccountWithCode(code, signalingKey, registrationId, !registrationState.gcmToken.isPresent(), pin, + accountManager.verifyAccountWithCode(code, null, registrationId, !registrationState.gcmToken.isPresent(), pin, unidentifiedAccessKey, universalUnidentifiedAccess); IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(RegistrationActivity.this); @@ -741,7 +739,6 @@ public class RegistrationActivity extends BaseActionBarActivity implements Verif TextSecurePreferences.setPushRegistered(RegistrationActivity.this, true); TextSecurePreferences.setLocalNumber(RegistrationActivity.this, registrationState.e164number); TextSecurePreferences.setPushServerPassword(RegistrationActivity.this, registrationState.password); - TextSecurePreferences.setSignalingKey(RegistrationActivity.this, signalingKey); TextSecurePreferences.setSignedPreKeyRegistered(RegistrationActivity.this, true); TextSecurePreferences.setPromptedPushRegistration(RegistrationActivity.this, true); TextSecurePreferences.setUnauthorizedReceived(RegistrationActivity.this, false); diff --git a/src/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java b/src/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java index 4227f93c95..0c2c9d16f3 100644 --- a/src/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java @@ -52,14 +52,13 @@ public class RefreshAttributesJob extends ContextJob implements InjectableType { @Override public void onRun() throws IOException { - String signalingKey = TextSecurePreferences.getSignalingKey(context); int registrationId = TextSecurePreferences.getLocalRegistrationId(context); boolean fetchesMessages = TextSecurePreferences.isGcmDisabled(context); String pin = TextSecurePreferences.getRegistrationLockPin(context); byte[] unidentifiedAccessKey = UnidentifiedAccessUtil.getSelfUnidentifiedAccessKey(context); boolean universalUnidentifiedAccess = TextSecurePreferences.isUniversalUnidentifiedAccess(context); - signalAccountManager.setAccountAttributes(signalingKey, registrationId, fetchesMessages, pin, + signalAccountManager.setAccountAttributes(null, registrationId, fetchesMessages, pin, unidentifiedAccessKey, universalUnidentifiedAccess); ApplicationContext.getInstance(context) diff --git a/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java b/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java index ead6eb1901..9f347c6ca4 100644 --- a/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java +++ b/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java @@ -620,10 +620,6 @@ public class TextSecurePreferences { setStringPreference(context, GCM_PASSWORD_PREF, password); } - public static void setSignalingKey(Context context, String signalingKey) { - setStringPreference(context, SIGNALING_KEY_PREF, signalingKey); - } - public static String getSignalingKey(Context context) { return getStringPreference(context, SIGNALING_KEY_PREF, null); }