hbruintjes / ceema

Threema protocol implementation in C++
Apache License 2.0
20 stars 4 forks source link
pidgin protocol purple threema threema-protocol

Ceema

This is the ceema library, which provides a C++ implementation of the Threema communication protocol (and, in the future, a C interface to it). The aim is to provide a somewhat simple interface to hook the Threema protocol in client applications such as multi-protocol IM clients.

If you are looking for a ready-to-use desktop application, consider openMittsu.

Building

Since this is CMake based, building the library consists of the following steps

git submodule init
git submodule sync
git submodule update --init --recursive
mkdir build && cd build
cmake ../
make

Dependencies

This library requires the following dependencies to be installed (both headers and libraries):

Library layout

Under src you will find:

Protocol

The protocol is fairly straightforward. First, a client-server handshake is performed to set-up the encryption (using sodium/NaCl). This is handled by the Session class. Next, the client and server will communicate in (encrypted) packets as follows:

Backup string

The Threema client allows for backup of the private key and client ID using a backup string. Its is a base32 encoded string consisting of a salt and the encrypted data. The salt and password generate a hash which can be used to decrypt the data, which will yield the client ID, private key, and 2 bytes of the SHA-256 hash of both which can be used to validate the decryption.

Using the Pidgin Plugin

Importing users and groups

For importing users and groups from a backup, use menu Accounts->Threema->Import from Backup

Adding users and groups manually

Adding users

Users have to be added manually via the Add Buddy menu in Pidgin.

Adding groups

When online with Pidgin while the administrator of a group creates or updates a group, this group is automatically created/updated by the plugin. However, this does not work if you are the administrator since it is not possible to be online with the same account on two devices.

A workaraound for this and in case that you want to add a group that already exists and is not updated by the administrator, you can enter the relevant data in Pidgin's configuration file blist.xml. This file is located at ~/.purple/blist.xml. The syntax for a group entry in the buddy list is the following:

<chat proto='prpl-threepl' account='MACCOUNT'>
  <alias>Alias</alias>
  <component name='id'>GROUP-ID-Hex-16digits</component>
  <component name='owner'>OACCOUNT</component>
  <setting name='name' type='string'>Group Name</setting>
  <setting name='members' type='string'>MEMBER01MEMBER02...MEMBERxx</setting>
</chat>