diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-03-02 15:05:10 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-03-02 15:47:43 -0600 |
commit | 7f128f4639b6a14217780d69a0615b44d36f2f1b (patch) | |
tree | bb124985a687040524cea1f6347737399cfdb948 | |
parent | 227518090282bba4d973d4efe910623879218a62 (diff) | |
download | wix-7f128f4639b6a14217780d69a0615b44d36f2f1b.tar.gz wix-7f128f4639b6a14217780d69a0615b44d36f2f1b.tar.bz2 wix-7f128f4639b6a14217780d69a0615b44d36f2f1b.zip |
Use SHA512 instead of SHA1.
#3992
-rw-r--r-- | src/Cpp.Build.props | 2 | ||||
-rw-r--r-- | src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h | 2 | ||||
-rw-r--r-- | src/engine/cache.cpp | 12 | ||||
-rw-r--r-- | src/engine/cache.h | 2 | ||||
-rw-r--r-- | src/engine/externalengine.cpp | 2 | ||||
-rw-r--r-- | src/engine/userexperience.cpp | 2 | ||||
-rw-r--r-- | src/test/BurnUnitTest/BurnUnitTest.vcxproj | 1 | ||||
-rw-r--r-- | src/test/BurnUnitTest/CacheTest.cpp | 8 | ||||
-rw-r--r-- | src/test/BurnUnitTest/TestData/CacheTest/CacheSignatureTest.File | 1 |
9 files changed, 17 insertions, 15 deletions
diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index ef9de6f0..a734aab0 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props | |||
@@ -25,7 +25,7 @@ | |||
25 | <DisableSpecificWarnings>$(DisableSpecificCompilerWarnings)</DisableSpecificWarnings> | 25 | <DisableSpecificWarnings>$(DisableSpecificCompilerWarnings)</DisableSpecificWarnings> |
26 | <WarningLevel>Level4</WarningLevel> | 26 | <WarningLevel>Level4</WarningLevel> |
27 | <AdditionalIncludeDirectories>$(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 27 | <AdditionalIncludeDirectories>$(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
28 | <PreprocessorDefinitions>WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | 28 | <PreprocessorDefinitions>WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0600;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
29 | <PrecompiledHeader>Use</PrecompiledHeader> | 29 | <PrecompiledHeader>Use</PrecompiledHeader> |
30 | <PrecompiledHeaderFile>precomp.h</PrecompiledHeaderFile> | 30 | <PrecompiledHeaderFile>precomp.h</PrecompiledHeaderFile> |
31 | <CallingConvention Condition="'$(Platform)'=='Win32'">StdCall</CallingConvention> | 31 | <CallingConvention Condition="'$(Platform)'=='Win32'">StdCall</CallingConvention> |
diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h index 9642748b..c0e4ded1 100644 --- a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h +++ b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h | |||
@@ -82,7 +82,7 @@ enum BOOTSTRAPPER_LOG_LEVEL | |||
82 | enum BOOTSTRAPPER_UPDATE_HASH_TYPE | 82 | enum BOOTSTRAPPER_UPDATE_HASH_TYPE |
83 | { | 83 | { |
84 | BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE, | 84 | BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE, |
85 | BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA1, | 85 | BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | enum BOOTSTRAPPER_ENGINE_MESSAGE | 88 | enum BOOTSTRAPPER_ENGINE_MESSAGE |
diff --git a/src/engine/cache.cpp b/src/engine/cache.cpp index 92a79eb9..2349a357 100644 --- a/src/engine/cache.cpp +++ b/src/engine/cache.cpp | |||
@@ -273,7 +273,7 @@ extern "C" HRESULT CacheCalculatePayloadWorkingPath( | |||
273 | ExitOnFailure(hr, "Failed to get working folder for payload."); | 273 | ExitOnFailure(hr, "Failed to get working folder for payload."); |
274 | 274 | ||
275 | hr = StrAllocConcat(psczWorkingPath, pPayload->sczKey, 0); | 275 | hr = StrAllocConcat(psczWorkingPath, pPayload->sczKey, 0); |
276 | ExitOnFailure(hr, "Failed to append SHA1 hash as payload unverified path."); | 276 | ExitOnFailure(hr, "Failed to append Id as payload unverified path."); |
277 | 277 | ||
278 | LExit: | 278 | LExit: |
279 | return hr; | 279 | return hr; |
@@ -291,7 +291,7 @@ extern "C" HRESULT CacheCalculateContainerWorkingPath( | |||
291 | ExitOnFailure(hr, "Failed to get working folder for container."); | 291 | ExitOnFailure(hr, "Failed to get working folder for container."); |
292 | 292 | ||
293 | hr = StrAllocConcat(psczWorkingPath, pContainer->sczHash, 0); | 293 | hr = StrAllocConcat(psczWorkingPath, pContainer->sczHash, 0); |
294 | ExitOnFailure(hr, "Failed to append SHA1 hash as container unverified path."); | 294 | ExitOnFailure(hr, "Failed to append hash as container unverified path."); |
295 | 295 | ||
296 | LExit: | 296 | LExit: |
297 | return hr; | 297 | return hr; |
@@ -1750,23 +1750,23 @@ static HRESULT VerifyHash( | |||
1750 | UNREFERENCED_PARAMETER(wzUnverifiedPayloadPath); | 1750 | UNREFERENCED_PARAMETER(wzUnverifiedPayloadPath); |
1751 | 1751 | ||
1752 | HRESULT hr = S_OK; | 1752 | HRESULT hr = S_OK; |
1753 | BYTE rgbActualHash[SHA1_HASH_LEN] = { }; | 1753 | BYTE rgbActualHash[SHA512_HASH_LEN] = { }; |
1754 | DWORD64 qwHashedBytes; | 1754 | DWORD64 qwHashedBytes; |
1755 | LPWSTR pszExpected = NULL; | 1755 | LPWSTR pszExpected = NULL; |
1756 | LPWSTR pszActual = NULL; | 1756 | LPWSTR pszActual = NULL; |
1757 | 1757 | ||
1758 | // TODO: create a cryp hash file that sends progress. | 1758 | // TODO: create a cryp hash file that sends progress. |
1759 | hr = CrypHashFileHandle(hFile, PROV_RSA_FULL, CALG_SHA1, rgbActualHash, sizeof(rgbActualHash), &qwHashedBytes); | 1759 | hr = CrypHashFileHandle(hFile, PROV_RSA_AES, CALG_SHA_512, rgbActualHash, sizeof(rgbActualHash), &qwHashedBytes); |
1760 | ExitOnFailure(hr, "Failed to calculate hash for path: %ls", wzUnverifiedPayloadPath); | 1760 | ExitOnFailure(hr, "Failed to calculate hash for path: %ls", wzUnverifiedPayloadPath); |
1761 | 1761 | ||
1762 | // Compare hashes. | 1762 | // Compare hashes. |
1763 | if (cbHash != sizeof(rgbActualHash) || 0 != memcmp(pbHash, rgbActualHash, SHA1_HASH_LEN)) | 1763 | if (cbHash != sizeof(rgbActualHash) || 0 != memcmp(pbHash, rgbActualHash, SHA512_HASH_LEN)) |
1764 | { | 1764 | { |
1765 | hr = CRYPT_E_HASH_VALUE; | 1765 | hr = CRYPT_E_HASH_VALUE; |
1766 | 1766 | ||
1767 | // Best effort to log the expected and actual hash value strings. | 1767 | // Best effort to log the expected and actual hash value strings. |
1768 | if (SUCCEEDED(StrAllocHexEncode(pbHash, cbHash, &pszExpected)) && | 1768 | if (SUCCEEDED(StrAllocHexEncode(pbHash, cbHash, &pszExpected)) && |
1769 | SUCCEEDED(StrAllocHexEncode(rgbActualHash, SHA1_HASH_LEN, &pszActual))) | 1769 | SUCCEEDED(StrAllocHexEncode(rgbActualHash, (SIZE_T)qwHashedBytes, &pszActual))) |
1770 | { | 1770 | { |
1771 | ExitOnFailure(hr, "Hash mismatch for path: %ls, expected: %ls, actual: %ls", wzUnverifiedPayloadPath, pszExpected, pszActual); | 1771 | ExitOnFailure(hr, "Hash mismatch for path: %ls, expected: %ls, actual: %ls", wzUnverifiedPayloadPath, pszExpected, pszActual); |
1772 | } | 1772 | } |
diff --git a/src/engine/cache.h b/src/engine/cache.h index f8ad2a90..a00c50b7 100644 --- a/src/engine/cache.h +++ b/src/engine/cache.h | |||
@@ -16,7 +16,7 @@ HRESULT CacheInitialize( | |||
16 | __in_z_opt LPCWSTR wzSourceProcessPath | 16 | __in_z_opt LPCWSTR wzSourceProcessPath |
17 | ); | 17 | ); |
18 | HRESULT CacheEnsureWorkingFolder( | 18 | HRESULT CacheEnsureWorkingFolder( |
19 | __in_z LPCWSTR wzBundleId, | 19 | __in_z_opt LPCWSTR wzBundleId, |
20 | __deref_out_z_opt LPWSTR* psczWorkingFolder | 20 | __deref_out_z_opt LPWSTR* psczWorkingFolder |
21 | ); | 21 | ); |
22 | HRESULT CacheCalculateBundleWorkingPath( | 22 | HRESULT CacheCalculateBundleWorkingPath( |
diff --git a/src/engine/externalengine.cpp b/src/engine/externalengine.cpp index f9a06437..26ab9fba 100644 --- a/src/engine/externalengine.cpp +++ b/src/engine/externalengine.cpp | |||
@@ -288,7 +288,7 @@ HRESULT ExternalEngineSetUpdate( | |||
288 | { | 288 | { |
289 | hr = E_INVALIDARG; | 289 | hr = E_INVALIDARG; |
290 | } | 290 | } |
291 | else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA1 == hashType && (SHA1_HASH_LEN != cbHash || !rgbHash)) | 291 | else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (SHA512_HASH_LEN != cbHash || !rgbHash)) |
292 | { | 292 | { |
293 | hr = E_INVALIDARG; | 293 | hr = E_INVALIDARG; |
294 | } | 294 | } |
diff --git a/src/engine/userexperience.cpp b/src/engine/userexperience.cpp index 84e88718..40a30c5d 100644 --- a/src/engine/userexperience.cpp +++ b/src/engine/userexperience.cpp | |||
@@ -111,7 +111,7 @@ extern "C" HRESULT UserExperienceLoad( | |||
111 | args.pCommand = pCommand; | 111 | args.pCommand = pCommand; |
112 | args.pfnBootstrapperEngineProc = EngineForApplicationProc; | 112 | args.pfnBootstrapperEngineProc = EngineForApplicationProc; |
113 | args.pvBootstrapperEngineProcContext = pEngineContext; | 113 | args.pvBootstrapperEngineProcContext = pEngineContext; |
114 | args.qwEngineAPIVersion = MAKEQWORDVERSION(2021, 2, 24, 0); | 114 | args.qwEngineAPIVersion = MAKEQWORDVERSION(2021, 3, 2, 0); |
115 | 115 | ||
116 | results.cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); | 116 | results.cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); |
117 | 117 | ||
diff --git a/src/test/BurnUnitTest/BurnUnitTest.vcxproj b/src/test/BurnUnitTest/BurnUnitTest.vcxproj index 869ba7a2..2ca7219e 100644 --- a/src/test/BurnUnitTest/BurnUnitTest.vcxproj +++ b/src/test/BurnUnitTest/BurnUnitTest.vcxproj | |||
@@ -69,6 +69,7 @@ | |||
69 | <ResourceCompile Include="BurnUnitTest.rc" /> | 69 | <ResourceCompile Include="BurnUnitTest.rc" /> |
70 | </ItemGroup> | 70 | </ItemGroup> |
71 | <ItemGroup> | 71 | <ItemGroup> |
72 | <None Include="TestData\CacheTest\CacheSignatureTest.File" CopyToOutputDirectory="PreserveNewest" /> | ||
72 | <None Include="TestData\PlanTest\BasicFunctionality_BundleA_manifest.xml" CopyToOutputDirectory="PreserveNewest" /> | 73 | <None Include="TestData\PlanTest\BasicFunctionality_BundleA_manifest.xml" CopyToOutputDirectory="PreserveNewest" /> |
73 | <None Include="TestData\PlanTest\MsiTransaction_BundleAv1_manifest.xml" CopyToOutputDirectory="PreserveNewest" /> | 74 | <None Include="TestData\PlanTest\MsiTransaction_BundleAv1_manifest.xml" CopyToOutputDirectory="PreserveNewest" /> |
74 | <None Include="TestData\PlanTest\Slipstream_BundleA_manifest.xml" CopyToOutputDirectory="PreserveNewest" /> | 75 | <None Include="TestData\PlanTest\Slipstream_BundleA_manifest.xml" CopyToOutputDirectory="PreserveNewest" /> |
diff --git a/src/test/BurnUnitTest/CacheTest.cpp b/src/test/BurnUnitTest/CacheTest.cpp index 6d261842..fc0b4531 100644 --- a/src/test/BurnUnitTest/CacheTest.cpp +++ b/src/test/BurnUnitTest/CacheTest.cpp | |||
@@ -24,7 +24,7 @@ namespace Bootstrapper | |||
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | [Fact(Skip = "Currently fails")] | 27 | [Fact] |
28 | void CacheSignatureTest() | 28 | void CacheSignatureTest() |
29 | { | 29 | { |
30 | HRESULT hr = S_OK; | 30 | HRESULT hr = S_OK; |
@@ -36,12 +36,12 @@ namespace Bootstrapper | |||
36 | 36 | ||
37 | try | 37 | try |
38 | { | 38 | { |
39 | pin_ptr<const wchar_t> dataDirectory = PtrToStringChars(this->TestContext->DataDirectory); | 39 | pin_ptr<const wchar_t> dataDirectory = PtrToStringChars(this->TestContext->TestDirectory); |
40 | hr = PathConcat(dataDirectory, L"BurnTestPayloads\\Products\\TestExe\\TestExe.exe", &sczPayloadPath); | 40 | hr = PathConcat(dataDirectory, L"TestData\\CacheTest\\CacheSignatureTest.File", &sczPayloadPath); |
41 | Assert::True(S_OK == hr, "Failed to get path to test file."); | 41 | Assert::True(S_OK == hr, "Failed to get path to test file."); |
42 | Assert::True(FileExistsEx(sczPayloadPath, NULL), "Test file does not exist."); | 42 | Assert::True(FileExistsEx(sczPayloadPath, NULL), "Test file does not exist."); |
43 | 43 | ||
44 | hr = StrAllocHexDecode(L"232BD16B78C1926F95D637731E1EE5379A3C4222", &pb, &cb); | 44 | hr = StrAllocHexDecode(L"25e61cd83485062b70713aebddd3fe4992826cb121466fddc8de3eacb1e42f39d4bdd8455d95eec8c9529ced4c0296ab861931fe2c86df2f2b4e8d259a6d9223", &pb, &cb); |
45 | Assert::Equal(S_OK, hr); | 45 | Assert::Equal(S_OK, hr); |
46 | 46 | ||
47 | package.fPerMachine = FALSE; | 47 | package.fPerMachine = FALSE; |
diff --git a/src/test/BurnUnitTest/TestData/CacheTest/CacheSignatureTest.File b/src/test/BurnUnitTest/TestData/CacheTest/CacheSignatureTest.File new file mode 100644 index 00000000..896ac017 --- /dev/null +++ b/src/test/BurnUnitTest/TestData/CacheTest/CacheSignatureTest.File | |||
@@ -0,0 +1 @@ | |||
This file has a known hash. \ No newline at end of file | |||