Commit c9601c5e authored by richardARPANET's avatar richardARPANET

Merge branch 'master' into 'master'

Swap pycrypto to pycryptodome

See merge request richardARPANET/mega.py!1
parents dc360ebe f053a2db
...@@ -130,12 +130,12 @@ class Mega: ...@@ -130,12 +130,12 @@ class Mega:
encrypted_sid = mpi_to_int(base64_url_decode(resp['csid'])) encrypted_sid = mpi_to_int(base64_url_decode(resp['csid']))
rsa_decrypter = RSA.construct( rsa_decrypter = RSA.construct(
( (
self.rsa_private_key[0] * self.rsa_private_key[1], 0, self.rsa_private_key[0] * self.rsa_private_key[1], 257,
self.rsa_private_key[2], self.rsa_private_key[0], self.rsa_private_key[2], self.rsa_private_key[0],
self.rsa_private_key[1] self.rsa_private_key[1]
) )
) )
sid = '%x' % rsa_decrypter.key._decrypt(encrypted_sid) sid = '%x' % rsa_decrypter._decrypt(encrypted_sid)
sid = binascii.unhexlify('0' + sid if len(sid) % 2 else sid) sid = binascii.unhexlify('0' + sid if len(sid) % 2 else sid)
self.sid = base64_url_encode(sid[:43]) self.sid = base64_url_encode(sid[:43])
...@@ -608,7 +608,7 @@ class Mega: ...@@ -608,7 +608,7 @@ class Mega:
master_key_cipher = AES.new(a32_to_str(self.master_key), AES.MODE_ECB) master_key_cipher = AES.new(a32_to_str(self.master_key), AES.MODE_ECB)
ha = base64_url_encode( ha = base64_url_encode(
master_key_cipher.encrypt(node_data['h'] + node_data['h']) master_key_cipher.encrypt(node_data['h'].encode("utf8") + node_data['h'].encode("utf8"))
) )
share_key = secrets.token_bytes(16) share_key = secrets.token_bytes(16)
...@@ -726,7 +726,7 @@ class Mega: ...@@ -726,7 +726,7 @@ class Mega:
aes = AES.new(k_str, AES.MODE_CTR, counter=counter) aes = AES.new(k_str, AES.MODE_CTR, counter=counter)
mac_str = '\0' * 16 mac_str = '\0' * 16
mac_encryptor = AES.new(k_str, AES.MODE_CBC, mac_str) mac_encryptor = AES.new(k_str, AES.MODE_CBC, mac_str.encode("utf8"))
iv_str = a32_to_str([iv[0], iv[1], iv[0], iv[1]]) iv_str = a32_to_str([iv[0], iv[1], iv[0], iv[1]])
for chunk_start, chunk_size in get_chunks(file_size): for chunk_start, chunk_size in get_chunks(file_size):
...@@ -789,7 +789,7 @@ class Mega: ...@@ -789,7 +789,7 @@ class Mega:
completion_file_handle = None completion_file_handle = None
mac_str = '\0' * 16 mac_str = '\0' * 16
mac_encryptor = AES.new(k_str, AES.MODE_CBC, mac_str) mac_encryptor = AES.new(k_str, AES.MODE_CBC, mac_str.encode("utf8"))
iv_str = a32_to_str([ul_key[4], ul_key[5], ul_key[4], ul_key[5]]) iv_str = a32_to_str([ul_key[4], ul_key[5], ul_key[4], ul_key[5]])
if file_size > 0: if file_size > 0:
for chunk_start, chunk_size in get_chunks(file_size): for chunk_start, chunk_size in get_chunks(file_size):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment