24 releases (14 breaking)

0.15.1 Dec 6, 2021
0.15.0 Apr 2, 2021
0.14.1 Mar 27, 2021
0.13.0 Jun 10, 2020
0.2.0 Dec 15, 2016

#83 in Cryptography

Download history 6/week @ 2022-01-19 6/week @ 2022-01-26 7/week @ 2022-02-02 9/week @ 2022-02-09 8/week @ 2022-02-16 35/week @ 2022-02-23 8/week @ 2022-03-02 6/week @ 2022-03-09 124/week @ 2022-03-16 53/week @ 2022-03-23 6/week @ 2022-03-30 9/week @ 2022-04-06 4/week @ 2022-04-13 7/week @ 2022-04-20 220/week @ 2022-04-27 177/week @ 2022-05-04

410 downloads per month

MIT/Apache

85KB
2K SLoC

Rust SDK for Threema Gateway

GitHub CI Crates.io Version Crates.io Downloads

This is a mostly-complete implementation of an asynchronous Threema Gateway client library in Rust. For implementation status, see feature list below.

Docs

Features

Sending

  • Send simple messages
  • Send end-to-end encrypted messages

Encrypting

  • Encrypt raw bytes
  • Encrypt text messages
  • Encrypt image messages
  • Encrypt file messages
  • Encrypt delivery receipt messages

Lookup

  • Look up ID by phone number
  • Look up ID by e-mail
  • Look up ID by phone number hash
  • Look up ID by e-mail hash
  • Look up capabilities by ID
  • Look up public key by ID
  • Look up remaining credits

Receiving

  • Decode incoming request body
  • Verify MAC of incoming message
  • Decrypt incoming message
  • Decode incoming message

Files

  • Upload files
  • Download files

Usage

Take a look at the examples in the examples/ directory to see how they're implemented.

Generate a new keypair:

cargo run --example generate_keypair

Lookup public key:

cargo run --example lookup_pubkey -- <our_id> <secret> <their_id>

Send simple transport-encrypted encrypted message:

cargo run --example send_simple -- <from> id <to-id> <secret> <text>...
cargo run --example send_simple -- <from> email <to-email> <secret> <text>...
cargo run --example send_simple -- <from> phone <to-phone> <secret> <text>...

Send e2e encrypted message:

cargo run --example send_e2e_text -- <from> <to> <secret> <private-key> <text>...

Look up Threema ID by phone:

cargo run --example lookup_id -- by_phone <from> <secret> 41791234567

Look up Threema ID by email hash:

cargo run --example lookup_id -- by_email_hash <from> <secret> 1ea093239cc5f0e1b6ec81b866265b921f26dc4033025410063309f4d1a8ee2c

Decode and decrypt an incoming message payload:

cargo run --example receive -- <our-id> <secret> <private-key> <request-body>

Cargo Features

This library offers the following optional features:

  • receive: Add support for processing incoming messages. Enabled by default.

Rust Version Requirements (MSRV)

This library generally tracks the latest stable Rust version but tries to guarantee backwards compatibility with older stable versions as much as possible. However, in many cases transitive dependencies make guaranteeing a minimal supported Rust version impossible (see this discussion).

TLS

This library uses rustls with native (system-provided) root certificates to establish a TLS connection.

License

Licensed under either of

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~10–20MB
~317K SLoC