mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-29 19:08:12 +00:00
tools: fix bug in vheader processing in binctl
This commit is contained in:
parent
300016cc92
commit
c53b0afd5b
@ -182,6 +182,7 @@ class VendorHeader(object):
|
|||||||
self.vsig_n, \
|
self.vsig_n, \
|
||||||
self.vtrust = header
|
self.vtrust = header
|
||||||
assert self.magic == b'TRZV'
|
assert self.magic == b'TRZV'
|
||||||
|
data = data[:self.hdrlen] # strip remaining data (firmware)
|
||||||
assert self.vsig_m > 0 and self.vsig_m <= self.vsig_n
|
assert self.vsig_m > 0 and self.vsig_m <= self.vsig_n
|
||||||
assert self.vsig_n > 0 and self.vsig_n <= 8
|
assert self.vsig_n > 0 and self.vsig_n <= 8
|
||||||
p = 32
|
p = 32
|
||||||
@ -277,6 +278,7 @@ def binopen(filename):
|
|||||||
vheader = VendorHeader(data)
|
vheader = VendorHeader(data)
|
||||||
if len(data) == vheader.hdrlen:
|
if len(data) == vheader.hdrlen:
|
||||||
return vheader
|
return vheader
|
||||||
|
vheader.print()
|
||||||
subdata = data[vheader.hdrlen:]
|
subdata = data[vheader.hdrlen:]
|
||||||
if subdata[:4] == b'TRZF':
|
if subdata[:4] == b'TRZF':
|
||||||
firmware = FirmwareImage(data, vheader.hdrlen)
|
firmware = FirmwareImage(data, vheader.hdrlen)
|
||||||
@ -316,7 +318,6 @@ def main():
|
|||||||
sigmask = 1 << (int(sys.argv[3]) - 1)
|
sigmask = 1 << (int(sys.argv[3]) - 1)
|
||||||
signature = binascii.unhexlify(sys.argv[4])
|
signature = binascii.unhexlify(sys.argv[4])
|
||||||
b.sign(sigmask, signature)
|
b.sign(sigmask, signature)
|
||||||
print()
|
|
||||||
b.write(fn)
|
b.write(fn)
|
||||||
if rehash:
|
if rehash:
|
||||||
b.update_hashes()
|
b.update_hashes()
|
||||||
|
Loading…
Reference in New Issue
Block a user