A Dart implementation of the cryptography needed for OMEMO 0.8.3.

Overview

omemo_dart

omemo_dart is a Dart library to help developers of Dart/Flutter XMPP clients to implement OMEMO in its newest version - currently 0.8.3.

The library provides an implementation of the X3DH key exchange, the Double Ratchet with the OMEMO 0.8.3 specific ENCRYPT, DECRYPT and KDF_* functions and a very high-level OmemoSessionManager that manages all Double Ratchet sessions and provides a clean and simple interface for encrypting a message for all known Ratchet sessions we have with a user.

This library also has no dependency on any XMPP library. omemo_dart instead defines an intermediary format for the required data that you, the user, will need to transform to and from the stanza format of your preferred XMPP library yourself.

Important Notes

  • Please note that this library has not been audited for its security! Use at your own risk!
  • This library is not tested with other implementations of OMEMO 0.8.3 as I do not know of any client implementing spec compliant OMEMO 0.8.3. It does, however, work with itself.

Usage

Include omemo_dart in your pubspec.yaml like this:

# [...]

dependencies:
  omemo_dart:
    hosted: https://git.polynom.me/api/packages/PapaTutuWawa/pub
    version: ^0.2.0
  # [...]

# [...]

Contributing

Due to issues with protobuf, omemo_dart reimplements the Protobuf encoding for the required OMEMO messages. As such, protobuf is only a dependency for testing that the serialisation and deserialisation of the custom implementation. In order to run tests, you need the Protbuf compiler. After that, making sure that the Dart Protobuf compiler addon and the Protobuf compiler itself is in your PATH, run protoc -I=./protobuf/ --dart_out=lib/protobuf/ ./protobuf/schema.proto in the repository's root to generate the real Protobuf bindings.

When submitting a PR, please run the linter using dart analyze and make sure that all tests still pass using dart test.

To ensure uniform commit message formatting, please also use gitlint to lint your commit messages' formatting.

License

Licensed under the MIT license.

See LICENSE.

Comments
  • All tests are pretty flaky

    All tests are pretty flaky

    They very occasionally fail for the same reason:

      Instance of 'UnknownSignedPrekeyException'
      package:omemo_dart/src/omemo/sessionmanager.dart 185:7  OmemoSessionManager._addSessionFromKeyExchange
      ===== asynchronous gap ===========================
      package:omemo_dart/src/omemo/sessionmanager.dart 347:7  OmemoSessionManager.decryptMessage
      ===== asynchronous gap ===========================
      test/omemo_test.dart 254:24                             main.<fn>
    
    bug 
    opened by PapaTutuWawa 3
  • Wrong behaviour on unacked ratchets

    Wrong behaviour on unacked ratchets

    Whenever we send a message to an unacked ratchet, we are not supposed to generate a new one but instead just send the old key exchange until we are acked. The message numbering prevents this from being an issue.

    bug 
    opened by PapaTutuWawa 1
  • Using the OmemoSessionManager to encrypt a second message to a Jid will causes an invalid HMAC exception

    Using the OmemoSessionManager to encrypt a second message to a Jid will causes an invalid HMAC exception

    See the test Test by sending multiple messages back and forth in test/omemo_test.dart.

    Edit: This bug does not seem to be triggered due to a bad ratchet since the Double Ratchet tests do not fail.

    Unhandled exception:
    Instance of 'InvalidMessageHMACException'
    #0      decrypt (package:omemo_dart/src/double_ratchet/crypto.dart:44:5)
    <asynchronous suspension>
    #1      OmemoSessionManager.decryptMessage.<anonymous closure> (package:omemo_dart/src/omemo/sessionmanager.dart:329:22)
    <asynchronous suspension>
    #2      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
    <asynchronous suspension>
    #3      OmemoSessionManager.decryptMessage (package:omemo_dart/src/omemo/sessionmanager.dart:324:5)
    <asynchronous suspension>
    #4      OmemoEncryptionImplementation.decryptStanza (package:xmpp_omemo/src/transformers/message.dart:151:22)
    <asynchronous suspension>
    #5      OmemoMessageTransformer.transformToData (package:xmpp_omemo/src/transformers/message.dart:198:23)
    <asynchronous suspension>
    #6      MessageTransformerManager.transformToData (package:xmpp_im/src/transformers/manager.dart:92:22)
    <asynchronous suspension>
    #7      Stream.asyncMap.<anonymous closure>.add (dart:async/stream.dart:742:7)
    <asynchronous suspension
    
    bug 
    opened by PapaTutuWawa 1
  • Empty OMEMO Messages should be allowed to bypass the trust manager

    Empty OMEMO Messages should be allowed to bypass the trust manager

    From XEP-0384

    Clients MUST NOT use a newly built session to transmit data without user intervention. [...] This rule does not apply to empty OMEMO messages (as per Sending a message) that are used purely to transfer key material, e.g. as part of heartbeat messages or automatic key exchange completion.
    
    bug 
    opened by PapaTutuWawa 1
  • The session manager should be able to serialise and deserialise itself

    The session manager should be able to serialise and deserialise itself

    • [x] Allow fully deserialising
    • [x] Allow fully serialising itself
    • [x] Add a commit and load function to allow users to just subclass, override those two functions and use their preferred storage solution
      • This should, however, be optional to provide a memoryless backend
      • This allows us to store ratchets individually, preventing us from having to serialise the entire manager everytime a message is encrypted or decrypted
    enhancement 
    opened by PapaTutuWawa 1
  • WIP: OmemoManager

    WIP: OmemoManager

    Replace the OmemoSessionManager interface. Closes #20.

    Fixes:

    • Build an abstraction over message sending #20.
    • Implements heartbeat messages.
    • Moves implementation experience from moxxmpp into the library
    opened by PapaTutuWawa 0
  • Build an abstraction over message sending

    Build an abstraction over message sending

    Message sending a bit more involved since we need to check for new ratchets, handle unacked ratchets and so on. So having this one being handled by omemo_dart would be a huge improvement.

    enhancement 
    opened by PapaTutuWawa 0
Releases(v0.3.0)
Owner
Student, Anime Expert, Vocaloid Listener, Docker and Linux Fan. Also known as Polynomdivision.
null
Jannis 0 Jan 29, 2022
Create flutter project with all needed configuration in two minutes (theme, localization, connect to firebase, FCM, local notifications, safe API call, error handling, animation..etc)

Flutter GetX Template Flutter Getx template to make starting project fast and easy . Introduction We all face the same problem when we want to start a

Emad Beltaje 150 Jan 7, 2023
It is a Mobile Application built with Flutter to help Instructors reach their students with the material needed for their course (Videos, PDFs, Exams)

Droos - Flutter Mobile Appliction It is a Mobile Application built with Flutter to help Instructors reach their students with the material needed for

Abdulrahman Emad 4 Oct 5, 2022
Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur

❤️ Sponsor get_it This is a simple Service Locator for Dart and Flutter projects with some additional goodies highly inspired by Splat. It can be used

Flutter Community 1k Jan 1, 2023
Socketio dart server and client - Full Socket.io implementation using Dart Lang

Getting Started Step 1: Run dart_server.dart Step 2: Android Emulator has proble

Trần Thiên Trọng 1 Jan 23, 2022
A dart implementation of fixed precision numbers.

The Fixed package allows you to store and perform maths on numbers with a fixed scale (fixed no. of decimal places). All amounts are store as integers

Brett Sutton 6 Jun 4, 2022
The Dart language implementation of gRPC.

The Dart implementation of gRPC: A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. Learn more Quick Start - ge

grpc 737 Jan 6, 2023
A simple dart zeromq implementation/wrapper around the libzmq C++ library

dartzmq A simple dart zeromq implementation/wrapper around the libzmq C++ library Features Currently supported: Creating sockets (pair, pub, sub, req,

Moritz Wirger 18 Dec 29, 2022
Firebase dart common interface and implementation for Browser, VM, node and flutter

firebase.dart Firebase dart common interface and implementation for Browser, VM, node and flutter Firebase Initialization Usage in browser import 'pac

Tekartik 6 Nov 28, 2021
The reference implementation of Sass, written in Dart.

A Dart implementation of Sass. Sass makes CSS fun again. Using Dart Sass From Chocolatey or Scoop (Windows) From Homebrew (macOS) Standalone From npm

Sass 3.4k Jan 5, 2023
A web-safe implementation of dart.io.Platforms. Helps avoid the "Unsupported operation: Platform._operatingSystem" runtime error.

Universal Platform - A Web-safe Platform class Currently, if you include the dart.io.Platform anywhere in your code, your app will throw the following

gskinner team 86 Nov 20, 2022
A dart implementation of the chord.js javascript package to display beautiful chord diagrams

flutter_guitar_tabs This is a dart implementation of the chord.js javascript package to display beautiful chord diagrams like the ones below. Where to

null 20 Nov 16, 2022
Flutter plugin that provides a quick&dirty workaround for incompatibility between VMWare Airwatch MDM solution and Dart Sockets implementation

airwatch_socket_workaround This plugin has been created to enable flutter apps to reach endpoints that are only reachable using a VMWare airwatch per

Gonçalo Silva 5 Nov 11, 2022
ESP-Touch Dart API for Flutter. Platform-specific implementation for Android (Java) and iOS (Objective-C).

esptouch_flutter Flutter plugin for ESP-Touch to configure network for ESP-8266 and ESP-32 devices. Runs on iOS and Android. esptouch_flutter is Flutt

SMAHO Engineering OSS 86 Dec 10, 2022
Implementation of data structures and algorithms in Dart programming language.

Algorithms in Dart Implementation of several algorithms with Dart programming language. Use dartdoc to generate documentation. Lists List data structu

Mafinar Khan 197 Dec 24, 2022
Lite-graphql - A light way implementation of GraphQL client in dart language

lite GraphQL client A light way implementation of GraphQL client in dart languag

Vincenzo Palazzo 3 Mar 17, 2022
Dart Implementation of the ISO-8583 banking protocol.

Dart Implementation of the ISO-8583 banking protocol. Supports 03xx message class (File Actions Message - 1987) and is compatible with most PoS device

Mahdi K. Fard 11 Dec 8, 2022
A simple and efficient FFT implementation for Dart

fftea A simple and efficient Fast Fourier Transform (FFT) library. FFT converts a time domain signal to the frequency domain, and back again. This is

Liam Appelbe 29 Nov 18, 2022
A simple Git LFS server implementation in Dart

A simple Git LFS server implementation in Dart Overview Git LFS client (git-lfs or git lfs command) requires a dedicated LFS-content server (not the G

Hoàng Văn Khoa 4 Oct 31, 2022