mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-18 21:10:02 +03:00
cleaning
This commit is contained in:
parent
ce63332a2f
commit
36c5566b07
3 changed files with 34 additions and 8 deletions
|
@ -38,7 +38,7 @@ internal data class MessageVerificationStartContent(
|
||||||
) : VerificationInfoStart {
|
) : VerificationInfoStart {
|
||||||
|
|
||||||
override fun toCanonicalJson(): String? {
|
override fun toCanonicalJson(): String? {
|
||||||
return JsonCanonicalizer.getCanonicalJson(MessageVerificationStartContent::class.java, this)
|
return JsonCanonicalizer.getCanonicalJson(MessageVerificationStartContent::class.java, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val transactionID: String?
|
override val transactionID: String?
|
||||||
|
@ -46,9 +46,14 @@ internal data class MessageVerificationStartContent(
|
||||||
|
|
||||||
override fun isValid(): Boolean {
|
override fun isValid(): Boolean {
|
||||||
if (
|
if (
|
||||||
(transactionID.isNullOrBlank() || fromDevice.isNullOrBlank() || method != KeyVerificationStart.VERIF_METHOD_SAS || keyAgreementProtocols.isNullOrEmpty() || hashes.isNullOrEmpty())
|
(transactionID.isNullOrBlank()
|
||||||
|
|| fromDevice.isNullOrBlank()
|
||||||
|
|| method != KeyVerificationStart.VERIF_METHOD_SAS
|
||||||
|
|| keyAgreementProtocols.isNullOrEmpty()
|
||||||
|
|| hashes.isNullOrEmpty())
|
||||||
|| !hashes.contains("sha256") || messageAuthenticationCodes.isNullOrEmpty()
|
|| !hashes.contains("sha256") || messageAuthenticationCodes.isNullOrEmpty()
|
||||||
|| (!messageAuthenticationCodes.contains(SASVerificationTransaction.SAS_MAC_SHA256) && !messageAuthenticationCodes.contains(SASVerificationTransaction.SAS_MAC_SHA256_LONGKDF))
|
|| (!messageAuthenticationCodes.contains(SASVerificationTransaction.SAS_MAC_SHA256)
|
||||||
|
&& !messageAuthenticationCodes.contains(SASVerificationTransaction.SAS_MAC_SHA256_LONGKDF))
|
||||||
|| shortAuthenticationStrings.isNullOrEmpty()
|
|| shortAuthenticationStrings.isNullOrEmpty()
|
||||||
|| !shortAuthenticationStrings.contains(SasMode.DECIMAL)) {
|
|| !shortAuthenticationStrings.contains(SasMode.DECIMAL)) {
|
||||||
Timber.e("## received invalid verification request")
|
Timber.e("## received invalid verification request")
|
||||||
|
@ -57,5 +62,5 @@ internal data class MessageVerificationStartContent(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toEventContent() = this.toContent()
|
override fun toEventContent() = this.toContent()
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,11 @@ internal class SasTransportRoomMessage(
|
||||||
private val taskExecutor: TaskExecutor
|
private val taskExecutor: TaskExecutor
|
||||||
) : SasTransport {
|
) : SasTransport {
|
||||||
|
|
||||||
override fun sendToOther(type: String, verificationInfo: VerificationInfo, nextState: SasVerificationTxState, onErrorReason: CancelCode, onDone: (() -> Unit)?) {
|
override fun sendToOther(type: String,
|
||||||
|
verificationInfo: VerificationInfo,
|
||||||
|
nextState: SasVerificationTxState,
|
||||||
|
onErrorReason: CancelCode,
|
||||||
|
onDone: (() -> Unit)?) {
|
||||||
Timber.d("## SAS sending msg type $type")
|
Timber.d("## SAS sending msg type $type")
|
||||||
Timber.v("## SAS sending msg info $verificationInfo")
|
Timber.v("## SAS sending msg info $verificationInfo")
|
||||||
sendVerificationMessageTask.configureWith(
|
sendVerificationMessageTask.configureWith(
|
||||||
|
@ -109,7 +113,14 @@ internal class SasTransportRoomMessage(
|
||||||
commitment: String,
|
commitment: String,
|
||||||
messageAuthenticationCode: String,
|
messageAuthenticationCode: String,
|
||||||
shortAuthenticationStrings: List<String>)
|
shortAuthenticationStrings: List<String>)
|
||||||
: VerificationInfoAccept = MessageVerificationAcceptContent.create(tid, keyAgreementProtocol, hash, commitment, messageAuthenticationCode, shortAuthenticationStrings)
|
: VerificationInfoAccept = MessageVerificationAcceptContent.create(
|
||||||
|
tid,
|
||||||
|
keyAgreementProtocol,
|
||||||
|
hash,
|
||||||
|
commitment,
|
||||||
|
messageAuthenticationCode,
|
||||||
|
shortAuthenticationStrings
|
||||||
|
)
|
||||||
|
|
||||||
override fun createKey(tid: String, pubKey: String): VerificationInfoKey = MessageVerificationKeyContent.create(tid, pubKey)
|
override fun createKey(tid: String, pubKey: String): VerificationInfoKey = MessageVerificationKeyContent.create(tid, pubKey)
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,11 @@ internal class SasTransportToDevice(
|
||||||
private var taskExecutor: TaskExecutor
|
private var taskExecutor: TaskExecutor
|
||||||
) : SasTransport {
|
) : SasTransport {
|
||||||
|
|
||||||
override fun sendToOther(type: String, verificationInfo: VerificationInfo, nextState: SasVerificationTxState, onErrorReason: CancelCode, onDone: (() -> Unit)?) {
|
override fun sendToOther(type: String,
|
||||||
|
verificationInfo: VerificationInfo,
|
||||||
|
nextState: SasVerificationTxState,
|
||||||
|
onErrorReason: CancelCode,
|
||||||
|
onDone: (() -> Unit)?) {
|
||||||
Timber.d("## SAS sending msg type $type")
|
Timber.d("## SAS sending msg type $type")
|
||||||
Timber.v("## SAS sending msg info $verificationInfo")
|
Timber.v("## SAS sending msg info $verificationInfo")
|
||||||
val tx = tx ?: return
|
val tx = tx ?: return
|
||||||
|
@ -98,7 +102,13 @@ internal class SasTransportToDevice(
|
||||||
commitment: String,
|
commitment: String,
|
||||||
messageAuthenticationCode: String,
|
messageAuthenticationCode: String,
|
||||||
shortAuthenticationStrings: List<String>)
|
shortAuthenticationStrings: List<String>)
|
||||||
: VerificationInfoAccept = KeyVerificationAccept.create(tid, keyAgreementProtocol, hash, commitment, messageAuthenticationCode, shortAuthenticationStrings)
|
: VerificationInfoAccept = KeyVerificationAccept.create(
|
||||||
|
tid,
|
||||||
|
keyAgreementProtocol,
|
||||||
|
hash,
|
||||||
|
commitment,
|
||||||
|
messageAuthenticationCode,
|
||||||
|
shortAuthenticationStrings)
|
||||||
|
|
||||||
override fun createKey(tid: String, pubKey: String): VerificationInfoKey = KeyVerificationKey.create(tid, pubKey)
|
override fun createKey(tid: String, pubKey: String): VerificationInfoKey = KeyVerificationKey.create(tid, pubKey)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue