Fix / ensure keys trust is updated before checking devices

This commit is contained in:
Valere 2020-03-23 19:15:29 +01:00
parent 6cc8d1b205
commit 3b62402cfe
1 changed files with 35 additions and 16 deletions

View File

@ -770,6 +770,27 @@ internal class DefaultCrossSigningService @Inject constructor(
setUserKeysAsTrusted(otherUserId, it.isVerified()) setUserKeysAsTrusted(otherUserId, it.isVerified())
} }
// // TODO if my keys have changes, i should recheck all devices of all users?
// val devices = cryptoStore.getUserDeviceList(otherUserId)
// devices?.forEach { device ->
// val updatedTrust = checkDeviceTrust(otherUserId, device.deviceId, device.trustLevel?.isLocallyVerified() ?: false)
// Timber.v("## CrossSigning - update trust for device ${device.deviceId} of user $otherUserId , verified=$updatedTrust")
// cryptoStore.setDeviceTrust(otherUserId, device.deviceId, updatedTrust.isCrossSignedVerified(), updatedTrust.isLocallyVerified())
// }
//
// if (otherUserId == userId) {
// // It's me, i should check if a newly trusted device is signing my master key
// // In this case it will change my MSK trust, and should then re-trigger a check of all other user trust
// setUserKeysAsTrusted(otherUserId, checkSelfTrust().isVerified())
// }
}
// eventBus.post(CryptoToSessionUserTrustChange(userIds))
}
// now check device trust
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
userIds.forEach { otherUserId ->
// TODO if my keys have changes, i should recheck all devices of all users? // TODO if my keys have changes, i should recheck all devices of all users?
val devices = cryptoStore.getUserDeviceList(otherUserId) val devices = cryptoStore.getUserDeviceList(otherUserId)
devices?.forEach { device -> devices?.forEach { device ->
@ -790,7 +811,6 @@ internal class DefaultCrossSigningService @Inject constructor(
} }
private fun setUserKeysAsTrusted(otherUserId: String, trusted: Boolean) { private fun setUserKeysAsTrusted(otherUserId: String, trusted: Boolean) {
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
val currentTrust = cryptoStore.getCrossSigningInfo(otherUserId)?.isTrusted() val currentTrust = cryptoStore.getCrossSigningInfo(otherUserId)?.isTrusted()
cryptoStore.setUserKeysAsTrusted(otherUserId, trusted) cryptoStore.setUserKeysAsTrusted(otherUserId, trusted)
// If it's me, recheck trust of all users and devices? // If it's me, recheck trust of all users and devices?
@ -811,7 +831,6 @@ internal class DefaultCrossSigningService @Inject constructor(
} }
} }
} }
}
// private fun reRequestAllPendingRoomKeyRequest() { // private fun reRequestAllPendingRoomKeyRequest() {
// cryptoCoroutineScope.launch(coroutineDispatchers.crypto) { // cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {