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("