mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 10:17:56 +00:00
Only generate a PNI key if necessary.
This commit is contained in:
@@ -19,7 +19,6 @@ package org.thoughtcrime.securesms;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
@@ -63,7 +62,7 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
||||
|
||||
MasterSecretUtil.generateAsymmetricMasterSecret(PassphraseCreateActivity.this, masterSecret);
|
||||
SignalStore.account().generateAciIdentityKey();
|
||||
SignalStore.account().generatePniIdentityKey();
|
||||
SignalStore.account().generatePniIdentityKeyIfNecessary();
|
||||
VersionTracker.updateLastSeenVersion(PassphraseCreateActivity.this);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -291,7 +291,7 @@ public class ApplicationDependencyProvider implements ApplicationDependencies.Pr
|
||||
}
|
||||
|
||||
if (!SignalStore.account().hasPniIdentityKey()) {
|
||||
SignalStore.account().generatePniIdentityKey();
|
||||
SignalStore.account().generatePniIdentityKeyIfNecessary();
|
||||
CreateSignedPreKeyJob.enqueueIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
@@ -168,11 +168,15 @@ internal class AccountValues internal constructor(store: KeyValueStore) : Signal
|
||||
return store.containsKey(KEY_PNI_IDENTITY_PUBLIC_KEY)
|
||||
}
|
||||
|
||||
/** Generates and saves an identity key pair for the PNI identity. Should only be done once. */
|
||||
fun generatePniIdentityKey() {
|
||||
/** Generates and saves an identity key pair for the PNI identity if one doesn't already exist. */
|
||||
fun generatePniIdentityKeyIfNecessary() {
|
||||
synchronized(this) {
|
||||
if (store.containsKey(KEY_PNI_IDENTITY_PUBLIC_KEY)) {
|
||||
Log.w(TAG, "Tried to generate a PNI identity, but one was already set!", Throwable())
|
||||
return
|
||||
}
|
||||
|
||||
Log.i(TAG, "Generating a new PNI identity key pair.")
|
||||
require(!store.containsKey(KEY_PNI_IDENTITY_PUBLIC_KEY)) { "Already generated!" }
|
||||
|
||||
val key: IdentityKeyPair = IdentityKeyUtil.generateIdentityKeyPair()
|
||||
store
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.jobs.KbsEnclaveMigrationWorkerJob;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.whispersystems.libsignal.state.PreKeyRecord;
|
||||
@@ -65,7 +64,7 @@ public class PniAccountInitializationMigrationJob extends MigrationJob {
|
||||
|
||||
if (!SignalStore.account().hasPniIdentityKey()) {
|
||||
Log.i(TAG, "Generating PNI identity.");
|
||||
SignalStore.account().generatePniIdentityKey();
|
||||
SignalStore.account().generatePniIdentityKeyIfNecessary();
|
||||
} else {
|
||||
Log.w(TAG, "Already generated the PNI identity. Skipping this step.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user