mtproto v0.1.0-alpha MTProto.Crypto

Summary

Functions

sha1_a = SHA1(msg_key + substr(auth_key, x, 32)); sha1_b = SHA1(substr(auth_key, 32+x, 16) + msg_key + substr(auth_key, 48+x, 16)); sha1_с = SHA1(substr(auth_key, 64+x, 32) + msg_key); sha1_d = SHA1(msg_key + substr(auth_key, 96+x, 32)); aes_key = substr(sha1_a, 0, 8) + substr(sha1_b, 8, 12) + substr(sha1_c, 4, 12); aes_iv = substr(sha1_a, 8, 12) + substr(sha1_b, 0, 8) + substr(sha1_c, 16, 4) + substr(sha1_d, 0, 8);

Functions

auth_key_hash(auth_key)
client_dh_inner_data_encrypt(tmp_aes_key, tmp_aes_iv, data)
decrypt_packet(packet, auth_key)
encrypt_packet(packet, auth_key, auth_key_hash)
generate_aes(msg_key, auth_key, action)

sha1_a = SHA1(msg_key + substr(auth_key, x, 32)); sha1_b = SHA1(substr(auth_key, 32+x, 16) + msg_key + substr(auth_key, 48+x, 16)); sha1_с = SHA1(substr(auth_key, 64+x, 32) + msg_key); sha1_d = SHA1(msg_key + substr(auth_key, 96+x, 32)); aes_key = substr(sha1_a, 0, 8) + substr(sha1_b, 8, 12) + substr(sha1_c, 4, 12); aes_iv = substr(sha1_a, 8, 12) + substr(sha1_b, 0, 8) + substr(sha1_c, 16, 4) + substr(sha1_d, 0, 8);

make_nonce(size \\ 16)
make_nonce_hash1(new_nonce, auth_key)
make_server_salt(new_nonce, server_nonce)
make_session_id()
p_q_inner_data_rsa(p_q_inner_data)
server_dh_params_decode(new_nonce, server_nonce, encrypted_answer)