Code cleanup
This commit is contained in:
parent
b3f887ca28
commit
4634b963a2
@ -77,26 +77,24 @@ internal class DefaultQrCodeVerificationTransaction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check master key
|
// check master key
|
||||||
|
val myMasterKey = crossSigningService.getUserCrossSigningKeys(userId)?.masterKey()?.unpaddedBase64PublicKey
|
||||||
when (otherQrCodeData) {
|
when (otherQrCodeData) {
|
||||||
is QrCodeData.VerifyingAnotherUser -> {
|
is QrCodeData.VerifyingAnotherUser -> {
|
||||||
if (otherQrCodeData.otherUserMasterCrossSigningPublicKey
|
if (otherQrCodeData.otherUserMasterCrossSigningPublicKey != myMasterKey) {
|
||||||
!= crossSigningService.getUserCrossSigningKeys(userId)?.masterKey()?.unpaddedBase64PublicKey) {
|
|
||||||
Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.otherUserMasterCrossSigningPublicKey}")
|
Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.otherUserMasterCrossSigningPublicKey}")
|
||||||
cancel(CancelCode.MismatchedKeys)
|
cancel(CancelCode.MismatchedKeys)
|
||||||
return
|
return
|
||||||
} else Unit
|
} else Unit
|
||||||
}
|
}
|
||||||
is QrCodeData.SelfVerifyingMasterKeyTrusted -> {
|
is QrCodeData.SelfVerifyingMasterKeyTrusted -> {
|
||||||
if (otherQrCodeData.userMasterCrossSigningPublicKey
|
if (otherQrCodeData.userMasterCrossSigningPublicKey != myMasterKey) {
|
||||||
!= crossSigningService.getUserCrossSigningKeys(userId)?.masterKey()?.unpaddedBase64PublicKey) {
|
|
||||||
Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.userMasterCrossSigningPublicKey}")
|
Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.userMasterCrossSigningPublicKey}")
|
||||||
cancel(CancelCode.MismatchedKeys)
|
cancel(CancelCode.MismatchedKeys)
|
||||||
return
|
return
|
||||||
} else Unit
|
} else Unit
|
||||||
}
|
}
|
||||||
is QrCodeData.SelfVerifyingMasterKeyNotTrusted -> {
|
is QrCodeData.SelfVerifyingMasterKeyNotTrusted -> {
|
||||||
if (otherQrCodeData.userMasterCrossSigningPublicKey
|
if (otherQrCodeData.userMasterCrossSigningPublicKey != myMasterKey) {
|
||||||
!= crossSigningService.getUserCrossSigningKeys(userId)?.masterKey()?.unpaddedBase64PublicKey) {
|
|
||||||
Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.userMasterCrossSigningPublicKey}")
|
Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.userMasterCrossSigningPublicKey}")
|
||||||
cancel(CancelCode.MismatchedKeys)
|
cancel(CancelCode.MismatchedKeys)
|
||||||
return
|
return
|
||||||
@ -156,7 +154,7 @@ internal class DefaultQrCodeVerificationTransaction(
|
|||||||
trust(canTrustOtherUserMasterKey, toVerifyDeviceIds.distinct())
|
trust(canTrustOtherUserMasterKey, toVerifyDeviceIds.distinct())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun start(remoteSecret: String) {
|
private fun start(remoteSecret: String) {
|
||||||
if (state != VerificationTxState.None) {
|
if (state != VerificationTxState.None) {
|
||||||
Timber.e("## Verification QR: start verification from invalid state")
|
Timber.e("## Verification QR: start verification from invalid state")
|
||||||
// should I cancel??
|
// should I cancel??
|
||||||
@ -219,8 +217,8 @@ internal class DefaultQrCodeVerificationTransaction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun trust(canTrustOtherUserMasterKey: Boolean, toVerifyDeviceIds: List<String>) {
|
private fun trust(canTrustOtherUserMasterKey: Boolean, toVerifyDeviceIds: List<String>) {
|
||||||
// If not me sign his MSK and upload the signature
|
|
||||||
if (canTrustOtherUserMasterKey) {
|
if (canTrustOtherUserMasterKey) {
|
||||||
|
// If not me sign his MSK and upload the signature
|
||||||
if (otherUserId != userId) {
|
if (otherUserId != userId) {
|
||||||
// we should trust this master key
|
// we should trust this master key
|
||||||
// And check verification MSK -> SSK?
|
// And check verification MSK -> SSK?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user