next step - to decrypt answer with AES
This commit is contained in:
parent
57db4d9e32
commit
d4e229b084
@ -139,11 +139,11 @@ def deserialize(bytes_io, type_=None, subtype=None):
|
||||
elif type_ == 'int128': x = bytes_io.read(16)
|
||||
elif type_ == 'int256': x = bytes_io.read(32)
|
||||
elif type_ == 'string' or type_ == 'bytes':
|
||||
l = struct.unpack('<b', bytes_io.read(1))[0]
|
||||
l = struct.unpack('<B', bytes_io.read(1))[0]
|
||||
assert l <= 254 # In general, 0xFF byte is not allowed here
|
||||
if l == 254:
|
||||
# We have a long string
|
||||
long_len = struct.unpack('<i', bytes_io.read(3))[0]
|
||||
long_len = struct.unpack('<I', bytes_io.read(3)+b'\x00')[0]
|
||||
x = bytes_io.read(long_len)
|
||||
bytes_io.read(-long_len % 4) # skip padding bytes
|
||||
else:
|
||||
|
10
testing.py
10
testing.py
@ -11,6 +11,7 @@ except ImportError:
|
||||
import ConfigParser as configparser
|
||||
from Crypto.Hash import SHA
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Cipher import AES
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
# Check if credentials is correctly loaded (when it doesn't read anything it returns [])
|
||||
@ -73,5 +74,12 @@ z = Session.method_call('req_DH_params',
|
||||
public_key_fingerprint=public_key_fingerprint,
|
||||
encrypted_data=encrypted_data)
|
||||
|
||||
print(z)
|
||||
encrypted_answer = z['encrypted_answer']
|
||||
tmp_aes_key = SHA.new(new_nonce + server_nonce).digest() + SHA.new(server_nonce + new_nonce).digest()[0:12]
|
||||
tmp_aes_iv = SHA.new(server_nonce + new_nonce).digest()[12:20] + SHA.new(new_nonce + new_nonce).digest() + new_nonce[0:4]
|
||||
|
||||
print("\ntmp_aes_key:")
|
||||
mtproto.vis(tmp_aes_key)
|
||||
|
||||
print("\ntmp_aes_iv:")
|
||||
mtproto.vis(tmp_aes_iv)
|
||||
|
Loading…
Reference in New Issue
Block a user