Implement OMEMO #126

Merged
PapaTutuWawa merged 163 commits from feat/omemo into master 1 month ago
Owner

Closes #132.
Closes #119.
Also improves the performance of generating Blurhash thumbnails.

  • Encrypt message stanzas
  • Encrypt to self
    • Actually encrypt to self
    • Manage trust for our own keys
  • Implement a trust manager
  • Use Explicit Message Encryption to mark messages
  • Encrypt IQ stanzas
    • Do not encrypt PubSub
  • Discover if an entity supports OMEMO
  • Make using OMEMO optional
  • Fix some UI issues
    • Make the lock symbol prettier
    • Color message bubbles if they are unencrypted but the chat is supposed to be encrypted
  • Display a chat's OMEMO fingerprints, if available
  • Allow managing one's own OMEMO devices
    • View the device's fingerprint and Conversations compatible QR code
    • Allow deleting other keys
    • Allow trusting and enabling keys
    • Allow recreating sessions
  • Encrypted file transfers
    • XEP-0448
    • Encrypt uploads
    • Decrypt downloads
  • Enable cryptography_flutter
    • Use flutter_isolate to set up Isolates that can use Method Channels
    • Or maybe do the cryptography (using the platform APIs) ourselves so that we read, encrypt/decrypt, write on the platform side
    • See here
  • Implement hash verification and generation inside the encrypt-/decryptFile methods
    • The hashes mismatched last time due to using digest.update(buffer) instead of digest.update(buffer, 0, len)
  • Implement the OMEMO device list race condition detection
  • Subscribe to interesting device lists
  • Implement managing trust from the UI
  • Fix all sent messages having an error marker
  • Clean the PubSub code
  • Allow recreating all ratchets with the Jid
  • Fix the ratchet breaking when we receive messages multiple times (Maybe a fix in omemo_dart?)
    • It may be caused by aes256CbcDecrypt throwing an exception causing the ratchet to not get restored Fixed in omemo_dart
    • It may be caused be receiving an old kex message again: The correct ratchet is replaced by one built against a new opk that the sender did not know about, thus the ratchet breaks
      • Maybe guard against this by making assumptions about the state of pn and n
      • Make omemo_dart throw an exception if that's the case. This allows Moxxy to just silently ignore those messages
    • Confirmed that this is a bug in omemo_dart 🥳. Theoretically fixed
    • How can we brute force reset the ratchets if we cannot even match the expectation?
      • Maybe keep a hash of the last kex and prevent it from happening again
  • Fix eagerly building new ratchets (Maybe caused by somehow publishing multiple ratchets with different ids?)
  • Ensure that we wait for OmemoService initialization before sending or decrypting messages
  • Fix OmemoService using shared preferences for stuff. It should use the database
  • Fix information leak when encryption fails
  • Off-thread optimization
    • Run Omemo device generation on a separate Isolate
    • Encrypt and decrypt files off-thread
  • Add Message Processing Hints
  • Error handling
    • Invalid MAC during decryption
    • Hash mismatch while verifying the file's hash
    • Contact does not support OMEMO:2
  • Allow resetting one's device
  • Add a warning indicator for non-critical issues, like a hash mismatch
  • Fix max_items sometimes not working for Publish-Options (See *1)
  • Clear the Omemo Db tables whem regenerating the device
  • Fix the problem with Stream Management
  • Cache our own devices Improvement for some time later
  • Pull filename from SFS metadata, if given
  • Fix file transfers with no hashes always showing a warning symbol
  • File Upload Notifications don't seem to work when using OMEMO
  • Maybe patch the entire logging system to log decrypted stanzas
  • Keep isDownloading and isUploading in the database
  • Remove support for SIMS in the service
  • Move blurhash generation into another isolate using compute. flutter_isolate does not have to be used since native_imaging uses ffi
    • Also scale the image down to something like 20px x 20px * w/h ratio
  • Implement regular file hashing in moxplatform
  • Rename own_keys and keys in lib/ui/bloc and lib/ui/pages to own_device and devices
  • I think sending encrypted IQs is not really working
  • Fix all tests
  • Starting an encrypted chat
    • ...results in one message that we cannot decrypt, even though the chat is fine
    • Fails to trigger the new chat on the side of the receiver (Maybe fixed by bd79a7b1a2)
  • When sending a file to multiple chats, where one is not encrypted, ask the user if they want to send the file in plaintext
    • Implement the dialog
    • In the sending selection list, indicate which chats are encrypted and which are not
  • Notify when we cannot publish out OMEMO key
  • Test initiating a chat (again)
    • When a contact publishes a new device, then we don't encrypt for it
    • The UI does not update when a new device appears
  • Fix request tracking not being cleared in xep_0030.dart in case of an error and thus an early return
  • Regenerating the device should show a spinner

*1:

I/flutter (17131): [FINEST] (TCPSocketWrapper) 2022-10-01 18:37:38.177877: <== <iq type='error' id='bfa5ce92-0313-4c13-8773-52bcaca6596a' to='*******/M-K5g7P0'><error type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>max_items: not a number</text></error></iq>
Closes #132. Closes #119. Also improves the performance of generating Blurhash thumbnails. - [x] Encrypt message stanzas - [x] Encrypt to self - [x] Actually encrypt to self - [x] Manage trust for our own keys - [x] Implement a trust manager - [x] Use Explicit Message Encryption to mark messages - [x] Encrypt IQ stanzas - Do not encrypt PubSub - [x] Discover if an entity supports OMEMO - [x] Make using OMEMO optional - [x] Fix some UI issues - [x] Make the lock symbol prettier - [x] Color message bubbles if they are unencrypted but the chat is supposed to be encrypted - [x] Display a chat's OMEMO fingerprints, if available - [x] Allow managing one's own OMEMO devices - [x] View the device's fingerprint and Conversations compatible QR code - [x] Allow deleting other keys - [x] Allow trusting and enabling keys - [x] Allow recreating sessions - [x] Encrypted file transfers - [x] XEP-0448 - [x] Encrypt uploads - [x] Decrypt downloads - [x] Enable `cryptography_flutter` - Use `flutter_isolate` to set up Isolates that can use Method Channels - Or maybe do the cryptography (using the platform APIs) ourselves so that we read, encrypt/decrypt, write on the platform side - See [here](https://github.com/hugo-pcl/native-crypto-flutter) - [x] Implement hash verification and generation inside the encrypt-/decryptFile methods - The hashes mismatched last time due to using `digest.update(buffer)` instead of `digest.update(buffer, 0, len)` - [x] Implement the OMEMO device list race condition detection - [x] Subscribe to interesting device lists - [x] Implement managing trust from the UI - [x] Fix all sent messages having an error marker - [x] Clean the PubSub code - [x] Allow recreating all ratchets with the Jid - [x] Fix the ratchet breaking when we receive messages multiple times (Maybe a fix in omemo_dart?) - ~~It may be caused by aes256CbcDecrypt throwing an exception causing the ratchet to not get restored~~ Fixed in omemo_dart - ~~It may be caused be receiving an old kex message again: The correct ratchet is replaced by one built against a new opk that the sender did not know about, thus the ratchet breaks~~ - ~~Maybe guard against this by making assumptions about the state of pn and n~~ - ~~Make omemo_dart throw an exception if that's the case. This allows Moxxy to just silently ignore those messages~~ - Confirmed that this is a bug in omemo_dart 🥳. Theoretically fixed - [x] How can we brute force reset the ratchets if we cannot even match the expectation? - Maybe keep a hash of the last kex and prevent it from happening again - [x] Fix eagerly building new ratchets (Maybe caused by somehow publishing multiple ratchets with different ids?) - [x] Ensure that we wait for OmemoService initialization before sending or decrypting messages - [x] Fix OmemoService using shared preferences for stuff. It should use the database - [x] Fix information leak when encryption fails - [x] Off-thread optimization - [x] Run Omemo device generation on a separate Isolate - [x] Encrypt and decrypt files off-thread - [x] Add Message Processing Hints - [x] Error handling - [x] Invalid MAC during decryption - [x] Hash mismatch while verifying the file's hash - [x] Contact does not support OMEMO:2 - [x] Allow resetting one's device - [x] Add a warning indicator for non-critical issues, like a hash mismatch - [x] Fix `max_items` sometimes not working for Publish-Options (See *1) - [x] Clear the Omemo Db tables whem regenerating the device - [x] Fix the problem with Stream Management - [x] ~~Cache our own devices~~ Improvement for some time later - [x] Pull filename from SFS metadata, if given - [x] Fix file transfers with no hashes always showing a warning symbol - [x] File Upload Notifications don't seem to work when using OMEMO - [x] Maybe patch the entire logging system to log decrypted stanzas - [x] Keep `isDownloading` and `isUploading` in the database - [x] Remove support for SIMS in the service - [x] Move blurhash generation into another isolate using `compute`. `flutter_isolate` does not have to be used since `native_imaging` uses ffi - [x] Also scale the image down to something like 20px x 20px * w/h ratio - [x] Implement regular file hashing in moxplatform - [x] Rename `own_keys` and `keys` in `lib/ui/bloc` and `lib/ui/pages` to `own_device` and `devices` - [x] I think sending encrypted IQs is not really working - [x] Fix all tests - [x] Starting an encrypted chat - [x] ...results in one message that we cannot decrypt, even though the chat is fine - [x] Fails to trigger the new chat on the side of the receiver (Maybe fixed by bd79a7b1a2743cc509a4877ddf1c1e9aec8efd2a) - [x] When sending a file to multiple chats, where one is not encrypted, ask the user if they want to send the file in plaintext - [x] Implement the dialog - [x] In the sending selection list, indicate which chats are encrypted and which are not - [x] Notify when we cannot publish out OMEMO key - [x] Test initiating a chat (again) - [x] When a contact publishes a new device, then we don't encrypt for it - [x] The UI does not update when a new device appears - [x] Fix request tracking not being cleared in xep_0030.dart in case of an error and thus an early return - [x] Regenerating the device should show a spinner *1: ``` I/flutter (17131): [FINEST] (TCPSocketWrapper) 2022-10-01 18:37:38.177877: <== <iq type='error' id='bfa5ce92-0313-4c13-8773-52bcaca6596a' to='*******/M-K5g7P0'><error type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>max_items: not a number</text></error></iq> ```
PapaTutuWawa added 8 commits 3 months ago
PapaTutuWawa added the
enhancement
backend/xmpp
ui
backend/service
labels 3 months ago
PapaTutuWawa added 7 commits 3 months ago
PapaTutuWawa added 2 commits 3 months ago
PapaTutuWawa added 1 commit 3 months ago
PapaTutuWawa added 8 commits 3 months ago
PapaTutuWawa added 1 commit 3 months ago
PapaTutuWawa added 1 commit 3 months ago
PapaTutuWawa added 4 commits 3 months ago
PapaTutuWawa added 1 commit 3 months ago
PapaTutuWawa added 5 commits 3 months ago
PapaTutuWawa added this to the Alpha Release 0.3.0 project 2 months ago
PapaTutuWawa added 2 commits 1 month ago
PapaTutuWawa added 1 commit 1 month ago
PapaTutuWawa added 1 commit 1 month ago
PapaTutuWawa added 1 commit 1 month ago
PapaTutuWawa added 1 commit 1 month ago
PapaTutuWawa added 1 commit 1 month ago
PapaTutuWawa added 2 commits 1 month ago
PapaTutuWawa added 3 commits 1 month ago
PapaTutuWawa added 1 commit 1 month ago
PapaTutuWawa force-pushed feat/omemo from 434ed2ff2a to a2b477a3dc 1 month ago
PapaTutuWawa changed title from WIP: Implement OMEMO to Implement OMEMO 1 month ago
PapaTutuWawa merged commit 42ebbdba6d into master 1 month ago
The pull request has been merged as 42ebbdba6d.
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: moxxy/moxxyv2#126
Loading…
There is no content yet.