some more fixes to pddbg to bring it up to v2. now passing CI.

This commit is contained in:
bunnie 2022-04-19 23:28:47 +08:00
parent 2d0af08266
commit 758ed1ba31

View file

@ -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)]