From 7368cd8d4f2701819b0e662071f03ed6e1d7115e Mon Sep 17 00:00:00 2001 From: Viktor Dragomiretskyy Date: Thu, 20 Jun 2019 10:11:06 +1200 Subject: [PATCH] Add padding to private key encryption. Now compartible with windows version. --- partition-the-flash.py | 3 +++ tls97.py | 1 + 2 files changed, 4 insertions(+) diff --git a/partition-the-flash.py b/partition-the-flash.py index e8e05de..3f982af 100644 --- a/partition-the-flash.py +++ b/partition-the-flash.py @@ -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) diff --git a/tls97.py b/tls97.py index 112012a..1ecfe2f 100644 --- a/tls97.py +++ b/tls97.py @@ -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:]