update_chitu: generating update uuid based on file hash (#4663)

This makes update_chitu a pure function: same file in — same file out.
That's something I need to make Nix builds for firmware itself reproducible.

Signed-off-by: Vladimir Serov <me@cab404.ru>
This commit is contained in:
Vladimir Serov 2021-09-16 01:31:47 +03:00 committed by GitHub
parent 8cf1b51223
commit 4b5d1c85c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -6,10 +6,10 @@
# Licensed under GPL-3.0
import os
import random
import struct
import uuid
import sys
import hashlib
def calculate_crc(contents, seed):
accumulating_xor_value = seed;
@ -69,7 +69,9 @@ def encode_file(input, output_file, file_length):
block_size = 0x800
key_length = 0x18
uid_value = uuid.uuid4()
file_digest = hashlib.md5(input_file).digest()
uid_value = uuid.UUID(bytes=file_digest)
print("Update UUID ", uid_value)
file_key = int(uid_value.hex[0:8], 16)
xor_crc = 0xef3d4323;