Telegram Api - Creating An Authorization Key 404 Error
Solution 1:
here is sample data from a simple TCP handshake with Telegram Servers:
Connect:Success:0Connectedto149.154.167.40:443raw_data:000000000000000000F011DB3B2AA9561400000078974660A9729A4F5B51F18F7943F9C0D61B1315auth_key_id:00000000000000000message_id:56A92A3BDB11F0006244568794892726272data_length:0000001420message_data:78974660A9729A4F5B51F18F7943F9C0D61B1315message_type:60469778>>EF0A000000000000000000F011DB3B2AA9561400000078974660A9729A4F5B51F18F7943F9C0D61B1315Send:Success:42Receive:Success:85<<15000000000000000001CC0CC93D2AA9564000000063241605A9729A4F5B51F18F7943F9C0D61B1315B4445B94718B3C6DD4136466FAC62DCD082311272BE9FF8F9700000015C4B51C01000000216BE86C022BB4C3raw_data:000000000000000001CC0CC93D2AA9564000000063241605A9729A4F5B51F18F7943F9C0D61B1315B4445B94718B3C6DD4136466FAC62DCD082311272BE9FF8F9700000015C4B51C01000000216BE86C022BB4C3auth_key_id:00000000000000000message_id:56A92A3DC90CCC016244568803180334081data_length:0000004064message_data:63241605A9729A4F5B51F18F7943F9C0D61B1315B4445B94718B3C6DD4136466FAC62DCD082311272BE9FF8F9700000015C4B51C01000000216BE86C022BB4C3message_type:05162463classid:resPQ#05162463nonce:A9729A4F5B51F18F7943F9C0D61B1315server_nonce:B4445B94718B3C6DD4136466FAC62DCDpq:2311272BE9FF8F972526843935494475671count:000000011fingerprints:C3B42B026CE86B2114101943622620965665
Lets break it down:
We are using the TCP abridged version, so we start off with 0xEF
The format for plain-text Telegram messages is
auth_ke_id + msg_id + msg_len + msg
auth_key_id
is always0
for plain-text messages hence we always start with0000000000000000
msg_id
must approximately equalunixtime*2^32
(see here) I have also seen that some variant of this works quite well formsg_id
in any language on any platform:whole_part_of(current_micro_second_time_stamp * 4294.967296)
The first message you start with for Auth_key generation is
reqPQ
which is defined as:reqPQ#0x60469778 {:nonce, :int128}
so it is simply a TL-header + a 128-bit random integer the total length will always be 4 + 16 = 20 encoded as little-endian that would bemsg_len = 14000000
say we have a 128-bit random integer= 55555555555555555555555555555555, then our reqPQ message would be 7897466055555555555555555555555555555555, which is simply TL-type
60469778
or 78974660 in little-endian followed by your randomly chooses 128-bit nonce.Before you send out the packet, again recall that TCP-abridged mode required you to include the total packet length in front of the other bytes just after the initial 0xEA . This packet length is computed as follows
let len = total_length / 4
a) If
len < 127
thenlen_header = len as byte
b) If
len >=127
thenlen_header = 0x7f + to_3_byte_little_endian(len)
finally we have:
EF0A000000000000000000F011DB3B2AA956140000007897466055555555555555555555555555555555
or
EF0A
0000000000000000
00F011DB3B2AA956
14000000
78974660
55555555555555555555555555555555
compared to yours:
0000000000000000
6C28224A94A9C956
14000000
78974660
68EDEAECD1372139BBB0394B6FD775D3
I would say, try using TCP-abriged mode by include the 0xEF
starting bit and re-check your msg_id
computation
cheers.
Post a Comment for "Telegram Api - Creating An Authorization Key 404 Error"