diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2019-07-01 23:54:10 +0200 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2019-07-01 23:54:10 +0200 |
commit | a8bf37eb611ce8fd8d963adb90cab6329ee0b8b6 (patch) | |
tree | 0e13701994f1f4727c3b2e169d0b6c35dae18470 /doc/source | |
parent | dd6efb144467a6f8463f194394cb1e725e4535b1 (diff) | |
download | poezio-a8bf37eb611ce8fd8d963adb90cab6329ee0b8b6.tar.gz poezio-a8bf37eb611ce8fd8d963adb90cab6329ee0b8b6.tar.bz2 poezio-a8bf37eb611ce8fd8d963adb90cab6329ee0b8b6.tar.xz poezio-a8bf37eb611ce8fd8d963adb90cab6329ee0b8b6.zip |
e2ee-api: Add documentation
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'doc/source')
-rw-r--r-- | doc/source/dev/e2ee.rst | 55 | ||||
-rw-r--r-- | doc/source/dev/index.rst | 1 |
2 files changed, 56 insertions, 0 deletions
diff --git a/doc/source/dev/e2ee.rst b/doc/source/dev/e2ee.rst new file mode 100644 index 00000000..08cae715 --- /dev/null +++ b/doc/source/dev/e2ee.rst @@ -0,0 +1,55 @@ +End-to-end Encryption API documentation +======================================= + +E2EEPlugin +---------- + +.. module:: poezio.plugin_e2ee + + +.. autoclass:: E2EEPlugin + :members: + +Builds on top of :py:class:`~BasePlugin` and requires the developer to +implement two methods, `decrypt` and `encrypt`, as well as the +`encryption_name` and `eme_ns` attribute. + +Please refer to :py:class:`~BasePlugin` for more information on how to +write plugins. + +Example plugins +--------------- + +**Example 1:** Base64 plugin + +.. code-block:: python + + from base64 import b64decode, b64encode + from poezio.plugin_e2ee import E2EEPlugin + from slixmpp import Message + + + class Plugin(E2EEPlugin): + """Base64 Plugin""" + + encryption_name = 'base64' + encryption_short_name = 'b64' + eme_ns = 'urn:xmpps:base64:0' + + # This encryption mechanism is using <body/> as a container + replace_body_with_eme = False + + def decrypt(self, message: Message, _tab) -> None: + """ + Decrypt base64 + """ + body = message['body'] + message['body'] = b64decode(body.encode()).decode() + + def encrypt(self, message: Message, _tab) -> None: + """ + Encrypt to base64 + """ + # TODO: Stop using <body/> for this. Put the encoded payload in another element. + body = message['body'] + message['body'] = b64encode(body.encode()).decode() diff --git a/doc/source/dev/index.rst b/doc/source/dev/index.rst index 21ea6253..630abfad 100644 --- a/doc/source/dev/index.rst +++ b/doc/source/dev/index.rst @@ -14,6 +14,7 @@ About plugins :maxdepth: 2 plugin + e2ee events slix xep |