annotate libervia/backend/plugins/plugin_xep_0391.py @ 4240:79c8a70e1813

backend, frontend: prepare remote control: This is a series of changes necessary to prepare the implementation of remote control feature: - XEP-0166: add a `priority` attribute to `ApplicationData`: this is needed when several applications are working in a same session, to know which one must be handled first. Will be used to make Remote Control have precedence over Call content. - XEP-0166: `_call_plugins` is now async and is not used with `DeferredList` anymore: the benefit to have methods called in parallels is very low, and it cause a lot of trouble as we can't predict order. Methods are now called sequentially so workflow can be predicted. - XEP-0167: fix `senders` XMPP attribute <=> SDP mapping - XEP-0234: preflight acceptance key is now `pre-accepted` instead of `file-accepted`, so the same key can be used with other jingle applications. - XEP-0167, XEP-0343: move some method to XEP-0167 - XEP-0353: use new `priority` feature to call preflight methods of applications according to it. - frontend (webrtc): refactor the sources/sink handling with a more flexible mechanism based on Pydantic models. It is now possible to have has many Data Channel as necessary, to have them in addition to A/V streams, to specify manually GStreamer sources and sinks, etc. - frontend (webrtc): rework of the pipeline to reduce latency. - frontend: new `portal_desktop` method. Screenshare portal handling has been moved there, and RemoteDesktop portal has been added. - frontend (webrtc): fix `extract_ufrag_pwd` method. rel 436
author Goffi <goffi@goffi.org>
date Sat, 11 May 2024 13:52:41 +0200
parents e11b13418ba6
children 0d7bb4df2343
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3969
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
2
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia plugin for Jingle Encrypted Transports
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2022 Jérôme Poisson (goffi@goffi.org)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
5
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
10
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
15
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
18
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from base64 import b64encode
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from functools import partial
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
21 import io
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from typing import Any, Callable, Dict, List, Optional, Tuple, Union
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
23
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from twisted.words.protocols.jabber import error, jid, xmlstream
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from twisted.words.xish import domish
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from wokkel import disco, iwokkel
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from zope.interface import implementer
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from cryptography.exceptions import AlreadyFinalized
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from cryptography.hazmat import backends
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from cryptography.hazmat.primitives import ciphers
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from cryptography.hazmat.primitives.ciphers import Cipher, CipherContext, modes
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from cryptography.hazmat.primitives.padding import PKCS7, PaddingContext
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
33
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
34 from libervia.backend.core import exceptions
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
35 from libervia.backend.core.constants import Const as C
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
36 from libervia.backend.core.core_types import SatXMPPEntity
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
37 from libervia.backend.core.i18n import _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
38 from libervia.backend.core.log import getLogger
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
39 from libervia.backend.tools import xml_tools
3969
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
40
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
41 try:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
42 import oldmemo
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
43 import oldmemo.etree
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
44 except ImportError as import_error:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
45 raise exceptions.MissingModule(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
46 "You are missing one or more package required by the OMEMO plugin. Please"
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
47 " download/install the pip packages 'oldmemo'."
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
48 ) from import_error
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
49
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
50
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
51 log = getLogger(__name__)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
52
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
53 IMPORT_NAME = "XEP-0391"
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
54
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
55 PLUGIN_INFO = {
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
56 C.PI_NAME: "Jingle Encrypted Transports",
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
57 C.PI_IMPORT_NAME: IMPORT_NAME,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
58 C.PI_TYPE: C.PLUG_TYPE_XEP,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
59 C.PI_MODES: C.PLUG_MODE_BOTH,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
60 C.PI_PROTOCOLS: ["XEP-0391", "XEP-0396"],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
61 C.PI_DEPENDENCIES: ["XEP-0166", "XEP-0384"],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
62 C.PI_MAIN: "JET",
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
63 C.PI_HANDLER: "yes",
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
64 C.PI_DESCRIPTION: _("""End-to-end encryption of Jingle transports"""),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
65 }
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
66
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
67 NS_JET = "urn:xmpp:jingle:jet:0"
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
68 NS_JET_OMEMO = "urn:xmpp:jingle:jet-omemo:0"
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
69
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
70
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
71 class JET:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
72 namespace = NS_JET
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
73
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
74 def __init__(self, host):
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
75 log.info(_("XEP-0391 (Pubsub Attachments) plugin initialization"))
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3969
diff changeset
76 host.register_namespace("jet", NS_JET)
3969
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
77 self.host = host
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
78 self._o = host.plugins["XEP-0384"]
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
79 self._j = host.plugins["XEP-0166"]
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
80 host.trigger.add(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
81 "XEP-0166_initiate_elt_built",
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
82 self._on_initiate_elt_build
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
83 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
84 host.trigger.add(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
85 "XEP-0166_on_session_initiate",
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
86 self._on_session_initiate
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
87 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
88 host.trigger.add(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
89 "XEP-0234_jingle_handler",
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
90 self._add_encryption_filter
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
91 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
92 host.trigger.add(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
93 "XEP-0234_file_receiving_request_conf",
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
94 self._add_encryption_filter
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
95 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
96
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3969
diff changeset
97 def get_handler(self, client):
3969
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
98 return JET_Handler()
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
99
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
100 async def _on_initiate_elt_build(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
101 self,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
102 client: SatXMPPEntity,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
103 session: Dict[str, Any],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
104 iq_elt: domish.Element,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
105 jingle_elt: domish.Element
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
106 ) -> bool:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
107 if client.encryption.get_namespace(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
108 session["peer_jid"].userhostJID()
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
109 ) != self._o.NS_OLDMEMO:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
110 return True
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
111 for content_elt in jingle_elt.elements(self._j.namespace, "content"):
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
112 content_data = session["contents"][content_elt["name"]]
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
113 transport_data = content_data["transport_data"]
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
114 if transport_data.get("webrtc"):
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
115 # webRTC is already e2e encrypted, we skip this content to avoid double
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
116 # encryption
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
117 continue
3969
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
118 security_elt = content_elt.addElement((NS_JET, "security"))
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
119 security_elt["name"] = content_elt["name"]
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
120 # XXX: for now only OLDMEMO is supported, thus we do it directly here. If some
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
121 # other are supported in the future, a plugin registering mechanism will be
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
122 # implemented.
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
123 cipher = "urn:xmpp:ciphers:aes-128-gcm-nopadding"
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
124 enc_type = "eu.siacs.conversations.axolotl"
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
125 security_elt["cipher"] = cipher
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
126 security_elt["type"] = enc_type
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
127 encryption_data = content_data["encryption"] = {
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
128 "cipher": cipher,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
129 "type": enc_type
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
130 }
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
131 session_manager = await self._o.get_session_manager(client.profile)
4219
1b5cf2ee1d86 plugin XEP-0384, XEP-0391: download missing devices list:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
132 await self._o.download_missing_device_lists(
1b5cf2ee1d86 plugin XEP-0384, XEP-0391: download missing devices list:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
133 client, self._o.NS_OLDMEMO, {session["peer_jid"]}, session_manager
1b5cf2ee1d86 plugin XEP-0384, XEP-0391: download missing devices list:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
134 )
3969
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
135 try:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
136 messages, encryption_errors = await session_manager.encrypt(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
137 frozenset({session["peer_jid"].userhost()}),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
138 # the value seems to be the commonly used value
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
139 { self._o.NS_OLDMEMO: b" " },
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
140 backend_priority_order=[ self._o.NS_OLDMEMO ],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
141 identifier = client.jid.userhost()
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
142 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
143 except Exception as e:
4219
1b5cf2ee1d86 plugin XEP-0384, XEP-0391: download missing devices list:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
144 log.exception("Can't generate IV and keys")
3969
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
145 raise e
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
146 message, plain_key_material = next(iter(messages.items()))
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
147 iv, key = message.content.initialization_vector, plain_key_material.key
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
148 content_data["encryption"].update({
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
149 "iv": iv,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
150 "key": key
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
151 })
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
152 encrypted_elt = xml_tools.et_elt_2_domish_elt(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
153 oldmemo.etree.serialize_message(message)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
154 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
155 security_elt.addChild(encrypted_elt)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
156 return True
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
157
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
158 async def _on_session_initiate(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
159 self,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
160 client: SatXMPPEntity,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
161 session: Dict[str, Any],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
162 iq_elt: domish.Element,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
163 jingle_elt: domish.Element
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
164 ) -> bool:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
165 for content_elt in jingle_elt.elements(self._j.namespace, "content"):
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
166 content_data = session["contents"][content_elt["name"]]
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
167 security_elt = next(content_elt.elements(NS_JET, "security"), None)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
168 if security_elt is None:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
169 continue
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
170 encrypted_elt = next(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
171 security_elt.elements(self._o.NS_OLDMEMO, "encrypted"), None
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
172 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
173 if encrypted_elt is None:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
174 log.warning(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
175 "missing <encrypted> element, can't decrypt: {security_elt.toXml()}"
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
176 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
177 continue
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
178 session_manager = await self._o.get_session_manager(client.profile)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
179 try:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
180 message = await oldmemo.etree.parse_message(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
181 xml_tools.domish_elt_2_et_elt(encrypted_elt, False),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
182 session["peer_jid"].userhost(),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
183 client.jid.userhost(),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
184 session_manager
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
185 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
186 __, __, plain_key_material = await session_manager.decrypt(message)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
187 except Exception as e:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
188 log.warning(f"Can't get IV and key: {e}\n{security_elt.toXml()}")
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
189 continue
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
190 try:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
191 content_data["encryption"] = {
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
192 "cipher": security_elt["cipher"],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
193 "type": security_elt["type"],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
194 "iv": message.content.initialization_vector,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
195 "key": plain_key_material.key
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
196 }
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
197 except KeyError as e:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
198 log.warning(f"missing data, can't decrypt: {e}")
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
199 continue
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
200
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
201 return True
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
202
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
203 def __encrypt(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
204 self,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
205 data: bytes,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
206 encryptor: CipherContext,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
207 data_cb: Callable
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
208 ) -> bytes:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
209 data_cb(data)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
210 if data:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
211 return encryptor.update(data)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
212 else:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
213 try:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
214 return encryptor.finalize() + encryptor.tag
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
215 except AlreadyFinalized:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
216 return b''
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
217
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
218 def __decrypt(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
219 self,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
220 data: bytes,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
221 buffer: list[bytes],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
222 decryptor: CipherContext,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
223 data_cb: Callable
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
224 ) -> bytes:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
225 buffer.append(data)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
226 data = b''.join(buffer)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
227 buffer.clear()
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
228 if len(data) > 16:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
229 decrypted = decryptor.update(data[:-16])
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
230 data_cb(decrypted)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
231 else:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
232 decrypted = b''
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
233 buffer.append(data[-16:])
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
234 return decrypted
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
235
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
236 def __decrypt_finalize(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
237 self,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
238 file_obj: io.BytesIO,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
239 buffer: list[bytes],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
240 decryptor: CipherContext,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
241 ) -> None:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
242 tag = b''.join(buffer)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
243 file_obj.write(decryptor.finalize_with_tag(tag))
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
244
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
245 async def _add_encryption_filter(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
246 self,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
247 client: SatXMPPEntity,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
248 session: Dict[str, Any],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
249 content_data: Dict[str, Any],
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
250 elt: domish.Element
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
251 ) -> bool:
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
252 try:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
253 file_obj = content_data["stream_object"].file_obj
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
254 except KeyError:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
255 transport_data = content_data["transport_data"]
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
256 if transport_data.get("webrtc"):
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
257 # we skip JET to avoid double encryption
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
258 log.debug("JET skipped due to webrtc transport.")
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4223
diff changeset
259 return True
3969
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
260 try:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
261 encryption_data=content_data["encryption"]
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
262 except KeyError:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
263 return True
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
264 cipher = ciphers.Cipher(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
265 ciphers.algorithms.AES(encryption_data["key"]),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
266 modes.GCM(encryption_data["iv"]),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
267 backend=backends.default_backend(),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
268 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
269 if file_obj.mode == "wb":
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
270 # we are receiving a file
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
271 buffer = []
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
272 decryptor = cipher.decryptor()
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
273 file_obj.pre_close_cb = partial(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
274 self.__decrypt_finalize,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
275 file_obj=file_obj,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
276 buffer=buffer,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
277 decryptor=decryptor
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
278 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
279 file_obj.data_cb = partial(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
280 self.__decrypt,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
281 buffer=buffer,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
282 decryptor=decryptor,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
283 data_cb=file_obj.data_cb
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
284 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
285 else:
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
286 # we are sending a file
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
287 file_obj.data_cb = partial(
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
288 self.__encrypt,
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
289 encryptor=cipher.encryptor(),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
290 data_cb=file_obj.data_cb
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
291 )
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
292
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
293 return True
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
294
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
295
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
296 @implementer(iwokkel.IDisco)
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
297 class JET_Handler(xmlstream.XMPPHandler):
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
298
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
299 def getDiscoInfo(self, requestor, service, nodeIdentifier=""):
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
300 return [
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
301 disco.DiscoFeature(NS_JET),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
302 disco.DiscoFeature(NS_JET_OMEMO),
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
303 ]
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
304
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
305 def getDiscoItems(self, requestor, service, nodeIdentifier=""):
8e7d5796fb23 plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
Goffi <goffi@goffi.org>
parents:
diff changeset
306 return []