Skip to content

Conversation

@DelmoreCooper
Copy link
Contributor

No description provided.

return realm.where<SharedSessionEntity>()
.equalTo(SharedSessionEntityFields.ROOM_ID, roomId)
.equalTo(SharedSessionEntityFields.SESSION_ID, sessionId)
.equalTo(SharedSessionEntityFields.ALGORITHM, MXCRYPTO_ALGORITHM_MEGOLM)
Copy link

@chzhongsending chzhongsending Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this line changed its behavior, it will return any SharedSessionEntity regardless it is a MXCRYPTO_ALGORITHM_MEGOLM or MXCRYPTO_ALGORITHM_RATCHET.

Try to add a parameter algorithm ?

return realm.where<SharedSessionEntity>()
.equalTo(SharedSessionEntityFields.ROOM_ID, roomId)
.equalTo(SharedSessionEntityFields.SESSION_ID, sessionId)
.equalTo(SharedSessionEntityFields.ALGORITHM, MXCRYPTO_ALGORITHM_MEGOLM)
Copy link

@chzhongsending chzhongsending Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above and all similar issues below.

): SharedSessionEntity {
return realm.createObject<SharedSessionEntity>().apply {
this.roomId = roomId
this.algorithm = MXCRYPTO_ALGORITHM_MEGOLM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure removing this field is OK.

return params.algorithm
?.let {
if (it != MXCRYPTO_ALGORITHM_MEGOLM) {
if (!arrayOf(MXCRYPTO_ALGORITHM_MEGOLM, MXCRYPTO_ALGORITHM_RATCHET).contains(it)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrayOf(MXCRYPTO_ALGORITHM_MEGOLM, MXCRYPTO_ALGORITHM_RATCHET) occurs multiple times, consider extract it as a const or static final

}

override suspend fun enableEncryption(algorithm: String, force: Boolean) {
val supportedAlgorithm = arrayOf(MXCRYPTO_ALGORITHM_MEGOLM, MXCRYPTO_ALGORITHM_RATCHET)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this val/var to upper level?

private const val cipherMode = "AES/CBC/PKCS7Padding" //algorithm/mode/padding

fun encrypt(key: ByteArray, cleartext: String): String {
Timber.i("AES encrypt with key: ${key.decodeToString()}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should NEVER print key to log.

}

if (isUpdated) {
Timber.v("## CRYPTO: removeCurrentGroupSession on device changed")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please confirm while isUpdated=true is equivalent to the scenarios mentioned by @auruac

@DelmoreCooper DelmoreCooper force-pushed the e2e branch 2 times, most recently from 8d4db95 to e43771d Compare April 29, 2024 12:28
Copy link

@Mazzika1 Mazzika1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

@DelmoreCooper DelmoreCooper force-pushed the e2e branch 6 times, most recently from 87711f8 to 3919a13 Compare July 17, 2024 06:54
@DelmoreCooper DelmoreCooper force-pushed the e2e branch 3 times, most recently from 88b0363 to aaa92d7 Compare July 17, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants