Always check master key when provided by verifying device
This commit is contained in:
parent
f297117df2
commit
a1d2944c32
@ -165,21 +165,25 @@ class Rendezvous(
|
|||||||
}
|
}
|
||||||
|
|
||||||
verificationResponse.masterKey?.let { masterKeyFromVerifyingDevice ->
|
verificationResponse.masterKey?.let { masterKeyFromVerifyingDevice ->
|
||||||
// check master key againt what the homeserver told us
|
// verifying device provided us with a master key, so use it to check integrity
|
||||||
crypto.crossSigningService().getMyCrossSigningKeys()?.masterKey()?.let { localMasterKey ->
|
|
||||||
if (localMasterKey.unpaddedBase64PublicKey != masterKeyFromVerifyingDevice) {
|
|
||||||
Timber.tag(TAG).w("Master key from verifying device doesn't match: $masterKeyFromVerifyingDevice vs $localMasterKey")
|
|
||||||
// inform the other side
|
|
||||||
send(Payload(PayloadType.FINISH, outcome = Outcome.E2EE_SECURITY_ERROR))
|
|
||||||
throw RendezvousError("Master key from verifying device doesn't match", RendezvousFailureReason.E2EESecurityIssue)
|
|
||||||
}
|
|
||||||
// set other device as verified
|
|
||||||
Timber.tag(TAG).i("Setting device $verifyingDeviceId as verified")
|
|
||||||
crypto.setDeviceVerification(DeviceTrustLevel(locallyVerified = true, crossSigningVerified = false), userId, verifyingDeviceId)
|
|
||||||
|
|
||||||
Timber.tag(TAG).i("Setting master key as trusted")
|
// see what the homeserver told us
|
||||||
crypto.crossSigningService().markMyMasterKeyAsTrusted()
|
val localMasterKey = crypto.crossSigningService().getMyCrossSigningKeys()?.masterKey()
|
||||||
} ?: Timber.tag(TAG).w("No local master key so not verifying")
|
|
||||||
|
// n.b. if no local master key this is a problem, as well as it not matching
|
||||||
|
if (localMasterKey?.unpaddedBase64PublicKey != masterKeyFromVerifyingDevice) {
|
||||||
|
Timber.tag(TAG).w("Master key from verifying device doesn't match: $masterKeyFromVerifyingDevice vs $localMasterKey")
|
||||||
|
// inform the other side
|
||||||
|
send(Payload(PayloadType.FINISH, outcome = Outcome.E2EE_SECURITY_ERROR))
|
||||||
|
throw RendezvousError("Master key from verifying device doesn't match", RendezvousFailureReason.E2EESecurityIssue)
|
||||||
|
}
|
||||||
|
|
||||||
|
// set other device as verified
|
||||||
|
Timber.tag(TAG).i("Setting device $verifyingDeviceId as verified")
|
||||||
|
crypto.setDeviceVerification(DeviceTrustLevel(locallyVerified = true, crossSigningVerified = false), userId, verifyingDeviceId)
|
||||||
|
|
||||||
|
Timber.tag(TAG).i("Setting master key as trusted")
|
||||||
|
crypto.crossSigningService().markMyMasterKeyAsTrusted()
|
||||||
} ?: run {
|
} ?: run {
|
||||||
// set other device as verified anyway
|
// set other device as verified anyway
|
||||||
Timber.tag(TAG).i("Setting device $verifyingDeviceId as verified")
|
Timber.tag(TAG).i("Setting device $verifyingDeviceId as verified")
|
||||||
|
Loading…
Reference in New Issue
Block a user