[][src]Struct threema_gateway::E2eApi

pub struct E2eApi { /* fields omitted */ }

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

Methods

impl E2eApi[src]

pub fn encrypt_raw(
    &self,
    data: &[u8],
    recipient_key: &RecipientKey
) -> EncryptedMessage
[src]

Encrypt raw bytes for the specified recipient public key.

pub fn encrypt_text_msg(
    &self,
    text: &str,
    recipient_key: &RecipientKey
) -> EncryptedMessage
[src]

Encrypt a text message for the specified recipient public key.

pub fn encrypt_image_msg(
    &self,
    blob_id: &BlobId,
    img_size_bytes: u32,
    image_data_nonce: &[u8; 24],
    recipient_key: &RecipientKey
) -> EncryptedMessage
[src]

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.

pub fn encrypt_file_msg(
    &self,
    file_blob_id: &BlobId,
    thumbnail_blob_id: Option<&BlobId>,
    blob_encryption_key: &Key,
    mime_type: &Mime,
    file_name: Option<&str>,
    file_size_bytes: u32,
    description: Option<&str>,
    recipient_key: &RecipientKey
) -> EncryptedMessage
[src]

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.

pub fn send(
    &self,
    to: &str,
    message: &EncryptedMessage
) -> Result<String, ApiError>
[src]

Send an encrypted E2E message to the specified Threema ID.

Cost: 1 credit.

pub fn lookup_pubkey(&self, id: &str) -> Result<String, ApiError>[src]

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.

pub fn lookup_id(&self, criterion: &LookupCriterion) -> Result<String, ApiError>[src]

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.

pub fn lookup_capabilities(&self, id: &str) -> Result<Capabilities, ApiError>[src]

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.

pub fn lookup_credits(&self) -> Result<i64, ApiError>[src]

Look up a remaining gateway credits.

pub fn blob_upload(
    &self,
    data: &EncryptedMessage,
    persist: bool
) -> Result<BlobId, ApiError>
[src]

Upload encrypted data to the blob server.

If persist is set to true, then the blob will not be deleted after a client has downloaded it and marked it as done. Use when distributing the same blob to multiple clients.

Cost: 1 credit.

pub fn blob_upload_raw(
    &self,
    data: &[u8],
    persist: bool
) -> Result<BlobId, ApiError>
[src]

Upload raw data to the blob server.

If persist is set to true, then the blob will not be deleted after a client has downloaded it and marked it as done. Use when distributing the same blob to multiple clients.

Cost: 1 credit.

Trait Implementations

impl Clone for E2eApi[src]

impl Eq for E2eApi[src]

impl PartialEq<E2eApi> for E2eApi[src]

impl Debug for E2eApi[src]

Auto Trait Implementations

impl Send for E2eApi

impl Sync for E2eApi

impl Unpin for E2eApi

impl UnwindSafe for E2eApi

impl RefUnwindSafe for E2eApi

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err