Add internal UI for importing backup with different credentials.

Co-authored-by: Greyson Parrelli <greyson@signal.org>
This commit is contained in:
Jordan Rose
2024-12-19 11:15:27 -08:00
committed by Greyson Parrelli
parent 0cfda852cf
commit fa32f399b2
7 changed files with 185 additions and 51 deletions

View File

@@ -15,9 +15,21 @@ import org.signal.libsignal.messagebackup.AccountEntropyPool as LibSignalAccount
class AccountEntropyPool(val value: String) {
companion object {
private val INVALID_CHARACTERS = Regex("[^0-9a-zA-Z]")
private const val LENGTH = 64
fun generate(): AccountEntropyPool {
return AccountEntropyPool(LibSignalAccountEntropyPool.generate())
}
fun parseOrNull(input: String): AccountEntropyPool? {
val stripped = input.replace(INVALID_CHARACTERS, "")
if (stripped.length != LENGTH) {
return null
}
return AccountEntropyPool(stripped)
}
}
fun deriveMasterKey(): MasterKey {

View File

@@ -12,7 +12,7 @@ import org.signal.libsignal.messagebackup.MessageBackupKey as LibSignalMessageBa
/**
* Safe typing around a backup key, which is a 32-byte array.
* This key is derived from the master key.
* This key is derived from the AEP.
*/
class MessageBackupKey(override val value: ByteArray) : BackupKey {
init {