Conversation
Verify MsiDigitalSignatureEx separately and include the stored stream in the MSI content digest at its sorted position instead of prepending the calculated pre-hash. Keep the existing signing behavior unchanged.
Signing and verification now disagree on MSI digest ordering
Reproducer using the existing fixture, renaming its embedded-cabinet stream so it sorts before DSE: python3 - <<'PY'
from pathlib import Path
b = bytearray(Path("tests/files/unsigned.msi").read_bytes())
b[7168] = 0
Path("early-stream.msi").write_bytes(b)
PY
openssl req -x509 -newkey rsa:2048 -nodes \
-keyout key.pem -out cert.pem -subj /CN=Review \
-days 1 -addext extendedKeyUsage=codeSigning
build/osslsigncode sign -certs cert.pem -key key.pem \
-add-msi-dse -in early-stream.msi -out signed.msi
build/osslsigncode verify -CAfile cert.pem -in signed.msiResult: base passes; this branch fails with The unmodified fixture with DSE, and the modified fixture without DSE, pass on both versions. Suggestion: make signing and verification use the same digest ordering, including the detached-signature digest path. Explicitly address compatibility with previously generated signatures and add an early-sorting-stream regression test. |
Pull Request Type
Related Issue
Fixes #507
Current Behavior
MSI verification prepends the recalculated
MsiDigitalSignatureExvalue to the content digest and skips the storedMsiDigitalSignatureExstream.This can produce a different
DigitalSignaturedigest than Windows signtool for valid MSI files.New Behavior
During verification, the recalculated
MsiDigitalSignatureExvalue is checked against the stored value.The stored
MsiDigitalSignatureExstream is then included in the MSI content digest at its sorted position.Signing behavior remains unchanged.
Scope of Changes
MsiDigitalSignatureExvalue.msi_hash_dir()to include theMsiDigitalSignatureExstream during verification.Testing
Verified an affected MSI file successfully with both
osslsigncodeand Windowssigntool.Additional Notes
License Declaration