Add padding to private key encryption. Now compartible with windows version.

This commit is contained in:
Viktor Dragomiretskyy 2019-06-20 10:11:06 +12:00
parent 164a0a9e91
commit 7368cd8d4f
2 changed files with 4 additions and 0 deletions

View file

@ -325,6 +325,9 @@ def encrypt_key():
d = unhexlify('%064x' % client_private)[::-1]
m = x+y+d
l = 16 - (len(m) % 16)
m = m + bytes([l])*l
iv = get_random_bytes(AES.block_size)
aes = AES.new(psk_encryption_key, AES.MODE_CBC, iv)
c = iv + aes.encrypt(m)

View file

@ -478,6 +478,7 @@ class Tls():
iv, c = c[:AES.block_size], c[AES.block_size:]
aes=AES.new(psk_encryption_key, AES.MODE_CBC, iv)
m=aes.decrypt(c)
m=m[:-m[-1]] # unpad (standard this time)
x, m = m[:0x20], m[0x20:]
y, m = m[:0x20], m[0x20:]