diff --git a/ltchiptool/soc/ambz2/util/models/images.py b/ltchiptool/soc/ambz2/util/models/images.py index 9bfa764..031b752 100644 --- a/ltchiptool/soc/ambz2/util/models/images.py +++ b/ltchiptool/soc/ambz2/util/models/images.py @@ -29,6 +29,7 @@ FLASH_CALIBRATION = b"\x99\x99\x96\x96\x3F\xCC\x66\xFC\xC0\x33\xCC\x03\xE5\xDC\x31\x62" +IMAGE_SIGNATURE_OFFSET = 0 IMAGE_PUBLIC_KEY_OFFSET = 32 diff --git a/ltchiptool/soc/ambz2/util/ota.py b/ltchiptool/soc/ambz2/util/ota.py index 12ed7a4..fdff561 100644 --- a/ltchiptool/soc/ambz2/util/ota.py +++ b/ltchiptool/soc/ambz2/util/ota.py @@ -1,10 +1,10 @@ # Copyright (c) Martin Prokopič 2024-12-02 -from .models.images import IMAGE_PUBLIC_KEY_OFFSET +from .models.images import IMAGE_PUBLIC_KEY_OFFSET, IMAGE_SIGNATURE_OFFSET def patch_firmware_for_ota(data: bytes) -> bytes: copy = bytearray(data) - copy[0] ^= 0xff # negate first signature byte - copy[IMAGE_PUBLIC_KEY_OFFSET] ^= 0xff # negate first pubkey byte + copy[IMAGE_SIGNATURE_OFFSET] ^= 0xFF # negate first signature byte + copy[IMAGE_PUBLIC_KEY_OFFSET] ^= 0xFF # negate first pubkey byte return bytes(copy)