123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- """
- NSIS is neither padding nor calculating the PE-file checksum. But the tool
- we use for signing and the tools for stripping the signature do which leads to a
- SHA256 mismatch if one tries to check that the binary we offer is actually the
- the one we got from our reproducible builds.
- This small Python snippet does both things: It pads the .exe if necessary and it
- recalculates the PE-file checksum. Details of the discussion can be found in bug
- 15339: https://bugs.torproject.org/15539.
- Thanks to a cypherpunk for this workaround idea.
- """
- import pefile;
- f = open('torbrowser-install-tmp.exe')
- exe = f.read()
- f.close()
- remainder = len(exe) % 8
- if remainder > 0:
- exe += '\0' * (8 - remainder)
- pef = pefile.PE(data=exe, fast_load=True)
- pef.OPTIONAL_HEADER.CheckSum = pef.generate_checksum()
- pef.write(filename='torbrowser-install-tmp2.exe')
|