mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
fix padding on hash check in backup tools
This commit is contained in:
parent
a416069002
commit
42052fdcc5
2 changed files with 11 additions and 7 deletions
|
|
@ -113,6 +113,7 @@ def main():
|
|||
COMMIT_NONCE_LEN = 32
|
||||
COMMIT_LEN = 32
|
||||
CHECKSUM_LEN = 32
|
||||
PADDING = 4 # structure is padded to 8-byte boundary
|
||||
offset = PT_HEADER_LEN
|
||||
nonce = backup[offset:offset+NONCE_LEN]
|
||||
offset += NONCE_LEN
|
||||
|
|
@ -124,6 +125,7 @@ def main():
|
|||
offset += COMMIT_NONCE_LEN
|
||||
commit = backup[offset:offset+COMMIT_LEN]
|
||||
offset += COMMIT_LEN
|
||||
offset += PADDING
|
||||
check_region = backup[:offset]
|
||||
checksum = backup[offset:offset+CHECKSUM_LEN]
|
||||
|
||||
|
|
|
|||
|
|
@ -504,12 +504,6 @@ def check_header(backup):
|
|||
header_total_size = int.from_bytes(backup[i:i+4], 'little')
|
||||
print("Header total length in bytes: {}".format(header_total_size))
|
||||
i += 36 # reserved
|
||||
backup[i:i+4] = (2).to_bytes(4, 'little')
|
||||
op = int.from_bytes(backup[i:i+4], 'little')
|
||||
print("Opcode (should be 2, to trigger the next phase of restore): {}".format(op))
|
||||
if op != 2:
|
||||
print("Opcode is incorrect.")
|
||||
return False
|
||||
|
||||
if backup_version == 0x10001:
|
||||
print("Checksums found in backup image, checking...")
|
||||
|
|
@ -520,7 +514,8 @@ def check_header(backup):
|
|||
COMMIT_NONCE_LEN = 32
|
||||
COMMIT_LEN = 32
|
||||
CHECKSUM_LEN = 32
|
||||
checksum_loc = PT_HEADER_LEN + NONCE_LEN + CT_LEN + TAG_LEN + COMMIT_NONCE_LEN + COMMIT_LEN
|
||||
PADDING = 4
|
||||
checksum_loc = PT_HEADER_LEN + NONCE_LEN + CT_LEN + TAG_LEN + COMMIT_NONCE_LEN + COMMIT_LEN + PADDING
|
||||
check_region = backup[:checksum_loc]
|
||||
checksum = backup[checksum_loc:checksum_loc + CHECKSUM_LEN]
|
||||
hasher = SHA512.new(truncate="256")
|
||||
|
|
@ -532,6 +527,13 @@ def check_header(backup):
|
|||
|
||||
# TODO: checksums on data region
|
||||
|
||||
backup[i:i+4] = (2).to_bytes(4, 'little')
|
||||
op = int.from_bytes(backup[i:i+4], 'little')
|
||||
print("Opcode (should be 2, to trigger the next phase of restore): {}".format(op))
|
||||
if op != 2:
|
||||
print("Opcode is incorrect.")
|
||||
return False
|
||||
|
||||
print("Backup header passes sanity check!")
|
||||
return True
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue