Commit graph libervia-backend/sat/plugins/plugin_xep_0384.py
Author SHA1 Message Date
Syndace
8daec13fbb plugin XEP-0384: proper handling of exceptions in prepare_for_profile 2022-10-06 17:25:37 +02:00
Goffi
4b498cffe0 plugin XEP-0384: temporarily disable <iq> stanza encryption:
`<iq>` stanza encryption is implemented, but the `send` trigger doesn't catch all `iq`
stanza send (which are often sent directly with `xmlstream.send`), and some stanza
encryption may cause trouble (happened with disco on a bare jid).

It is temporarily disabled but should be reactivated before `0.9` release.
2022-10-06 16:02:05 +02:00
Goffi
7d415c705d plugin XEP-0384: expose OLDMEMO and TWOMEMO namespaces:
rel 379
2022-10-06 16:02:05 +02:00
Goffi
8444115262 plugin XEP-0384, xml_tools: avoid getItems timeout + fix empty node crash + parsing:
- use `max_items` in `getItems` calls for bundles, as otherwise some pubsub service may
  return full nodes, which may be huge is `max_items=1` is not set on the node, possibly
  resulting in timeouts.

- the plugin was crashing when TWOMEMO devices list node has no items at all. This is not
  the case anymore.

- a naive parsing method has been implemented in `xml_tools` to replace the
  serialisation/deserialisation method. This should be more efficient and will avoid
  annoying `ns0:` prefixes in XML logs.
2022-09-24 16:37:46 +02:00
Syndace
75ae8160ae plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
- support for both (modern) OMEMO under the `urn:xmpp:omemo:2` namespace and (legacy) OMEMO under the `eu.siacs.conversations.axolotl` namespace
- maintains one identity across both versions of OMEMO
- migrates data from the old plugin
- includes more features for protocol stability
- uses SCE for modern OMEMO
- fully type-checked, linted and format-checked
- added type hints to various pieces of backend code used by the plugin
- added stubs for some Twisted APIs used by the plugin under stubs/ (use `export MYPYPATH=stubs/` before running mypy)
- core (xmpp): enabled `send` trigger and made it an asyncPoint

fix 375
2022-08-23 21:06:24 +02:00
Goffi
bb3e7ffa9b core (memory/sqla), plugin XEP-0359: always add origin-id, and store:
`origin-id` is now always added to messages, and it is stored to database in the new
column instead of `extra` when present.
2022-06-17 14:15:23 +02:00
Goffi
7216345e31 plugin XEP-0384: fix typo in attribute 2022-01-25 17:06:28 +01:00
Goffi
14d00a9dda merge bookmark @ 2021-11-12 17:21:24 +01:00
Goffi
bdbf4596da plugin XEP-0384: fix encryption for user own devices:
our own jid is added automatically by OMEMO library, but during the generation of the
stanza, our list of jids was used to get the keys (and thus our own jid and devices keys
was missing).

fix 402
2021-10-22 18:46:51 +02:00
Goffi
f40dbe8604 plugin XEP-0384: fix calls outside of main thread:
`callFromThread` is used instead of `callLater` with a 0 delay, as the later is not made
to be called outside of main thread (which was resulting in huge and random delays during
calls).

fix `OmemoStorage._callMainThread` which was returning wrong Deferred due a late lambda
evaluation.
2021-09-08 17:58:48 +02:00
Goffi
bab851006f plugin XEP-0060: getItem(s), publish and (un)subscribe are now coroutines 2021-06-30 16:19:14 +02:00
Goffi
97df5f8be3 core: various changes and fixes to work with new storage and D-Bus bridge:
- fixes coroutines handling in various places
- fixes types which are not serialised by Tx DBus
- XEP-0384: call storage methods in main thread in XEP: Python OMEMO's Promise use thread
  which prevent the use of AsyncIO loop. To work around that, callLater is used to launch
  storage method in main thread. This is a temporary workaround, as Python OMEMO should
  get rid of Promise implementation and threads soon.
2021-06-03 15:21:43 +02:00
Goffi
dc86957043 date update 2021-03-19 15:45:14 +01:00
Goffi
bd94d2620d plugin XEP-0384: fixed /omemo_reset + device ID type:
- the workflow done with /omemo_reset is now using the right methods
  (encryptRatchetForwardingMessage and decryptRatchetForwardingMessage)
- fixed type error with device when calling python-omemo methods: a mix of str and int
  was leading to two caches being created, and random bugs
2020-03-30 19:59:17 +02:00
Goffi
cabaa16279 plugin XEP-0384: OMEMO trust policy:
OMEMO trust policy can now be specified. For now there are 2 policies:

- `manual`: each new device fingerprint must be explicitly trusted or not before the
  device can be used, and the message sent
- `BTBV` (Blind Trust Before Verification): each new device fingerprint is automically
  trusted, until user manually trust or not a device, in which case the behaviour becomes
  the same as for `manual` for the entity. When using the Trust UI, user can put the
  entity back to blind trust if they wish.

A message is send as feedback to user when a new device is/must be trusted, trying to
explain clearly what's happening to the user.

Devices which have been automically trusted are marked, so user can know which ones may
cause security issue.
2020-03-27 10:02:14 +01:00
Goffi
240c62903d plugin XEP-0384: added resetTrust in OmemoSession 2020-03-27 09:55:16 +01:00
Goffi
2f8902e0d6 core (memory/encryption): automatic start encryption if peer send encrypted message:
If peer sends encrypted message and we have no encryption activated, we automatically
start encryption to avoid sending plain text message when answering.

markAsEncrypted now needs the encryption algorithm namespace as mandatory argument.
2020-03-23 17:52:18 +01:00
Goffi
4ccd859b62 plugin XEP-0384: added "/omemo_reset" text command:
this command will delete all sessions with peer entity, and send empty message to trigger
a new key exchange.
2020-03-18 19:56:05 +01:00
Goffi
1faa5e82da plugin XEP-0384: use "max_items=1" for devices and bundles nodes:
- max_items = 1 is requested with publish-options when publishing the bundle or the
  devices list. If the constraint is failed, a warning will be shown, and the publication
  will be done without this option
- fixed return values when devices list is badly formed
2020-03-11 20:44:49 +01:00
Goffi
3b64263f3b core: renamed "MessageReceived" trigger to "messageReceived" for consistency. 2020-02-18 18:13:19 +01:00
Goffi
c00fe7f1e6 plugin XEP-0384: fixed exception catching on getItems 2020-01-29 18:31:47 +01:00
Goffi
a39349fe64 dates update 2020-01-29 09:50:54 +01:00
Goffi
b5af781b82 plugin XEP-0384: OMEMO for MUC implementation:
- encryption is now allowed for group chats
- when an encryption is requested for a MUC, real jids or all occupants are used to
  encrypt the message
- a cache for plain text message sent to MUC is used, because for security reason we can't
  encrypt message for our own device with OMEMO (that would prevent ratchet and break the
  prefect forward secrecy). Thus, message sent in MUC are cached for 5 min, and the
  decrypted version is used when found. We don't send immediately the plain text message
  to frontends and history because we want to keep the same MUC behaviour as for plain
  text, and receiving a message means that it was received and sent back by MUC service
- <origin-id> is used to identify messages sent by our device
- a feedback_jid is now use to use correct entity for feedback message in case of problem:
  with a room we have to send feedback message to the room and not the the emitter
- encryptMessage now only accepts list in the renamed "entity_bare_jids" argument
2019-12-30 20:59:46 +01:00
Goffi
bca7453ee1 plugin XEP-0384: typo 2019-12-20 14:26:05 +01:00
Goffi
a300181a01 plugin XEP-0384: update to latest python-omemo + better trust management:
- python-omemo minimal version is now 0.11.0
- `undecided` devices are now handled, fixing the "accept all or none" issue: if a device
  is `undecided`, the trust manager will be shown with the missing devices before sending
  the message.
- `untrusted` devices are discarded
2019-12-20 12:28:01 +01:00
Goffi
ad1ec9698c plugin XEP-0384: specific warning on missing omemo-backend-signal + fixed encoding following Python 3 port 2019-12-07 11:30:56 +01:00
Goffi
fbfe96c505 Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time

This patch port backend, bridge and frontends to Python 3.

Roughly this has been done this way:

- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
  to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
2019-08-13 19:08:41 +02:00
Goffi
74bc166b88 plugin XEP-0384: wait for client to be ready if session is missing when onNewDevices is called 2019-04-28 08:55:07 +02:00
Goffi
0fbde67f2a plugin XEP-0384: handle NoEligibleDevicesException 2019-03-20 09:08:47 +01:00
Goffi
e89135b8ae plugin XEP-0384: give feedback to client when encryption failed 2019-03-20 09:08:47 +01:00
Goffi
71144d4581 plugin XEP-0384: small refactoring to encrypt messages + bugfix:
encryptMessage is now called in a loop, because problems may happen by steps (e.g. trust issue after getting missing bundles).
Fixed a mix between "if" and "elif" in problems handling,
2019-03-20 09:08:47 +01:00
Goffi
ace2f57027 plugin XEP-0384: removed version restriction, it is now compatible with (and require) last version of python-omemo (0.10.4) 2019-03-20 09:08:37 +01:00
Goffi
c6d26678ae plugin XEP-0384: removed _purgeOldData temporary hack, it should not be useful anymore 2019-03-01 12:17:34 +01:00
Goffi
e8e8881016 plugin XEP-0384: better bundle handling + misc improvments
- public bundles are now retrieved only when needed (i.e. on MissingBundleException when encrypting a message)
- a feedback is given to user when a message is received but it has not been encrypted for our device
- fixed feedback on decryption error if message come from an other device of the client (i.e. it's a carbon copy)
- setBundle if called in a "finally" if republish_bundle is set after decrypting a message
2019-02-28 18:57:26 +01:00
Goffi
8e338bf913 date update 2019-01-12 12:25:31 +01:00
Goffi
70253cd205 plugin XEP-0384: give feedback to user when trust must be handled before sending a message 2019-01-05 14:15:11 +01:00
Goffi
7e5a2f59cf plugin XEP-0380, XEP-0384: use C.EXTRA_INFO_DECR_ERR as info sub-type when a message can't be decrypted. 2019-01-04 18:47:56 +01:00
Goffi
a93bf01800 plugin XEP-0380: Explicit Message Encryption implementation 2019-01-04 11:14:53 +01:00
Goffi
30081bba79 plugin XEP-0384: don't ignore StanzaError if it's not item-not-found 2019-01-04 09:20:32 +01:00
Goffi
6a64556fd2 plugin XEP-0384: various bug fixes:
- fixed trust management on message sending, when trusts are missing
- retrieve identiy keys when trust has not been set yet
- added our own device when it is found missing on PEP notification
- mark message as trusted when suitable
2019-01-03 21:04:55 +01:00
Goffi
111d77e75e plugin XEP-0384: update to last python-omemo + trust management:
- Plugin has been updated to use last version of python-omemo (10.0.3).
- A temporary method remove all storage data if they are found, this method must be removed before 0.7 release (only people using dev version should have old omemo data in there storage).
- Trust management is not implemented, using new encryptionTrustUIGet method (an UI is also displayed when trust handling is needed before sending a message).
- omemo.DefaultOTPKPolicy is now used, instead of previous test policy of always deleting.

OMEMO e2e encryption is now functional for one2one conversations, including fingerprint management.
2019-01-02 18:50:28 +01:00
Goffi
d206324fbe plugin XEP-0384: PEP handling + mark as encrypted:
devices are gotten using PEP and +notify, and bundles are then retrieved, and kept in cache.
This allow to remove the test code which was always requesting devices and bundles before
sending a message. For now OMEMO plugin will only work with people in roster, this will be
fixed in the future.
2018-08-11 18:24:55 +02:00
Goffi
583d4b0c2e plugin XEP-0384, install: adapted plugin to omemo module changes + added omemo module to dependencies:
- omemo module logs are now integrated in SàT
- OmemoStorage adapated to changes
- now really delete OTPK each time, behaviour may be modified in future
- fixed bad arguments used during decryption
- adapted to other changes

OMEMO is now working \o/
It still needs some adjustements though: bundles/devices are for the moment requested on each message encryption, and fingerprints management is not implemented yet.
2018-08-11 18:24:55 +02:00
Goffi
14412f7a27 plugin XEP-0384: OMEMO implementation first draft:
this is the initial implementation of OMEMO encryption using python omemo module.
/!\ This implementation is not yet working /!\
2018-07-29 19:24:21 +02:00