-
Notifications
You must be signed in to change notification settings - Fork 1
support e2e encryption #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| return realm.where<SharedSessionEntity>() | ||
| .equalTo(SharedSessionEntityFields.ROOM_ID, roomId) | ||
| .equalTo(SharedSessionEntityFields.SESSION_ID, sessionId) | ||
| .equalTo(SharedSessionEntityFields.ALGORITHM, MXCRYPTO_ALGORITHM_MEGOLM) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()}") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
1035bee to
be51a59
Compare
8d4db95 to
e43771d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
87711f8 to
3919a13
Compare
88b0363 to
aaa92d7
Compare
No description provided.