Hi,
I am currently working on providing a detailed guide on how to compile the VeraCrypt Code on Windows.
I am able to compile the code without errors and the executables are generated when I run the script src/Signing/sign_test.bat
Unfortunately I get the error "This distribution package is damaged.", when I try to run the VeraCrypt Setup on a Windows 10 and above machine. On Windows 7 the package works fine, so it does not seem to be a compiling problem. The signing certificates of the resulting executable are trusted, so it should not be a certificate issue either.
After having a look into the code, I can see that the issue arises from the function "VerifyModuleSignature" within the file "Dlgcode.c". The function calculates a hash of a provided certificate and compares it against a hard coded value, in case the operating system is Windows 10 or higher. This should make sure, that the correct
For me, it looks like no certificate is provided, since the variable fileInfo is set to {0}. Therefore the comparison between the generated hash and the hard coded hash fails.
Can someone confirm this?
Regarding the fileInfo variable: The fileInfo structure is intended to provide details about the file being verified. While it's initialized to {0}, it is later populated with the path of the file that you're checking. Specifically, these lines of code ensure it's populated:
So, it's not an issue with the variable initialization. The fileInfo correctly points to the file path, as you mentioned.
Root Certificate Installation: One of the common reasons for WinVerifyTrust to fail, even if the certificate is valid, is if the root certificate (or intermediate certificates, if any) are not trusted by the system. To be specific, the root certificate used to sign the module needs to be present in the "Local Machine Trusted Root Certification Authorities" store on the machine where you're trying to run the setup. So, one needs to ensure that it is indeed installed in the correct store.
SHA512 Fingerprint: As per the code, the function computes a SHA512 hash of the certificate and compares it against two hard-coded SHA512 fingerprints (gpbSha256CodeSignCertFingerprint and gpbSha256MSCodeSignCertFingerprint). The name of the variable is misleading since it's a SHA512 hash and not SHA256 (this was fixed in this commit and now the variables names are gpbSha512CodeSignCertFingerprint and gpbSha512MSCodeSignCertFingerprint). Since you are using a test certificate for signing, you will need to compute the SHA512 hash of this certificate and update the value of the gpbSha256CodeSignCertFingerprint array with this new hash. That's because the hard-coded values are specific to the original VeraCrypt certificates, and won't match your custom test certificate.
So to summarize:
Double-check the installation of the root certificate in the "Local Machine Trusted Root Certification Authorities" store.
Compute its SHA512 fingerprint of the test certificate and update the gpbSha256CodeSignCertFingerprint array in the code accordingly.
I hope this clarifies the situation
Last edit: Mounir IDRASSI 2023-08-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am currently working on providing a detailed guide on how to compile the VeraCrypt Code on Windows.
I am able to compile the code without errors and the executables are generated when I run the script src/Signing/sign_test.bat
Unfortunately I get the error "This distribution package is damaged.", when I try to run the VeraCrypt Setup on a Windows 10 and above machine. On Windows 7 the package works fine, so it does not seem to be a compiling problem. The signing certificates of the resulting executable are trusted, so it should not be a certificate issue either.
After having a look into the code, I can see that the issue arises from the function "VerifyModuleSignature" within the file "Dlgcode.c". The function calculates a hash of a provided certificate and compares it against a hard coded value, in case the operating system is Windows 10 or higher. This should make sure, that the correct
For me, it looks like no certificate is provided, since the variable
fileInfo
is set to{0}
. Therefore the comparison between the generated hash and the hard coded hash fails.Can someone confirm this?
Regards
Felix
Hi Felix,
Thank you for your comprehensive analysis.
Regarding the fileInfo variable: The fileInfo structure is intended to provide details about the file being verified. While it's initialized to {0}, it is later populated with the path of the file that you're checking. Specifically, these lines of code ensure it's populated:
So, it's not an issue with the variable initialization. The fileInfo correctly points to the file path, as you mentioned.
Root Certificate Installation: One of the common reasons for WinVerifyTrust to fail, even if the certificate is valid, is if the root certificate (or intermediate certificates, if any) are not trusted by the system. To be specific, the root certificate used to sign the module needs to be present in the "Local Machine Trusted Root Certification Authorities" store on the machine where you're trying to run the setup. So, one needs to ensure that it is indeed installed in the correct store.
SHA512 Fingerprint: As per the code, the function computes a SHA512 hash of the certificate and compares it against two hard-coded SHA512 fingerprints (
gpbSha256CodeSignCertFingerprint
andgpbSha256MSCodeSignCertFingerprint
). The name of the variable is misleading since it's a SHA512 hash and not SHA256 (this was fixed in this commit and now the variables names aregpbSha512CodeSignCertFingerprint
andgpbSha512MSCodeSignCertFingerprint
). Since you are using a test certificate for signing, you will need to compute the SHA512 hash of this certificate and update the value of thegpbSha256CodeSignCertFingerprint
array with this new hash. That's because the hard-coded values are specific to the original VeraCrypt certificates, and won't match your custom test certificate.So to summarize:
gpbSha256CodeSignCertFingerprint
array in the code accordingly.I hope this clarifies the situation
Last edit: Mounir IDRASSI 2023-08-09