Skip to content

Commit

Permalink
Support EC-230
Browse files Browse the repository at this point in the history
  • Loading branch information
d3dave committed Nov 21, 2021
1 parent d7f6c54 commit 943c491
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tpconf_bin_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ def verify(src):
print('ERROR: Bad file or could not decrypt file - MD5 hash check failed!')
exit()

def verify_ec230(src):
length = unpack_from(packint, src, 16)[0]
payload = src[20:][:length]
if src[:16] != md5(payload).digest():
print('ERROR: Bad file or could not decrypt file - MD5 hash check failed!')
exit()
return payload

def check_size_endianness(src):
global packint
if unpack_from(packint, src)[0] > 0x20000:
Expand Down Expand Up @@ -274,6 +282,14 @@ def check_size_endianness(src):
verify(dst)
print('OK: MD5 hash verified')
xml = dst[16:]
elif src[24:31] == b'<\0\0?xml': # compressed XML (EC-230)
'''
payload md5 (16b) | payload size (4b) | payload
'''
check_size_endianness(src[16:])
src = verify_ec230(src)
print('OK: BIN file decrypted, MD5 hash verified, uncompressing…')
xml = uncompress(src)
else:
print('ERROR: Unrecognized file type!')
exit()
Expand Down

0 comments on commit 943c491

Please sign in to comment.