Skip to content

Commit 0d22b21

Browse files
Add logs
1 parent 9f245c4 commit 0d22b21

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,9 @@ internal class DefaultCryptoService @Inject constructor(
13941394
)
13951395
}?.filter { inboundGroupSession ->
13961396
// Prevent injecting a forged encrypted message and using session_id/sender_key of another room.
1397-
inboundGroupSession.roomId == roomId
1397+
(inboundGroupSession.roomId == roomId).also {
1398+
Timber.tag(loggerTag.value).d("Forged encrypted message detected for roomId:$roomId")
1399+
}
13981400
}?.forEach { inboundGroupSession ->
13991401
// Share the sharable session to userId with deviceId
14001402
val exportedKeys = inboundGroupSession.exportKeys(sharedHistory = true)

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmEncryption.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ internal class MXMegolmEncryption(
148148
"ed25519" to olmDevice.deviceEd25519Key!!
149149
)
150150

151-
olmDevice.addInboundGroupSession(sessionId!!, olmDevice.getSessionKey(sessionId)!!, roomId, olmDevice.deviceCurve25519Key!!,
152-
emptyList(), keysClaimedMap, false)
151+
olmDevice.addInboundGroupSession(
152+
sessionId!!, olmDevice.getSessionKey(sessionId)!!, roomId, olmDevice.deviceCurve25519Key!!,
153+
emptyList(), keysClaimedMap, false
154+
)
153155

154156
defaultKeysBackupService.maybeBackupKeys()
155157

@@ -168,7 +170,11 @@ internal class MXMegolmEncryption(
168170
// Need to make a brand new session?
169171
session.needsRotation(sessionRotationPeriodMsgs, sessionRotationPeriodMs) ||
170172
// Is there a room history visibility change since the last outboundSession
171-
cryptoStore.needsRotationDueToVisibilityChange(roomId) ||
173+
cryptoStore.needsRotationDueToVisibilityChange(roomId).also {
174+
if (it) {
175+
Timber.tag(loggerTag.value).d("roomId:$roomId Room history visibility change detected since the last outbound session")
176+
}
177+
} ||
172178
// Determine if we have shared with anyone we shouldn't have
173179
session.sharedWithTooManyDevices(devicesInRoom)) {
174180
Timber.tag(loggerTag.value).d("roomId:$roomId Starting new megolm session because we need to rotate.")
@@ -336,7 +342,8 @@ internal class MXMegolmEncryption(
336342
senderKey: String?,
337343
code: WithHeldCode) {
338344
Timber.tag(loggerTag.value).d("notifyKeyWithHeld() :sending withheld for session:$sessionId and code $code to" +
339-
" ${targets.joinToString { "${it.userId}|${it.deviceId}" }}")
345+
" ${targets.joinToString { "${it.userId}|${it.deviceId}" }}"
346+
)
340347
val withHeldContent = RoomKeyWithHeldContent(
341348
roomId = roomId,
342349
senderKey = senderKey,

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/DefaultMembershipService.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import org.matrix.android.sdk.internal.session.room.membership.admin.MembershipA
4343
import org.matrix.android.sdk.internal.session.room.membership.joining.InviteTask
4444
import org.matrix.android.sdk.internal.session.room.membership.threepid.InviteThreePidTask
4545
import org.matrix.android.sdk.internal.util.fetchCopied
46-
import timber.log.Timber
4746

4847
internal class DefaultMembershipService @AssistedInject constructor(
4948
@Assisted private val roomId: String,

0 commit comments

Comments
 (0)