diff --git a/tools/pddbdbg.py b/tools/pddbdbg.py index 062ab6140..8e5e093af 100755 --- a/tools/pddbdbg.py +++ b/tools/pddbdbg.py @@ -14,15 +14,7 @@ PAGE_SIZE = 4096 VPAGE_SIZE = 4064 MBBB_PAGES = 10 DO_CI_TESTS = True - -# PDDB version number is encoded here -def basis_aad(name, version=0x02_01, dna=0): - name_bytes = bytearray(name, 'utf-8') - # name_bytes += bytearray(([0] * (Basis.MAX_NAME_LEN - len(name)))) - name_bytes += version.to_bytes(4, 'little') - name_bytes += dna.to_bytes(8, 'little') - - return name_bytes +VERSION = 0x02_01 # build a table mapping all non-printable characters to None NOPRINT_TRANS_TABLE = { @@ -146,6 +138,13 @@ def keycommit_decrypt(key, aad, pp_data): raise Exception(ValueError) return pt_data +def basis_aad(name, version=VERSION, dna=0): + name_bytes = bytearray(name, 'utf-8') + # name_bytes += bytearray(([0] * (Basis.MAX_NAME_LEN - len(name)))) + name_bytes += version.to_bytes(4, 'little') + name_bytes += dna.to_bytes(8, 'little') + + return name_bytes def main(): global DO_CI_TESTS @@ -758,7 +757,7 @@ class Fscb: logging.warning("Duplicate journal number found:\n {} (in table)\n {} (incoming)".format(cur_pp.as_str(), pp.as_str())) # this is the "AAD" used to encrypt the FastSpace - def aad(version=0x01_01, dna=0): + def aad(version=VERSION, dna=0): return bytearray([46, 70, 97, 115, 116, 83, 112, 97, 99, 101]) + version.to_bytes(4, 'little') + dna.to_bytes(8, 'little') class SpaceUpdate: @@ -819,7 +818,7 @@ def decode_fscb(img, keys, FSCB_LEN_PAGES=2): fscb = None if fscb != None: - logging.debug("key: {}".format(key.hex())) + logging.debug("key: {}".format(key[1].hex())) cipher = AES.new(key[0], AES.MODE_ECB) for update in space_update: entries = [update[i:i+SpaceUpdate.SU_LEN] for i in range(0, len(update), SpaceUpdate.SU_LEN)]