forked from GitHub-Mirror/riotX-android
SAS Tested
This commit is contained in:
@ -61,7 +61,7 @@ internal class MXOlmDevice(
|
||||
// They are not stored in 'store' to avoid to remember to which devices we sent the session key.
|
||||
// Plus, in cryptography, it is good to refresh sessions from time to time.
|
||||
// The key is the session id, the value the outbound group session.
|
||||
private val mOutboundGroupSessionStore: MutableMap<String, OlmOutboundGroupSession>
|
||||
private val mOutboundGroupSessionStore: MutableMap<String, OlmOutboundGroupSession> = HashMap()
|
||||
|
||||
// Store a set of decrypted message indexes for each group session.
|
||||
// This partially mitigates a replay attack where a MITM resends a group
|
||||
@ -75,7 +75,7 @@ internal class MXOlmDevice(
|
||||
// The first level keys are timeline ids.
|
||||
// The second level keys are strings of form "<senderKey>|<session_id>|<message_index>"
|
||||
// Values are true.
|
||||
private val mInboundGroupSessionMessageIndexes: MutableMap<String, MutableMap<String, Boolean>>
|
||||
private val mInboundGroupSessionMessageIndexes: MutableMap<String, MutableMap<String, Boolean>> = HashMap()
|
||||
|
||||
/**
|
||||
* inboundGroupSessionWithId error
|
||||
@ -107,8 +107,6 @@ internal class MXOlmDevice(
|
||||
mOlmUtility = null
|
||||
}
|
||||
|
||||
mOutboundGroupSessionStore = HashMap()
|
||||
|
||||
try {
|
||||
deviceCurve25519Key = mOlmAccount!!.identityKeys()[OlmAccount.JSON_KEY_IDENTITY_KEY]
|
||||
} catch (e: Exception) {
|
||||
@ -120,8 +118,6 @@ internal class MXOlmDevice(
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "## MXOlmDevice : cannot find " + OlmAccount.JSON_KEY_FINGER_PRINT_KEY + " with error")
|
||||
}
|
||||
|
||||
mInboundGroupSessionMessageIndexes = HashMap()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@
|
||||
package im.vector.matrix.android.internal.crypto.model.rest
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import im.vector.matrix.android.api.session.crypto.sas.SasMode
|
||||
import im.vector.matrix.android.internal.crypto.verification.SASVerificationTransaction
|
||||
import timber.log.Timber
|
||||
@ -23,6 +24,7 @@ import timber.log.Timber
|
||||
/**
|
||||
* Sent by Alice to initiate an interactive key verification.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
class KeyVerificationStart : SendToDeviceObject {
|
||||
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ internal class DefaultSasVerificationService(private val mCredentials: Credentia
|
||||
|
||||
// Event received from the sync
|
||||
fun onToDeviceEvent(event: Event) {
|
||||
CryptoAsyncHelper.getDecryptBackgroundHandler().post {
|
||||
CryptoAsyncHelper.getDecryptBackgroundHandler().post { // TODO We are already in a BG thread
|
||||
when (event.type) {
|
||||
EventType.KEY_VERIFICATION_START -> {
|
||||
onStartRequestReceived(event)
|
||||
@ -226,10 +226,10 @@ internal class DefaultSasVerificationService(private val mCredentials: Credentia
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSuccess(info: MXUsersDevicesMap<MXDeviceInfo>) {
|
||||
override fun onSuccess(data: MXUsersDevicesMap<MXDeviceInfo>) {
|
||||
CryptoAsyncHelper.getDecryptBackgroundHandler().post {
|
||||
if (info.getUserDeviceIds(otherUserId).contains(startReq.fromDevice)) {
|
||||
success(info)
|
||||
if (data.getUserDeviceIds(otherUserId).contains(startReq.fromDevice)) {
|
||||
success(data)
|
||||
} else {
|
||||
error()
|
||||
}
|
||||
|
@ -38,8 +38,9 @@ internal class IncomingSASVerificationTransaction(
|
||||
private val mCredentials: Credentials,
|
||||
private val mCryptoStore: IMXCryptoStore,
|
||||
private val mSendToDeviceTask: SendToDeviceTask,
|
||||
private val mTaskExecutor: TaskExecutor, transactionId: String,
|
||||
private val mTaskExecutor: TaskExecutor,
|
||||
deviceFingerprint: String,
|
||||
transactionId: String,
|
||||
otherUserID: String)
|
||||
: SASVerificationTransaction(
|
||||
mSasVerificationService,
|
||||
|
@ -24,11 +24,11 @@ import im.vector.matrix.android.api.session.crypto.sas.SasMode
|
||||
import im.vector.matrix.android.api.session.crypto.sas.SasVerificationTxState
|
||||
import im.vector.matrix.android.api.session.events.model.EventType
|
||||
import im.vector.matrix.android.internal.crypto.CryptoAsyncHelper
|
||||
import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore
|
||||
import im.vector.matrix.android.internal.crypto.model.MXDeviceInfo
|
||||
import im.vector.matrix.android.internal.crypto.model.MXKey
|
||||
import im.vector.matrix.android.internal.crypto.model.MXUsersDevicesMap
|
||||
import im.vector.matrix.android.internal.crypto.model.rest.*
|
||||
import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore
|
||||
import im.vector.matrix.android.internal.crypto.tasks.SendToDeviceTask
|
||||
import im.vector.matrix.android.internal.task.TaskExecutor
|
||||
import im.vector.matrix.android.internal.task.configureWith
|
||||
@ -182,7 +182,7 @@ internal abstract class SASVerificationTransaction(
|
||||
is KeyVerificationAccept -> onVerificationAccept(event)
|
||||
is KeyVerificationKey -> onKeyVerificationKey(senderId, event)
|
||||
is KeyVerificationMac -> onKeyVerificationMac(event)
|
||||
else -> {
|
||||
else -> {
|
||||
//nop
|
||||
}
|
||||
}
|
||||
@ -323,11 +323,11 @@ internal abstract class SASVerificationTransaction(
|
||||
if (shortCodeBytes!!.size < 5) return null
|
||||
return getDecimalCodeRepresentation(shortCodeBytes!!)
|
||||
}
|
||||
SasMode.EMOJI -> {
|
||||
SasMode.EMOJI -> {
|
||||
if (shortCodeBytes!!.size < 6) return null
|
||||
return getEmojiCodeRepresentation(shortCodeBytes!!).joinToString(" ") { it.emoji }
|
||||
}
|
||||
else -> return null
|
||||
else -> return null
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user