Skip to content

Commit

Permalink
patch_itb.py: fix hash value compare
Browse files Browse the repository at this point in the history
Got error when handling my FIT file:
```txt
Extracted:
 Image 1 (fdt-1)
  Description:  ARM64 OpenWrt cmcc_rax3000m-nand-ubootmod device tree
blob
  Created:      Fri Aug  9 14:40:29 2024
  Type:         Flat Device Tree
  Compression:  uncompressed
  Data Size:    22515 Bytes = 21.99 KiB = 0.02 MiB
  Architecture: AArch64
  Hash algo:    crc32
  Hash value:   a8ce7e2e
  Hash algo:    sha1
  Hash value:   41d92ad20c528dfc32c78d4d68be20d8939c2220
Failed to find sha1 in itb its
```

The value of orig_sha1 variable in code is:
```txt
orig_sha1:  <0x41d92ad2 0x0c528dfc 0x32c78d4d 0x68be20d8 0x939c2220>
```

while the sha1 value in build/orig_itb.its is

```txt
			hash-2 {
				value = <0x41d92ad2 0xc528dfc 0x32c78d4d 0x68be20d8 0x939c2220>;
				algo = "sha1";
			};
```

Signed-off-by: Kun Lai <me@imlk.top>
  • Loading branch information
imlk0 authored and cyyself committed Sep 8, 2024
1 parent 8473d85 commit da50af4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion patch_itb.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_sha1_string(binary_file):
sha1.update(binary_file)
sha1_hex = sha1.hexdigest()
assert len(sha1_hex) == 40, "Invalid sha1"
sha1_32group = [sha1_hex[i:i+8] for i in range(0, len(sha1_hex), 8)]
sha1_32group = [hex(int(sha1_hex[i:i+8], 16))[2:] for i in range(0, len(sha1_hex), 8)]
return "<0x"+" 0x".join(sha1_32group) + ">"

def get_crc32_string(binary_file):
Expand Down

0 comments on commit da50af4

Please sign in to comment.