When checking a file through signtool, I get one hash, and when decoding the certificate, another. What am I missing?
Command:
signtool verify /a /ph /pa /v .\EmptyExe.exe
Hash of file (sha256): 9FCC67FA3FAA88BCDED22E9FCF6AE1D6D62A95A79A1C777743052DF16F63DADC
Decode octet string:
0001f...f003031300d06096086480165030402010500042066cea53b15089957fc4ca86e419e2058f562e17a802e23e7d5154d2e71412e1a
Parsed string: https://lapo.it/asn1js/#MDEwDQYJYIZIAWUDBAIBBQAEIGbOpTsVCJlX_EyobkGeIFj1YuF6gC4j59UVTS5xQS4a
According to my observation, when signing different files, only 3 fields change: hash, messageDigest, encoded hash. What is stored in the messageDigest field?
messageDigest
contains a hash of PKCS#7 message content which in turns contains the hash of signed data (PE, in a given case).