Store the authCredentialSalt when registering.

This commit is contained in:
Greyson Parrelli
2026-08-19 19:05:49 -04:00
committed by Cody Henthorne
parent 771cae8a9a
commit e1df942c3c
5 changed files with 16 additions and 1 deletions
@@ -49,6 +49,7 @@ class AccountValues internal constructor(store: KeyValueStore, context: Context)
private const val KEY_DEVICE_NAME = "account.device_name"
private const val KEY_DEVICE_ID = "account.device_id"
private const val KEY_PNI_REGISTRATION_ID = "account.pni_registration_id"
private const val KEY_AUTH_CREDENTIAL_SALT = "account.auth_credential_salt"
private const val KEY_ACI_IDENTITY_PUBLIC_KEY = "account.aci_identity_public_key"
private const val KEY_ACI_IDENTITY_PRIVATE_KEY = "account.aci_identity_private_key"
@@ -276,6 +277,9 @@ class AccountValues internal constructor(store: KeyValueStore, context: Context)
putString(KEY_SERVICE_PASSWORD, servicePassword)
}
/** Salt used by the service to generate PNI auth credentials. Only present for an account registered without a phone number. */
var authCredentialSalt: ByteArray? by nullableBlobValue(KEY_AUTH_CREDENTIAL_SALT, null)
/** A randomly-generated value that represents this registration instance. Helps the server know if you reinstalled. */
var registrationId: Int by integerValue(KEY_REGISTRATION_ID, 0)
@@ -820,6 +820,10 @@ class AppRegistrationStorageController(private val context: Context) : StorageCo
SignalStore.misc.needsUsernameRestore = true
}
accountData.authCredentialSalt?.let {
SignalStore.account.authCredentialSalt = it.toByteArray()
}
SignalStore.account.setServicePassword(accountData.servicePassword)
SignalStore.account.setRegistered(registered = true, isAciChanged = isAciChanged)
TextSecurePreferences.setPromptedPushRegistration(context, true)
@@ -94,6 +94,7 @@ class AppRegistrationStorageControllerTest {
private val pniSignedPreKey = PreKeyUtil.generateSignedPreKey(12, pniIdentity.privateKey)
private val aciLastResortKyberPreKey = PreKeyUtil.generateLastResortKyberPreKey(21, aciIdentity.privateKey)
private val pniLastResortKyberPreKey = PreKeyUtil.generateLastResortKyberPreKey(22, pniIdentity.privateKey)
private val authCredentialSalt = byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
private val blobData = mutableMapOf<Uri, ByteArray>()
private var blobCounter = 0
@@ -147,6 +148,7 @@ class AppRegistrationStorageControllerTest {
assertThat(SignalStore.account.pniIdentityKey.serialize()).isEqualTo(pniIdentity.serialize())
assertThat(SignalStore.account.accountEntropyPool.value).isEqualTo(aep.value)
assertThat(SignalStore.account.restoredAccountEntropyPool).isTrue()
assertThat(SignalStore.account.authCredentialSalt).isNotNull().isEqualTo(authCredentialSalt)
assertThat(SignalStore.account.aciPreKeys.isSignedPreKeyRegistered).isTrue()
assertThat(SignalStore.account.aciPreKeys.activeSignedPreKeyId).isEqualTo(11)
@@ -539,7 +541,8 @@ class AppRegistrationStorageControllerTest {
e164 = E164,
servicePassword = servicePassword,
linkedDeviceData = linkedDeviceData,
reRegistration = reRegistration
reRegistration = reRegistration,
authCredentialSalt = authCredentialSalt.toByteString()
)
}
}
@@ -715,6 +715,7 @@ class RegistrationRepository(
this.pni = result.result.pni
this.servicePassword = keyMaterial.servicePassword
this.reRegistration = result.result.reregistration
this.authCredentialSalt = result.result.authCredentialSalt?.let { Base64.decode(it).toByteString() }
}
storageController.commitRegistrationData()
}
@@ -50,6 +50,9 @@ message AccountData {
// Whether the service reported this registration as a re-registration of an existing account.
bool reRegistration = 16;
// Salt used by the service to generate PNI auth credentials. Only present for an account registered without a phone number.
optional bytes authCredentialSalt = 17;
}
message SvrCredential {