diff options
author | Brad King <brad.king@kitware.com> | 2023-08-10 12:57:04 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-08-10 12:57:16 (GMT) |
commit | b47b44630ba14a8cd748bee06f47645862451506 (patch) | |
tree | a0aeb857615759f149ba2c575b508a3b2bd376bb | |
parent | f16bbea383327b75c9fb710aa4feabcee3686bbf (diff) | |
parent | 4980f47b4691ad7f4b4a579484fb43bed4db5c99 (diff) | |
download | CMake-b47b44630ba14a8cd748bee06f47645862451506.zip CMake-b47b44630ba14a8cd748bee06f47645862451506.tar.gz CMake-b47b44630ba14a8cd748bee06f47645862451506.tar.bz2 |
Merge topic 'cmSystemTools-hash-cleanup'
4980f47b46 cmGlobalGenerator: always support generating rule hashes
b334dc84c3 cmLocalGenerator: always support shortening filenames
36bd3d82f8 cmSystemTools: move `ComputeCertificateThumbprint` to the only consumer
a4e4daceaf cmSystemTools: remove `ComputeFileHash` method
0abde043d2 cmCryptoHash: prefer to cmSystemTools::ComputeFileHash
4d5198a986 cmSystemTools: remove `ComputeStringMD5` method
ec5f1c489a cmCryptoHash: prefer to cmSystemTools::ComputeStringMD5
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8695
-rw-r--r-- | Source/CPack/WiX/cmWIXSourceWriter.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 8 | ||||
-rw-r--r-- | Source/cmExportCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 4 | ||||
-rw-r--r-- | Source/cmIncludeGuardCommand.cxx | 13 | ||||
-rw-r--r-- | Source/cmInstallExportGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 24 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 90 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 15 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 79 | ||||
-rw-r--r-- | Source/cmcmd.cxx | 8 |
14 files changed, 108 insertions, 166 deletions
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index 82dc019..ef6712a 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -5,6 +5,7 @@ #include <windows.h> #include "cmCPackGenerator.h" +#include "cmCryptoHash.h" #include "cmUuid.h" cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, @@ -134,7 +135,8 @@ std::string cmWIXSourceWriter::CreateGuidFromComponentId( { std::string guid = "*"; if (this->ComponentGuidType == CMAKE_GENERATED_GUID) { - std::string md5 = cmSystemTools::ComputeStringMD5(componentId); + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + std::string md5 = hasher.HashString(componentId); cmUuid uuid; std::vector<unsigned char> ns; guid = uuid.FromMd5(ns, md5); diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 34c56c9..8d16428 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -290,8 +290,8 @@ std::string DebGenerator::generateMD5File() const continue; } - std::string output = - cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5); + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + std::string output = hasher.HashFile(file); if (output.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of " << file << std::endl); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 7d4b0a8..1934d8c 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -285,8 +285,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( if (cmIsOn(this->GetOption("InternalTest"))) { upload_as += "ffffffffffffffffffffffffffffffff"; } else { - upload_as += - cmSystemTools::ComputeFileHash(local_file, cmCryptoHash::AlgoMD5); + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + upload_as += hasher.HashFile(local_file); } if (!cmSystemTools::FileExists(local_file)) { @@ -549,8 +549,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, } } - std::string md5sum = - cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5); + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + std::string md5sum = hasher.HashFile(file); // 1. request the buildid and check to see if the file // has already been uploaded // TODO I added support for subproject. You would need to add diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index a58f2b7..273296d 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -14,6 +14,7 @@ #include "cmArgumentParser.h" #include "cmArgumentParserTypes.h" +#include "cmCryptoHash.h" #include "cmExecutionStatus.h" #include "cmExperimental.h" #include "cmExportBuildAndroidMKGenerator.h" @@ -310,7 +311,8 @@ static bool HandlePackage(std::vector<std::string> const& args, // named by a hash of its own content. This is deterministic and is // unique with high probability. const std::string& outDir = mf.GetCurrentBinaryDirectory(); - std::string hash = cmSystemTools::ComputeStringMD5(outDir); + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + std::string hash = hasher.HashString(outDir); StorePackageRegistry(mf, package, outDir.c_str(), hash.c_str()); return true; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8a8d2e0..9af6e9b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -30,6 +30,7 @@ #include "cmAlgorithms.h" #include "cmCPackPropertiesGenerator.h" #include "cmComputeTargetDepends.h" +#include "cmCryptoHash.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" #include "cmDuration.h" @@ -64,7 +65,6 @@ # include <cm3p/json/value.h> # include <cm3p/json/writer.h> -# include "cmCryptoHash.h" # include "cmQtAutoGenGlobalInitializer.h" #endif @@ -3222,7 +3222,6 @@ std::set<std::string> const& cmGlobalGenerator::GetDirectoryContent( void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs, std::string const& content) { -#if !defined(CMAKE_BOOTSTRAP) // Ignore if there are no outputs. if (outputs.empty()) { return; @@ -3242,20 +3241,14 @@ void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs, // Associate the hash with this output. this->RuleHashes[fname] = hash; -#else - (void)outputs; - (void)content; -#endif } void cmGlobalGenerator::CheckRuleHashes() { -#if !defined(CMAKE_BOOTSTRAP) std::string home = this->GetCMakeInstance()->GetHomeOutputDirectory(); std::string pfile = cmStrCat(home, "/CMakeFiles/CMakeRuleHashes.txt"); this->CheckRuleHashes(pfile, home); this->WriteRuleHashes(pfile); -#endif } void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 7a852f8..aa8a895 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -18,6 +18,7 @@ #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" +#include "cmCryptoHash.h" #include "cmDocumentationEntry.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -1202,9 +1203,10 @@ std::string cmGlobalVisualStudio10Generator::GenerateRuleFile( { // The VS 10 generator needs to create the .rule files on disk. // Hide them away under the CMakeFiles directory. + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); std::string ruleDir = cmStrCat( this->GetCMakeInstance()->GetHomeOutputDirectory(), "/CMakeFiles/", - cmSystemTools::ComputeStringMD5(cmSystemTools::GetFilenamePath(output))); + hasher.HashString(cmSystemTools::GetFilenamePath(output))); std::string ruleFile = cmStrCat(ruleDir, '/', cmSystemTools::GetFilenameName(output), ".rule"); return ruleFile; diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx index e0a6958..2b0e03c 100644 --- a/Source/cmIncludeGuardCommand.cxx +++ b/Source/cmIncludeGuardCommand.cxx @@ -2,11 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmIncludeGuardCommand.h" +#include "cmCryptoHash.h" #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" #include "cmValue.h" #include "cmake.h" @@ -21,14 +22,8 @@ enum IncludeGuardScope std::string GetIncludeGuardVariableName(std::string const& filePath) { - std::string result = "__INCGUARD_"; -#ifndef CMAKE_BOOTSTRAP - result += cmSystemTools::ComputeStringMD5(filePath); -#else - result += cmSystemTools::MakeCidentifier(filePath); -#endif - result += "__"; - return result; + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + return cmStrCat("__INCGUARD_", hasher.HashString(filePath), "__"); } bool CheckIncludeGuardIsSet(cmMakefile* mf, std::string const& includeGuardVar) diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 32196d3..71d5471 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -8,6 +8,7 @@ #include <cm/memory> +#include "cmCryptoHash.h" #ifndef CMAKE_BOOTSTRAP # include "cmExportInstallAndroidMKGenerator.h" #endif @@ -64,11 +65,10 @@ std::string cmInstallExportGenerator::TempDirCalculate() const return path; } -#ifndef CMAKE_BOOTSTRAP + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); path += '/'; // Replace the destination path with a hash to keep it short. - path += cmSystemTools::ComputeStringMD5(this->Destination); -#endif + path += hasher.HashString(this->Destination); return path; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 499dd24..ffab712 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -25,6 +25,7 @@ #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" +#include "cmCryptoHash.h" #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmCustomCommandLines.h" @@ -59,11 +60,6 @@ #include "cmVersion.h" #include "cmake.h" -#if !defined(CMAKE_BOOTSTRAP) -# define CM_LG_ENCODE_OBJECT_NAMES -# include "cmCryptoHash.h" -#endif - #if defined(__HAIKU__) # include <FindDirectory.h> # include <StorageDefs.h> @@ -3026,13 +3022,11 @@ void cmLocalGenerator::WriteUnitySourceInclude( } else { pathToHash = "ABS_" + sf_full_path; } + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); unity_file << "/* " << pathToHash << " */\n" << "#undef " << *uniqueIdName << "\n" << "#define " << *uniqueIdName << " unity_" -#ifndef CMAKE_BOOTSTRAP - << cmSystemTools::ComputeStringMD5(pathToHash) << "\n" -#endif - ; + << hasher.HashString(pathToHash) << "\n"; } if (beforeInclude) { @@ -3700,9 +3694,9 @@ void cmLocalGenerator::GenerateTargetInstallRules( } } -#if defined(CM_LG_ENCODE_OBJECT_NAMES) -static bool cmLocalGeneratorShortenObjectName(std::string& objName, - std::string::size_type max_len) +namespace { +bool cmLocalGeneratorShortenObjectName(std::string& objName, + std::string::size_type max_len) { // Check if the path can be shortened using an md5 sum replacement for // a portion of the path. @@ -3746,7 +3740,7 @@ bool cmLocalGeneratorCheckObjectName(std::string& objName, // already too deep. return false; } -#endif +} std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName( const std::string& sin, std::string const& dir_max) @@ -3796,7 +3790,6 @@ std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName( } while (!done); } -#if defined(CM_LG_ENCODE_OBJECT_NAMES) if (!cmLocalGeneratorCheckObjectName(ssin, dir_max.size(), this->ObjectPathMax)) { // Warn if this is the first time the path has been seen. @@ -3817,9 +3810,6 @@ std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName( this->IssueMessage(MessageType::WARNING, m.str()); } } -#else - (void)dir_max; -#endif // Insert the newly mapped object file name. std::map<std::string, std::string>::value_type e(sin, ssin); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 3d2e5f6..eddc033 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -701,12 +701,6 @@ private: std::string const& filename_base); }; -#if !defined(CMAKE_BOOTSTRAP) -bool cmLocalGeneratorCheckObjectName(std::string& objName, - std::string::size_type dir_len, - std::string::size_type max_total_len); -#endif - namespace detail { void AddCustomCommandToTarget(cmLocalGenerator& lg, cmCommandOrigin origin, cmTarget* target, cmCustomCommandType type, diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index bf3fcd9..2bdc928 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -47,13 +47,6 @@ # endif #endif -#if !defined(CMAKE_BOOTSTRAP) -# if defined(_WIN32) -# include <cm/memory> -# endif -# include "cmCryptoHash.h" -#endif - #if defined(CMake_USE_MACH_PARSER) # include "cmMachO.h" #endif @@ -1308,89 +1301,6 @@ void cmSystemTools::MoveFileIfDifferent(const std::string& source, RemoveFile(source); } -#ifndef CMAKE_BOOTSTRAP -std::string cmSystemTools::ComputeFileHash(const std::string& source, - cmCryptoHash::Algo algo) -{ - cmCryptoHash hash(algo); - return hash.HashFile(source); -} - -std::string cmSystemTools::ComputeStringMD5(const std::string& input) -{ - cmCryptoHash md5(cmCryptoHash::AlgoMD5); - return md5.HashString(input); -} - -# ifdef _WIN32 -std::string cmSystemTools::ComputeCertificateThumbprint( - const std::string& source) -{ - std::string thumbprint; - - CRYPT_INTEGER_BLOB cryptBlob; - HCERTSTORE certStore = nullptr; - PCCERT_CONTEXT certContext = nullptr; - - HANDLE certFile = CreateFileW( - cmsys::Encoding::ToWide(source.c_str()).c_str(), GENERIC_READ, - FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); - - if (certFile != INVALID_HANDLE_VALUE && certFile != nullptr) { - DWORD fileSize = GetFileSize(certFile, nullptr); - if (fileSize != INVALID_FILE_SIZE) { - auto certData = cm::make_unique<BYTE[]>(fileSize); - if (certData != nullptr) { - DWORD dwRead = 0; - if (ReadFile(certFile, certData.get(), fileSize, &dwRead, nullptr)) { - cryptBlob.cbData = fileSize; - cryptBlob.pbData = certData.get(); - - // Verify that this is a valid cert - if (PFXIsPFXBlob(&cryptBlob)) { - // Open the certificate as a store - certStore = - PFXImportCertStore(&cryptBlob, nullptr, CRYPT_EXPORTABLE); - if (certStore != nullptr) { - // There should only be 1 cert. - certContext = - CertEnumCertificatesInStore(certStore, certContext); - if (certContext != nullptr) { - // The hash is 20 bytes - BYTE hashData[20]; - DWORD hashLength = 20; - - // Buffer to print the hash. Each byte takes 2 chars + - // terminating character - char hashPrint[41]; - char* pHashPrint = hashPrint; - // Get the hash property from the certificate - if (CertGetCertificateContextProperty( - certContext, CERT_HASH_PROP_ID, hashData, &hashLength)) { - for (DWORD i = 0; i < hashLength; i++) { - // Convert each byte to hexadecimal - snprintf(pHashPrint, 3, "%02X", hashData[i]); - pHashPrint += 2; - } - *pHashPrint = '\0'; - thumbprint = hashPrint; - } - CertFreeCertificateContext(certContext); - } - CertCloseStore(certStore, 0); - } - } - } - } - } - CloseHandle(certFile); - } - - return thumbprint; -} -# endif -#endif - void cmSystemTools::Glob(const std::string& directory, const std::string& regexp, std::vector<std::string>& files) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 27d788e..9563fd6 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -22,7 +22,6 @@ #include "cmsys/Status.hxx" // IWYU pragma: export #include "cmsys/SystemTools.hxx" // IWYU pragma: export -#include "cmCryptoHash.h" #include "cmDuration.h" #include "cmProcessOutput.h" @@ -214,20 +213,6 @@ public: static void MoveFileIfDifferent(const std::string& source, const std::string& destination); -#ifndef CMAKE_BOOTSTRAP - //! Compute the hash of a file - static std::string ComputeFileHash(const std::string& source, - cmCryptoHash::Algo algo); - - /** Compute the md5sum of a string. */ - static std::string ComputeStringMD5(const std::string& input); - -# ifdef _WIN32 - //! Get the SHA thumbprint for a certificate file - static std::string ComputeCertificateThumbprint(const std::string& source); -# endif -#endif - /** * Run a single executable command * diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 700631c..48f3197 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -17,11 +17,14 @@ #include <cmext/string_view> #include "windows.h" +// include wincrypt.h after windows.h +#include <wincrypt.h> #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" #include "cmComputeLinkInformation.h" +#include "cmCryptoHash.h" #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmFileSet.h" @@ -1821,8 +1824,9 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( } script += lg->FinishConstructScript(this->ProjectType); if (this->ProjectType == VsProjectType::csproj) { - std::string name = cmStrCat("CustomCommand_", c, '_', - cmSystemTools::ComputeStringMD5(sourcePath)); + cmCryptoHash hasher(cmCryptoHash::AlgoMD5); + std::string name = + cmStrCat("CustomCommand_", c, '_', hasher.HashString(sourcePath)); this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(), outputs.str(), comment, ccg); } else { @@ -4865,6 +4869,73 @@ void cmVisualStudio10TargetGenerator::WriteSingleSDKReference( .Attribute("Include", cmStrCat(extension, ", Version=", version)); } +namespace { +std::string ComputeCertificateThumbprint(const std::string& source) +{ + std::string thumbprint; + + CRYPT_INTEGER_BLOB cryptBlob; + HCERTSTORE certStore = nullptr; + PCCERT_CONTEXT certContext = nullptr; + + HANDLE certFile = CreateFileW( + cmsys::Encoding::ToWide(source.c_str()).c_str(), GENERIC_READ, + FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + + if (certFile != INVALID_HANDLE_VALUE && certFile != nullptr) { + DWORD fileSize = GetFileSize(certFile, nullptr); + if (fileSize != INVALID_FILE_SIZE) { + auto certData = cm::make_unique<BYTE[]>(fileSize); + if (certData != nullptr) { + DWORD dwRead = 0; + if (ReadFile(certFile, certData.get(), fileSize, &dwRead, nullptr)) { + cryptBlob.cbData = fileSize; + cryptBlob.pbData = certData.get(); + + // Verify that this is a valid cert + if (PFXIsPFXBlob(&cryptBlob)) { + // Open the certificate as a store + certStore = + PFXImportCertStore(&cryptBlob, nullptr, CRYPT_EXPORTABLE); + if (certStore != nullptr) { + // There should only be 1 cert. + certContext = + CertEnumCertificatesInStore(certStore, certContext); + if (certContext != nullptr) { + // The hash is 20 bytes + BYTE hashData[20]; + DWORD hashLength = 20; + + // Buffer to print the hash. Each byte takes 2 chars + + // terminating character + char hashPrint[41]; + char* pHashPrint = hashPrint; + // Get the hash property from the certificate + if (CertGetCertificateContextProperty( + certContext, CERT_HASH_PROP_ID, hashData, &hashLength)) { + for (DWORD i = 0; i < hashLength; i++) { + // Convert each byte to hexadecimal + snprintf(pHashPrint, 3, "%02X", hashData[i]); + pHashPrint += 2; + } + *pHashPrint = '\0'; + thumbprint = hashPrint; + } + CertFreeCertificateContext(certContext); + } + CertCloseStore(certStore, 0); + } + } + } + } + } + CloseHandle(certFile); + } + + return thumbprint; +} +} + void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( Elem& e0) { @@ -4911,14 +4982,14 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile( } e1.Element("PackageCertificateKeyFile", pfxFile); - std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile); + std::string thumb = ComputeCertificateThumbprint(pfxFile); if (!thumb.empty()) { e1.Element("PackageCertificateThumbprint", thumb); } } else if (!pfxFile.empty()) { Elem e1(e0, "PropertyGroup"); e1.Element("PackageCertificateKeyFile", pfxFile); - std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile); + std::string thumb = ComputeCertificateThumbprint(pfxFile); if (!thumb.empty()) { e1.Element("PackageCertificateThumbprint", thumb); } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index ce2479b..b18f5cf 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -13,6 +13,7 @@ #include "cmCommandLineArgument.h" #include "cmConsoleBuf.h" +#include "cmCryptoHash.h" #include "cmDuration.h" #include "cmGlobalGenerator.h" #include "cmList.h" @@ -1692,11 +1693,8 @@ int cmcmd::HashSumFile(std::vector<std::string> const& args, std::cerr << "Error: " << filename << " is a directory" << std::endl; retval++; } else { - std::string value -#ifndef CMAKE_BOOTSTRAP - = cmSystemTools::ComputeFileHash(filename, algo) -#endif - ; + cmCryptoHash hasher(algo); + std::string value = hasher.HashFile(filename); if (value.empty()) { // To mimic "md5sum/shasum" behavior in a shell: std::cerr << filename << ": No such file or directory" << std::endl; |