Struct threema_gateway::E2eApi

source ·
pub struct E2eApi { /* private fields */ }
Expand description

Struct to talk to the E2E API (with end-to-end encryption).

Implementations

Encrypt raw bytes for the specified recipient public key.

Encrypt a text message for the specified recipient public key.

Encrypt an image message for the specified recipient public key.

Before calling this function, you need to encrypt the image data (JPEG format) with encrypt_raw and upload the ciphertext to the blob server.

The image size needs to be specified in bytes. Note that the size is only used for download size displaying purposes and has no security implications.

Encrypt a file message for the specified recipient public key.

Before calling this function, you need to symetrically encrypt the file data (libsodium secretbox, random key) and upload the ciphertext to the blob server. If you also want to set a thumbnail, do the same with the update data (in JPEG format) and use the same key. Use the nonce 000...1 for the file and 000...2 for the thumbnail.

The file size needs to be specified in bytes. Note that the size is only used for download size displaying purposes and has no security implications.

Send an encrypted E2E message to the specified Threema ID.

Cost: 1 credit.

Fetch the public key for the specified Threema ID.

For the end-to-end encrypted mode, you need the public key of the recipient in order to encrypt a message. While it’s best to obtain this directly from the recipient (extract it from the QR code), this may not be convenient, and therefore you can also look up the key associated with a given ID from the server.

It is strongly recommended that you cache the public keys to avoid querying the API for each message.

Look up a Threema ID in the directory.

An ID can be looked up either by a phone number or an e-mail address, in plaintext or hashed form. You can specify one of those criteria using the LookupCriterion enum.

Look up the capabilities of a certain Threema ID.

Before you send a file to a Threema ID using the blob upload (+file message), you may want to check whether the recipient uses a Threema version that supports receiving files. The receiver may be using an old version, or a platform where file reception is not supported.

Look up a remaining gateway credits.

Upload encrypted data to the blob server.

Cost: 1 credit.

Upload raw data to the blob server.

Cost: 1 credit.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.