Skip to main content

Module authentication

Module authentication 

Source
Expand description

Sans-IO MTProto authorization key generation.

§Flow

let (req, s1) = authentication::step1()?;
// send req, receive resp (ResPQ)
let (req, s2) = authentication::step2(s1, resp, dc_id)?;
// send req, receive resp (ServerDhParams)
let (req, s3) = authentication::step3(s2, resp)?;
// send req, receive resp (SetClientDhParamsAnswer)
let result = authentication::finish(s3, resp)?;
// on FinishResult::Done(d): d.auth_key is ready
// on FinishResult::Retry{..}: call retry_step3() + finish() up to 5 times

Structs§

DhParamsForRetry
Pre-processed server DH parameters retained so that step 3 can be repeated on dh_gen_retry without having to re-decrypt the server response.
Finished
The final output of a successful auth key handshake.
Step1
State after step 1.
Step2
State after step 2.
Step3
State after step 3.

Enums§

Error
Errors that can occur during auth key generation.
FinishResult
Result of finish either the handshake is done, or the server wants us to retry step 3 with the auth_key_aux_hash as retry_id.

Functions§

finish
Finalise the handshake.
key_for_fingerprint
RSA key by server fingerprint. Includes both production and test DC keys.
retry_step3
Re-run the client DH params generation after a dh_gen_retry response. Feed the dh_params, nonce, server_nonce, new_nonce from FinishResult::Retry and the retry_id (= auth_key_aux_hash).
step1
Generate a req_pq_multi request. Returns the request + opaque state.
step2
Process ResPQ and generate req_DH_params.
step3
Process ServerDhParams into a reusable DhParamsForRetry + send the first set_client_DH_params request.