mirror of
https://github.com/vector-im/riotX-android
synced 2025-10-06 00:02:48 +02:00
Reduce complexity of function
This commit is contained in:
committed by
yostyle
parent
8e416cdaee
commit
fb3b8aabf6
@@ -234,12 +234,22 @@ class Rendezvous(
|
|||||||
if (verificationResponse?.outcome == Outcome.VERIFIED || verificationResponse?.type == PayloadType.VERIFIED) {
|
if (verificationResponse?.outcome == Outcome.VERIFIED || verificationResponse?.type == PayloadType.VERIFIED) {
|
||||||
val verifyingDeviceId = verificationResponse.verifyingDeviceId
|
val verifyingDeviceId = verificationResponse.verifyingDeviceId
|
||||||
?: throw RendezvousError("No verifying device id returned", RendezvousFailureReason.ProtocolError)
|
?: throw RendezvousError("No verifying device id returned", RendezvousFailureReason.ProtocolError)
|
||||||
|
handleVerification(session, verifyingDeviceId, verificationResponse.verifyingDeviceKey, verificationResponse.masterKey)
|
||||||
|
} else {
|
||||||
|
Timber.tag(TAG).i("Not doing verification")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(RendezvousError::class)
|
||||||
|
private suspend fun handleVerification(session: Session, verifyingDeviceId: String, verifyingDeviceKey: String?, masterKey: String?) {
|
||||||
|
var crypto = session.cryptoService()
|
||||||
|
var userId = session.myUserId
|
||||||
val verifyingDeviceFromServer = crypto.getCryptoDeviceInfo(userId, verifyingDeviceId)
|
val verifyingDeviceFromServer = crypto.getCryptoDeviceInfo(userId, verifyingDeviceId)
|
||||||
if (verifyingDeviceFromServer?.fingerprint() != verificationResponse.verifyingDeviceKey) {
|
if (verifyingDeviceFromServer?.fingerprint() != verifyingDeviceKey) {
|
||||||
Timber.tag(TAG).w(
|
Timber.tag(TAG).w(
|
||||||
"Verifying device $verifyingDeviceId key doesn't match: ${
|
"Verifying device $verifyingDeviceId key doesn't match: ${
|
||||||
verifyingDeviceFromServer?.fingerprint()
|
verifyingDeviceFromServer?.fingerprint()
|
||||||
} vs ${verificationResponse.verifyingDeviceKey})"
|
} vs $verifyingDeviceKey)"
|
||||||
)
|
)
|
||||||
// inform the other side
|
// inform the other side
|
||||||
if (isUsingV1()) {
|
if (isUsingV1()) {
|
||||||
@@ -250,7 +260,7 @@ class Rendezvous(
|
|||||||
throw RendezvousError("Key from verifying device doesn't match", RendezvousFailureReason.E2EESecurityIssue)
|
throw RendezvousError("Key from verifying device doesn't match", RendezvousFailureReason.E2EESecurityIssue)
|
||||||
}
|
}
|
||||||
|
|
||||||
verificationResponse.masterKey?.let { masterKeyFromVerifyingDevice ->
|
masterKey?.let { masterKeyFromVerifyingDevice ->
|
||||||
// verifying device provided us with a master key, so use it to check integrity
|
// verifying device provided us with a master key, so use it to check integrity
|
||||||
|
|
||||||
// see what the homeserver told us
|
// see what the homeserver told us
|
||||||
@@ -291,9 +301,6 @@ class Rendezvous(
|
|||||||
it.requestSecret(USER_SIGNING_KEY_SSSS_NAME, verifyingDeviceId)
|
it.requestSecret(USER_SIGNING_KEY_SSSS_NAME, verifyingDeviceId)
|
||||||
it.requestSecret(KEYBACKUP_SECRET_SSSS_NAME, verifyingDeviceId)
|
it.requestSecret(KEYBACKUP_SECRET_SSSS_NAME, verifyingDeviceId)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Timber.tag(TAG).i("Not doing verification")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(RendezvousError::class)
|
@Throws(RendezvousError::class)
|
||||||
|
Reference in New Issue
Block a user