Rotate MRBK when rotating AEP.

This commit is contained in:
Greyson Parrelli
2025-07-30 09:59:16 -04:00
committed by GitHub
parent faecbf5ea9
commit 90c381f0ba
5 changed files with 37 additions and 16 deletions

View File

@@ -211,17 +211,21 @@ object BackupRepository {
* Generates a new AEP that the user can choose to confirm.
*/
@CheckResult
fun stageAEPKeyRotation(): AccountEntropyPool {
return AccountEntropyPool.generate()
fun stageBackupKeyRotations(): StagedBackupKeyRotations {
return StagedBackupKeyRotations(
aep = AccountEntropyPool.generate(),
mediaRootBackupKey = MediaRootBackupKey.generate()
)
}
/**
* Saves the AEP to the local storage and kicks off a backup upload.
*/
suspend fun commitAEPKeyRotation(accountEntropyPool: AccountEntropyPool) {
suspend fun commitAEPKeyRotation(stagedKeyRotations: StagedBackupKeyRotations) {
haltAllJobs()
resetInitializedStateAndAuthCredentials()
SignalStore.account.rotateAccountEntropyPool(accountEntropyPool)
SignalStore.account.rotateAccountEntropyPool(stagedKeyRotations.aep)
SignalStore.backup.mediaRootBackupKey = stagedKeyRotations.mediaRootBackupKey
BackupMessagesJob.enqueue()
}
@@ -2009,6 +2013,11 @@ class DebugBackupMetadata(
val mediaSize: Long
)
data class StagedBackupKeyRotations(
val aep: AccountEntropyPool,
val mediaRootBackupKey: MediaRootBackupKey
)
sealed class ImportResult {
data class Success(val backupTime: Long) : ImportResult()
data object Failure : ImportResult()