Skip to main content

A Python implementation of the OMEMO Multi-End Message and Object Encryption protocol.

Project description

PyPI PyPI - Python Version Build Status

python-omemo

A Python implementation of the OMEMO Multi-End Message and Object Encryption protocol.

This python library offers an open implementation of the OMEMO Multi-End Message and Object Encryption protocol as specified here.

Goals of this implementation are:

  • Do not depend on libsignal but offer a solid alternative to it
  • Stay away from GPL (this repo will soon switch to MIT)
  • Be flexible to changes that might happen to the OMEMO protocol
  • Keep the structure close to the spec
  • Provide the parts of the protocol (X3DH, Double Ratchet) as own projects

This library uses the X3DH and DoubleRatchet libraries, configures them with the parameters that OMEMO uses and manages all encryption sessions for you.

This library does NOT manage XML/stanzas.

Usage

Choose a backend

To use this library you have to choose a backend first. Currently, you don't have a lot of choice: The only available backend is a backend offering libsignal compatibility, found here. Install your backend of choice and proceed to the next step.

Implement the Storage interface

The library has a lot of state/data that it has to persist between runs. To be as flexible as possible the library leaves it open for you to decide how to store the data. Simply implement the Storage interface found in storage.py. The file contains more info about how to implement the interface.

Decide on a one-time pre key policy

This part is kind of tricky as it requires a lot of knowledge about how the protocol works. Basically the key exchange mechanism used by the protocol assumes guaranteed message delivery and a response to the first message before another message is sent. Both conditions are not quite given in all environments, especially not in XMPP, which is the main use-case for this library. For that reason the library has to "relax" some of the protocols rules. Instead of always instantly deleting the keys used in the key exchange, it is now up to you to decide whether to keep keys or not. To do so, implement the OTPKPolicy interface found in otpkpolicy.py. The file contains more info about how to implement the interface.

Note: One of the following releases will contain a default policy that tries to find a good balance between security and usability.

Create a SessionManager

Now that you have selected a backend, decided on how to store the data and when to delete the key exchange keys, it's time to create an instance of the core class of this library: the SessionManager.

The SessionManager handles message en- and decryption with all your contacts, trying to make it as easy as possible for you. The file examples/sessions.py contains a lot of well-commented code that shows how to create and use a SessionManager.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

OMEMO-0.8.0.tar.gz (15.4 kB view details)

Uploaded Source

File details

Details for the file OMEMO-0.8.0.tar.gz.

File metadata

  • Download URL: OMEMO-0.8.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.3

File hashes

Hashes for OMEMO-0.8.0.tar.gz
Algorithm Hash digest
SHA256 45b0e9835aa9b7c3ee22c0460381ff32d359078c6c398ab2ecd83dc9e8826c80
MD5 d4eb2d5119469ce373c9f6c704764aef
BLAKE2b-256 4be21432e1d86d121003242fe9c6303ef0ae648a53d90051d75e788e87eefa4a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page