[][src]Module grammers_mtproto::authentication

Contains the steps required to generate an authorization key.

Examples

use grammers_mtproto::{authentication, errors::AuthKeyGenError};

fn send_data_to_server(request: &[u8]) -> Result<Vec<u8>, AuthKeyGenError> {
    unimplemented!()
}

fn main() -> Result<(), AuthKeyGenError> {
    let (request, data) = authentication::step1()?;
    let response = send_data_to_server(&request)?;

    let (request, data) = authentication::step2(data, &response)?;
    let response = send_data_to_server(&request)?;

    let (request, data) = authentication::step3(data, &response)?;
    let response = send_data_to_server(&request)?;

    let (auth_key, time_offset) = authentication::create_key(data, &response)?;
    // Now you have a secure `auth_key` to send encrypted messages to server.
    Ok(())
}

Structs

Step1

The data generated by step1, needed for step2.

Step2

The data generated by step2, needed for step3.

Step3

The data generated by step3, needed for create_key.

Functions

create_key

The last step of the process to generate an authorization key.

step1

The first step of the process to generate an authorization key.

step2

The second step of the process to generate an authorization key.

step3

The third step of the process to generate an authorization key.