Migrate to a new SVR2 enclave.

This commit is contained in:
Greyson Parrelli
2023-12-07 15:14:44 -05:00
parent f966b23f3a
commit a749b97707
4 changed files with 20 additions and 9 deletions

View File

@@ -39,10 +39,14 @@ object SvrRepository {
val TAG = Log.tag(SvrRepository::class.java)
private val svr2Deprecated: SecureValueRecovery = ApplicationDependencies.getSignalServiceAccountManager().getSecureValueRecoveryV2(BuildConfig.SVR2_MRENCLAVE_DEPRECATED)
private val svr2: SecureValueRecovery = ApplicationDependencies.getSignalServiceAccountManager().getSecureValueRecoveryV2(BuildConfig.SVR2_MRENCLAVE)
/** An ordered list of SVR implementations. They should be in priority order, with the most important one listed first. */
private val implementations: List<SecureValueRecovery> = listOf(svr2)
/** An ordered list of SVR implementations to read from. They should be in priority order, with the most important one listed first. */
private val readImplementations: List<SecureValueRecovery> = listOf(svr2, svr2Deprecated)
/** An ordered list of SVR implementations to write to. They should be in priority order, with the most important one listed first. */
private val writeImplementations: List<SecureValueRecovery> = listOf(svr2, svr2Deprecated)
/**
* A lock that ensures that only one thread at a time is altering the various pieces of SVR state.
@@ -122,7 +126,7 @@ object SvrRepository {
val stopwatch = Stopwatch("pin-submission")
operationLock.withLock {
for (implementation in implementations) {
for (implementation in readImplementations) {
when (val response: RestoreResponse = implementation.restoreDataPostRegistration(userPin)) {
is RestoreResponse.Success -> {
Log.i(TAG, "[restoreMasterKeyPostRegistration] Successfully restored master key. $implementation", true)
@@ -187,7 +191,7 @@ object SvrRepository {
}
/**
* Sets the user's PIN the one specified, updating local stores as necessary.
* Sets the user's PIN to the one specified, updating local stores as necessary.
* The resulting Single will not throw an error in any expected case, only if there's a runtime exception.
*/
@WorkerThread
@@ -196,7 +200,7 @@ object SvrRepository {
return operationLock.withLock {
val masterKey: MasterKey = SignalStore.svr().getOrCreateMasterKey()
val responses: List<BackupResponse> = implementations
val responses: List<BackupResponse> = writeImplementations
.filter { it != svr2 || FeatureFlags.svr2() }
.map { it.setPin(userPin, masterKey) }
.map { it.execute() }