From 973f93b2ec0a9c9a973e199b46c22dfc23242211 Mon Sep 17 00:00:00 2001 From: Ahmad Bin Shafqat <61423804+ahmadbinshafqat@users.noreply.github.com> Date: Thu, 3 Sep 2026 16:10:07 +0500 Subject: [PATCH 1/2] Update test_sign_image.py --- tests/unit/test_sign_image.py | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/unit/test_sign_image.py b/tests/unit/test_sign_image.py index 8884115..d00b287 100644 --- a/tests/unit/test_sign_image.py +++ b/tests/unit/test_sign_image.py @@ -182,6 +182,44 @@ def test_verify_rejects_a_signed_image_under_the_wrong_key(signed_image, tmp_pat assert "does not verify" in r.stderr + +def _pack_unsigned(tmp_path, payload=None): + """Pack a raw payload into an unsigned .eimg via imgpack.py.""" + payload = payload if payload is not None else b"\xA5" * 512 + (tmp_path / "fw.bin").write_bytes(payload) + r = _run(TOOLS / "imgpack.py", + "--input", tmp_path / "fw.bin", "--output", tmp_path / "fw.eimg", + "--load-addr", "0x08010000", "--entry-addr", "0x08010100", + "--version", "1.0.0") + assert r.returncode == 0, r.stderr + return tmp_path / "fw.eimg" + + +def test_sha256_method_sets_the_integrity_flag(tmp_path): + """--method sha256 must set EOS_IMG_FLAG_HASH_SHA256.""" + image = _pack_unsigned(tmp_path) + r = _run(TOOLS / "sign_image.py", "--image", image, "--method", "sha256") + assert r.returncode == 0, r.stderr + + data = image.read_bytes() + flags = struct.unpack_from(" Date: Thu, 3 Sep 2026 16:10:33 +0500 Subject: [PATCH 2/2] Update sign_image.py --- tools/sign_image.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/sign_image.py b/tools/sign_image.py index 3671cd6..84e8e52 100644 --- a/tools/sign_image.py +++ b/tools/sign_image.py @@ -112,6 +112,10 @@ def sign_sha256(image_path: Path): data[SIG_TYPE_OFFSET] = SIG_SHA256 data[SIG_LEN_OFFSET] = 0 + flags = struct.unpack_from('