mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 03:05:26 +00:00
Initial test implementation of SVR3.
This commit is contained in:
committed by
Nicholas Tinsley
parent
68ced18ea1
commit
f570f1f2c4
@@ -138,7 +138,7 @@ fun SvrPlaygroundScreenDarkTheme() {
|
||||
Surface {
|
||||
SvrPlaygroundScreen(
|
||||
state = InternalSvrPlaygroundState(
|
||||
options = persistentListOf(SvrImplementation.SVR2)
|
||||
options = persistentListOf(SvrImplementation.SVR2, SvrImplementation.SVR3)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -13,5 +13,6 @@ data class InternalSvrPlaygroundState(
|
||||
enum class SvrImplementation(
|
||||
val title: String
|
||||
) {
|
||||
SVR2("SVR2")
|
||||
SVR2("SVR2"),
|
||||
SVR3("SVR3")
|
||||
}
|
||||
|
||||
@@ -19,12 +19,13 @@ import org.thoughtcrime.securesms.BuildConfig
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.whispersystems.signalservice.api.svr.SecureValueRecovery
|
||||
import org.whispersystems.signalservice.api.svr.SecureValueRecoveryV3
|
||||
|
||||
class InternalSvrPlaygroundViewModel : ViewModel() {
|
||||
|
||||
private val _state: MutableState<InternalSvrPlaygroundState> = mutableStateOf(
|
||||
InternalSvrPlaygroundState(
|
||||
options = persistentListOf(SvrImplementation.SVR2)
|
||||
options = persistentListOf(SvrImplementation.SVR2, SvrImplementation.SVR3)
|
||||
)
|
||||
)
|
||||
val state: State<InternalSvrPlaygroundState> = _state
|
||||
@@ -104,6 +105,22 @@ class InternalSvrPlaygroundViewModel : ViewModel() {
|
||||
private fun SvrImplementation.toImplementation(): SecureValueRecovery {
|
||||
return when (this) {
|
||||
SvrImplementation.SVR2 -> ApplicationDependencies.getSignalServiceAccountManager().getSecureValueRecoveryV2(BuildConfig.SVR2_MRENCLAVE)
|
||||
SvrImplementation.SVR3 -> ApplicationDependencies.getSignalServiceAccountManager().getSecureValueRecoveryV3(ApplicationDependencies.getLibsignalNetwork().network, TestShareSetStorage())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary implementation of share set storage. Only useful for testing.
|
||||
*/
|
||||
private class TestShareSetStorage : SecureValueRecoveryV3.ShareSetStorage {
|
||||
private var shareSet: ByteArray? = null
|
||||
|
||||
override fun write(data: ByteArray) {
|
||||
shareSet = data
|
||||
}
|
||||
|
||||
override fun read(): ByteArray? {
|
||||
return shareSet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user