Fix / sign current device after entering xsigning passphrase
This commit is contained in:
parent
030f027516
commit
d537abc522
|
@ -138,7 +138,7 @@ class XSigningTest : InstrumentedTest {
|
||||||
|
|
||||||
// Manually mark it as trusted from first session
|
// Manually mark it as trusted from first session
|
||||||
mTestHelper.doSync<Unit> {
|
mTestHelper.doSync<Unit> {
|
||||||
bobSession.cryptoService().crossSigningService().signDevice(bobSecondDeviceId, it)
|
bobSession.cryptoService().crossSigningService().trustDevice(bobSecondDeviceId, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now alice should cross trust bob's second device
|
// Now alice should cross trust bob's second device
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package im.vector.matrix.android.api.extensions
|
package im.vector.matrix.android.api.extensions
|
||||||
|
|
||||||
import im.vector.matrix.android.api.comparators.DatedObjectComparators
|
|
||||||
import im.vector.matrix.android.internal.crypto.model.CryptoDeviceInfo
|
import im.vector.matrix.android.internal.crypto.model.CryptoDeviceInfo
|
||||||
import im.vector.matrix.android.internal.crypto.model.rest.DeviceInfo
|
import im.vector.matrix.android.internal.crypto.model.rest.DeviceInfo
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ interface CrossSigningService {
|
||||||
/**
|
/**
|
||||||
* Sign one of your devices and upload the signature
|
* Sign one of your devices and upload the signature
|
||||||
*/
|
*/
|
||||||
fun signDevice(deviceId: String,
|
fun trustDevice(deviceId: String,
|
||||||
callback: MatrixCallback<Unit>)
|
callback: MatrixCallback<Unit>)
|
||||||
|
|
||||||
fun checkDeviceTrust(otherUserId: String,
|
fun checkDeviceTrust(otherUserId: String,
|
||||||
|
|
|
@ -587,7 +587,7 @@ internal class DefaultCrossSigningService @Inject constructor(
|
||||||
checkSelfTrust()
|
checkSelfTrust()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun signDevice(deviceId: String, callback: MatrixCallback<Unit>) {
|
override fun trustDevice(deviceId: String, callback: MatrixCallback<Unit>) {
|
||||||
// This device should be yours
|
// This device should be yours
|
||||||
val device = cryptoStore.getUserDevice(userId, deviceId)
|
val device = cryptoStore.getUserDevice(userId, deviceId)
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
|
|
|
@ -312,7 +312,7 @@ internal abstract class SASDefaultVerificationTransaction(
|
||||||
if (otherUserId == userId) {
|
if (otherUserId == userId) {
|
||||||
// If me it's reasonable to sign and upload the device signature
|
// If me it's reasonable to sign and upload the device signature
|
||||||
// Notice that i might not have the private keys, so may not be able to do it
|
// Notice that i might not have the private keys, so may not be able to do it
|
||||||
crossSigningService.signDevice(otherDeviceId!!, object : MatrixCallback<Unit> {
|
crossSigningService.trustDevice(otherDeviceId!!, object : MatrixCallback<Unit> {
|
||||||
override fun onFailure(failure: Throwable) {
|
override fun onFailure(failure: Throwable) {
|
||||||
Timber.w(failure, "## SAS Verification: Failed to sign new device $otherDeviceId")
|
Timber.w(failure, "## SAS Verification: Failed to sign new device $otherDeviceId")
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ internal class DefaultQrCodeVerificationTransaction(
|
||||||
if (otherUserId == userId) {
|
if (otherUserId == userId) {
|
||||||
// If me it's reasonable to sign and upload the device signature
|
// If me it's reasonable to sign and upload the device signature
|
||||||
// Notice that i might not have the private keys, so may not be able to do it
|
// Notice that i might not have the private keys, so may not be able to do it
|
||||||
crossSigningService.signDevice(otherDeviceId!!, object : MatrixCallback<Unit> {
|
crossSigningService.trustDevice(otherDeviceId!!, object : MatrixCallback<Unit> {
|
||||||
override fun onFailure(failure: Throwable) {
|
override fun onFailure(failure: Throwable) {
|
||||||
Timber.w(failure, "## QR Verification: Failed to sign new device $otherDeviceId")
|
Timber.w(failure, "## QR Verification: Failed to sign new device $otherDeviceId")
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ import im.vector.matrix.android.internal.crypto.crosssigning.isVerified
|
||||||
import im.vector.matrix.android.internal.crypto.verification.PendingVerificationRequest
|
import im.vector.matrix.android.internal.crypto.verification.PendingVerificationRequest
|
||||||
import im.vector.riotx.core.extensions.exhaustive
|
import im.vector.riotx.core.extensions.exhaustive
|
||||||
import im.vector.riotx.core.platform.VectorViewModel
|
import im.vector.riotx.core.platform.VectorViewModel
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
data class VerificationBottomSheetViewState(
|
data class VerificationBottomSheetViewState(
|
||||||
val otherUserMxItem: MatrixItem? = null,
|
val otherUserMxItem: MatrixItem? = null,
|
||||||
|
@ -272,6 +273,16 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||||
res?.get(SELF_SIGNING_KEY_SSSS_NAME)
|
res?.get(SELF_SIGNING_KEY_SSSS_NAME)
|
||||||
)
|
)
|
||||||
if (trustResult.isVerified()) {
|
if (trustResult.isVerified()) {
|
||||||
|
// Sign this device and upload the signature
|
||||||
|
session.sessionParams.credentials.deviceId?.let { deviceId ->
|
||||||
|
session.cryptoService()
|
||||||
|
.crossSigningService().trustDevice(deviceId, object : MatrixCallback<Unit> {
|
||||||
|
override fun onFailure(failure: Throwable) {
|
||||||
|
Timber.w("Failed to sign my device after recovery", failure)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
setState {
|
setState {
|
||||||
copy(verifiedFromPrivateKeys = true)
|
copy(verifiedFromPrivateKeys = true)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue