From 4b5d1c85c01db789da08390f7c87799d5fd7cf51 Mon Sep 17 00:00:00 2001 From: Vladimir Serov Date: Thu, 16 Sep 2021 01:31:47 +0300 Subject: [PATCH] update_chitu: generating update uuid based on file hash (#4663) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/update_chitu.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/update_chitu.py b/scripts/update_chitu.py index 2da78276..1d993b46 100755 --- a/scripts/update_chitu.py +++ b/scripts/update_chitu.py @@ -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;