Since #3861 (closed) landed we do the authenticode code-signing for Windows Tor Browser .exe files. In order to compare these files with the ones we built deterministically we need to strip its signature. It turns out that this works using e.g. osslsigncode but (surprise!) one does not get the same SHA256 sum back.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related.
Learn more.
"Neither osslsigncode nor disitool get a .exe that matches the original, unsigned .exe (which got signed by signtool as a stopgap until we get our authenticode signing on Linux going) after I stripped the signature. The diff boils down to:
Trac: Description: Since #3861 (closed) landed we do the authenticode code-signing for Windows Tor Browser .exe files. In order to compare these files with the ones we built deterministically we need to strip its signature. It turns out that this works using e.g. osslsigncode but (surprise!) one does not get the same SHA256 sum back.
to
Since #3861 (closed) landed we do the authenticode code-signing for Windows Tor Browser .exe files. In order to compare these files with the ones we built deterministically we need to strip its signature. It turns out that this works using e.g. osslsigncode but (surprise!) one does not get the same SHA256 sum back.
"NSIS generates unaligned files. You can to test with exe from bundle, it should to matches.
NSIS generates totally wrong PE files, it just appends compressed stuff to end of valid and aligned PE file without changing anything to PE-header, like malware."
Because PE-checksum (it's at 0xd8 offset) depends size of file too, but NSIS don't care to include stuff to PE-checksum it appends to end of file (it could to do zeroing of PE-checksum then, but not to leave broken PE-file with wrong checksum). osslsigncode removing signature and recalculates valid PE-checksum for whole file (includes len, changed after padding).
// No check sum support yet... DWORD* pdwCheckSum = GetMemberFromOptionalHeader(m_ntHeaders->OptionalHeader, CheckSum); if (*pdwCheckSum) { // clear checksum (should be [re]calculated after all changes done) pdwCheckSum = 0; //throw runtime_error("CResourceEditor doesn't yet support check sum"); }
Found only one place where it tries to change checksum, where is "[re]calculated after all changes done" then? It's not even right code then, it clears pointer to DWORD with checksum (why?). If to truncate stuff they appends to PE-file then checksum value from generated exe is not random for sure but not real one again.
Have no resources to compile it either for tests.
Thanks for looking into it. I think in order to solve this bug we should indeed patch NSIS as the other tools are behaving properly it seems. But, boy, this will be a fun task. I'll start with trying to get NSIS compiled (in our gitian environment).
Finally found where is checksum from, NSIS using binary stubs (/usr/share/nsis/Stubs/) depends prefer compression, and then modifies sections and stuff but can't to modify checksum.
(req python-pefile pkg)
But test shows it spends too many seconds while trying to calculate and to write so many bytes, probably local problems, however.
Thanks for looking into it. I think in order to solve this bug we should indeed patch NSIS as the other tools are behaving properly it seems. But, boy, this will be a fun task. I'll start with trying to get NSIS compiled (in our gitian environment).
On a second thought I think this is a lot of work for little gain especially as we might get away with the workaround mentioned in comment:10 (at least in the short/medium term). Let's try that one instead first.
I have a fix for this which is working. I'll post a proper branch after incorporating everything into our gitian framework and give it a last round of testing. I think it should make it into 4.5 as we start doing the windows signing there too and it is actually only one additional rebundling if we don't want to wait for it before we start building (which is fine to me). The risk that it'll break things after testing is pretty low I think.
Trac: Status: new to assigned Keywords: N/Adeleted, tbb-4.5-alpha added