From f6cf50f58663e149a629bfdfcd252b6ff5c801cd Mon Sep 17 00:00:00 2001 From: Matthew Asplund Date: Wed, 20 Apr 2022 14:38:21 -0700 Subject: [PATCH] Mwasplund/cryptopp (#123) * Convert to CryptoPP with Sha1 * Update scripts * Remove submodules * Update docs * Bump version --- .github/workflows/main.yml | 4 +- .gitmodules | 6 -- Dependencies/Detours | 1 - Dependencies/openssl | 1 - Docs/Developer-Setup.md | 20 +---- Scripts/build.cmd | 4 +- Scripts/soup.cmd | 6 +- Scripts/soupd.cmd | 6 +- Source/Client/CLI/PackageLock.toml | 3 +- Source/Client/CLI/Recipe.toml | 2 +- .../CLI/Source/Commands/VersionCommand.h | 2 +- Source/Client/Core/Recipe.toml | 13 +-- .../Core/Source/Build/RecipeBuildRunner.h | 3 +- Source/Client/Core/Source/Module.cpp | 3 +- Source/Client/Core/Source/Sha3_256.h | 87 ------------------- .../Generate/Properties/launchSettings.json | 2 +- Source/Installer/SoupInstaller/Setup.cs | 2 +- Source/Monitor/Client/Recipe.toml | 2 +- Source/Monitor/Host/Recipe.toml | 2 +- Source/Monitor/Log/Recipe.toml | 2 +- 20 files changed, 25 insertions(+), 146 deletions(-) delete mode 100644 .gitmodules delete mode 160000 Dependencies/Detours delete mode 160000 Dependencies/openssl delete mode 100644 Source/Client/Core/Source/Sha3_256.h diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be64b17a..90515616 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,8 +38,8 @@ jobs: run: swhere - name: Soup Restore run: soup restore ./Soup/Source/Client/CLI/ -v:d - # TODO: Disabled for openssl - name: Soup Build - # run: soup build ./Soup/Source/Client/CLI/ -v:d -flavor ${{matrix.config}} + - name: Soup Build + run: soup build ./Soup/Source/Client/CLI/ -v:d -flavor ${{matrix.config}} # Build Samples - name: Soup Restore Cpp BuildExtension diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 7dad284c..00000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "Dependencies/openssl"] - path = Dependencies/openssl - url = https://github.com/openssl/openssl.git -[submodule "Dependencies/Detours"] - path = Dependencies/Detours - url = https://github.com/mwasplund/Detours.git diff --git a/Dependencies/Detours b/Dependencies/Detours deleted file mode 160000 index 245c9396..00000000 --- a/Dependencies/Detours +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 245c93969ad4213664cdc933dabce14c24e657f1 diff --git a/Dependencies/openssl b/Dependencies/openssl deleted file mode 160000 index b971d419..00000000 --- a/Dependencies/openssl +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b971d4198def0b29654e8fbf7987f7157741aed2 diff --git a/Docs/Developer-Setup.md b/Docs/Developer-Setup.md index 189c8f3b..88e24e2e 100644 --- a/Docs/Developer-Setup.md +++ b/Docs/Developer-Setup.md @@ -3,14 +3,10 @@ ## Requirements * Windows 10 * Build Tools - * [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) with "Desktop development with c++" workload. + * [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) with "Desktop development with c++" workload. * OR - * [Build Tools For Visual Studio 2019](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) with "c++ build tools" workload. -* [Latest Release](https://github.com/mwasplund/Soup/releases) - -### OpenSSL Requirements -* Perl. We recommend Strawberry https://strawberryperl.com/download/5.30.3.1/strawberry-perl-5.30.3.1-64bit.msi -* Netwide Assembler, a.k.a. NASM, available from https://www.nasm.us + * [Build Tools For Visual Studio 2022](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) with "c++ build tools" workload. +* [Latest Release](https://github.com/SoupBuild/Soup/releases) ## Setup Clone the repository and all submodules recursively. @@ -21,16 +17,6 @@ git clone --recursive https://github.com/mwasplund/Soup.git ## Build -### Build openssl -using x64 Native Tools Command Prompt for VS 2022 -``` -cd Dependencies/openssl -PATH=%PATH%;"C:\NASM" -perl Configure VC-WIN64A -nmake -nmake test -``` - ### Build the Client ``` cd Source/Client diff --git a/Scripts/build.cmd b/Scripts/build.cmd index 76086067..588075aa 100644 --- a/Scripts/build.cmd +++ b/Scripts/build.cmd @@ -7,8 +7,8 @@ SET ClientCLIDir=%SourceDir%\Client\CLI SET ExtensionCppDir=%SourceDir%\GenerateSharp\Extensions\Cpp\Extension SET ExtensionCSharpDir=%SourceDir%\GenerateSharp\Extensions\CSharp\Extension SET MonitorClientDir=%SourceDir%\Monitor\Client -if %Flavor% == release (SET OutputX64DirectorPath=1281a639dd5d393781f4188942c6bc05544b7c2c0124eae4cc59236248e36) else (SET OutputX64DirectorPath=3d80717e7d2695f0a7aa5c38e2849624beeaa5714331ca96898fe4b8b8023fe) -if %Flavor% == release (SET OutputX86DirectorPath=a15736f28dbf78415c82858ab76573eb6efdf98c85e3d67b3984210f54747) else (SET OutputX86DirectorPath=9e1e87dea39eeb349e44752a9a37cdf3ed1c2e7aea3044a45ed8bb44609efd) +if %Flavor% == release (SET OutputX64DirectorPath=txTMowfPh1V3rPmbvNBmBW9Z8Jg) else (SET OutputX64DirectorPath=J3mu4cpISw6nDaCPED8gkqZ-q84) +if %Flavor% == release (SET OutputX86DirectorPath=ci_UJP5zJKyF-O0VVSVDMNi1Wwg) else (SET OutputX86DirectorPath=9e1e87dea39eeb349e44752a9a37cdf3ed1c2e7aea3044a45ed8bb44609efd) SET ClientCLIOutputDirectory=%OutputDir%\C++\Soup\%OutputX64DirectorPath% SET MonitorClientOutputX64Directory=%OutputDir%\C++\Monitor.Client\%OutputX64DirectorPath% SET MonitorClientOutputX86Directory=%OutputDir%\C++\Monitor.Client\%OutputX86DirectorPath% diff --git a/Scripts/soup.cmd b/Scripts/soup.cmd index aa363ec5..0d7c6db0 100644 --- a/Scripts/soup.cmd +++ b/Scripts/soup.cmd @@ -5,10 +5,10 @@ SET OutDir=%RootDir%\out SET RunDir=%OutDir%\run REM - Use a copy of the final binary in case we are re-buiding itself robocopy %ScriptsDir%\Install\ %RunDir%\ /MIR /NJH /NJS /NDL > NUL -robocopy %OutDir%\C++\Soup\1281a639dd5d393781f4188942c6bc05544b7c2c0124eae4cc59236248e36\bin\ %RunDir%\Soup\ /MIR /NJH /NJS /NDL > NUL +robocopy %OutDir%\C++\Soup\txTMowfPh1V3rPmbvNBmBW9Z8Jg\bin\ %RunDir%\Soup\ /MIR /NJH /NJS /NDL > NUL robocopy %OutDir%\msbuild\bin\Soup.Build.Generate\Release\net5.0\ %RunDir%\Soup\Generate\ /MIR /NJH /NJS /NDL > NUL -robocopy %OutDir%\C#\Soup.Cpp\1281a639dd5d393781f4188942c6bc05544b7c2c0124eae4cc59236248e36\bin %RunDir%\Soup\Generate\Extensions\Soup.Cpp\ /MIR /NJH /NJS /NDL > NUL -robocopy %OutDir%\C#\Soup.CSharp\1281a639dd5d393781f4188942c6bc05544b7c2c0124eae4cc59236248e36\bin %RunDir%\Soup\Generate\Extensions\Soup.CSharp\ /MIR /NJH /NJS /NDL > NUL +robocopy %OutDir%\C#\Soup.Cpp\txTMowfPh1V3rPmbvNBmBW9Z8Jg\bin %RunDir%\Soup\Generate\Extensions\Soup.Cpp\ /MIR /NJH /NJS /NDL > NUL +robocopy %OutDir%\C#\Soup.CSharp\txTMowfPh1V3rPmbvNBmBW9Z8Jg\bin %RunDir%\Soup\Generate\Extensions\Soup.CSharp\ /MIR /NJH /NJS /NDL > NUL robocopy %OutDir%\msbuild\bin\Soup.Build.PackageManager\Release\net5-windows10.0.17763.0\ %RunDir%\Soup\PackageManager\ /MIR /NJH /NJS /NDL > NUL robocopy %OutDir%\msbuild\bin\Swhere\Release\net5-windows10.0.17763.0\ %RunDir%\Swhere\ /MIR /NJH /NJS /NDL > NUL %RunDir%\Soup.cmd %* \ No newline at end of file diff --git a/Scripts/soupd.cmd b/Scripts/soupd.cmd index 6ee9fc42..93fcc4d9 100644 --- a/Scripts/soupd.cmd +++ b/Scripts/soupd.cmd @@ -5,10 +5,10 @@ SET OutDir=%RootDir%\out SET RunDir=%OutDir%\run REM - Use a copy of the final binary in case we are re-buiding itself robocopy %ScriptsDir%\Install\ %RunDir%\ /MIR /NJH /NJS /NDL > NUL -robocopy %OutDir%\C++\Soup\3d80717e7d2695f0a7aa5c38e2849624beeaa5714331ca96898fe4b8b8023fe\bin\ %RunDir%\Soup\ /MIR /NJH /NJS /NDL > NUL +robocopy %OutDir%\C++\Soup\J3mu4cpISw6nDaCPED8gkqZ-q84\bin\ %RunDir%\Soup\ /MIR /NJH /NJS /NDL > NUL robocopy %OutDir%\msbuild\bin\Soup.Build.Generate\Debug\net5.0\ %RunDir%\Soup\Generate\ /MIR /NJH /NJS /NDL > NUL -robocopy %OutDir%\C#\Soup.Cpp\3d80717e7d2695f0a7aa5c38e2849624beeaa5714331ca96898fe4b8b8023fe\bin %RunDir%\Soup\Generate\Extensions\Soup.Cpp\ /MIR /NJH /NJS /NDL > NUL -robocopy %OutDir%\C#\Soup.CSharp\3d80717e7d2695f0a7aa5c38e2849624beeaa5714331ca96898fe4b8b8023fe\bin %RunDir%\Soup\Generate\Extensions\Soup.CSharp\ /MIR /NJH /NJS /NDL > NUL +robocopy %OutDir%\C#\Soup.Cpp\J3mu4cpISw6nDaCPED8gkqZ-q84\bin %RunDir%\Soup\Generate\Extensions\Soup.Cpp\ /MIR /NJH /NJS /NDL > NUL +robocopy %OutDir%\C#\Soup.CSharp\J3mu4cpISw6nDaCPED8gkqZ-q84\bin %RunDir%\Soup\Generate\Extensions\Soup.CSharp\ /MIR /NJH /NJS /NDL > NUL robocopy %OutDir%\msbuild\bin\Soup.Build.PackageManager\Debug\net5-windows10.0.17763.0\ %RunDir%\Soup\PackageManager\ /MIR /NJH /NJS /NDL > NUL robocopy %OutDir%\msbuild\bin\Swhere\Debug\net5-windows10.0.17763.0\ %RunDir%\Swhere\ /MIR /NJH /NJS /NDL > NUL %RunDir%\Soup.cmd %* \ No newline at end of file diff --git a/Source/Client/CLI/PackageLock.toml b/Source/Client/CLI/PackageLock.toml index 002506fe..c58c1210 100644 --- a/Source/Client/CLI/PackageLock.toml +++ b/Source/Client/CLI/PackageLock.toml @@ -2,11 +2,12 @@ "C++" = [ { Name = "Soup", Version = "./" }, { Name = "Soup.Core", Version = "../Core/" }, + { Name = "CryptoPP", Version = "CryptoPP@1.0.1" }, { Name = "json11", Version = "json11@1.0.1" }, { Name = "Opal", Version = "Opal@0.3.0" }, { Name = "toml11", Version = "toml11@1.0.1" }, { Name = "Monitor.Host", Version = "../../Monitor/Host/" }, - { Name = "Detours", Version = "../../../Dependencies/Detours/src/" }, + { Name = "Detours", Version = "Detours@4.0.1" }, { Name = "Monitor.Shared", Version = "../../../Monitor/Shared/" }, { Name = "Soup.Test.Assert", Version = "Soup.Test.Assert@0.1.8" }, { Name = "copy", Version = "../../Tools/Copy/" }, diff --git a/Source/Client/CLI/Recipe.toml b/Source/Client/CLI/Recipe.toml index e64fd72c..0e401512 100644 --- a/Source/Client/CLI/Recipe.toml +++ b/Source/Client/CLI/Recipe.toml @@ -1,6 +1,6 @@ Name = "Soup" Language = "C++" -Version = "0.17.6" +Version = "0.18.0" Type = "Executable" Source = [ diff --git a/Source/Client/CLI/Source/Commands/VersionCommand.h b/Source/Client/CLI/Source/Commands/VersionCommand.h index a7593d1f..d01ab164 100644 --- a/Source/Client/CLI/Source/Commands/VersionCommand.h +++ b/Source/Client/CLI/Source/Commands/VersionCommand.h @@ -31,7 +31,7 @@ namespace Soup::Client // TODO var version = Assembly.GetExecutingAssembly().GetName().Version; // Log::Message($"{version.Major}.{version.Minor}.{version.Build}"); - Log::HighPriority("0.17.6"); + Log::HighPriority("0.18.0"); } private: diff --git a/Source/Client/Core/Recipe.toml b/Source/Client/Core/Recipe.toml index e22d6704..90642dfd 100644 --- a/Source/Client/Core/Recipe.toml +++ b/Source/Client/Core/Recipe.toml @@ -7,24 +7,12 @@ Defines = [ ] IncludePaths = [ "Source/", - "../../../Dependencies/OpenSSL/include/", ] Interface = "Source/Module.cpp" Source = [ "Source/ValueTable/Value.cpp", ] -LinkLibraries = [ - # Link against the dynamic libraries - "../../../Dependencies/OpenSSL/libcrypto.lib", - "../../../Dependencies/OpenSSL/libssl.lib", -] -RuntimeDependencies = [ - # Copy the dynamic libraries - "../../../Dependencies/OpenSSL/libcrypto-3-x64.dll", - "../../../Dependencies/OpenSSL/libssl-3-x64.dll", -] - [Dependencies] Build = [ # "Soup.Test.Cpp@0.1.3", @@ -34,6 +22,7 @@ Runtime = [ "Opal@0.3.0", "toml11@1.0.1", "../../Monitor/Host/", + "CryptoPP@1.0.1", ] Test = [ "Soup.Test.Assert@0.1.8", diff --git a/Source/Client/Core/Source/Build/RecipeBuildRunner.h b/Source/Client/Core/Source/Build/RecipeBuildRunner.h index 5a275a4e..bf3e7ee2 100644 --- a/Source/Client/Core/Source/Build/RecipeBuildRunner.h +++ b/Source/Client/Core/Source/Build/RecipeBuildRunner.h @@ -12,7 +12,6 @@ #include "OperationGraph/OperationGraphManager.h" #include "Utils/HandledException.h" #include "ValueTable/ValueTableManager.h" -#include "Sha3_256.h" #include "Recipe/RecipeBuildStateConverter.h" #include "PathList/PathListManager.h" @@ -121,7 +120,7 @@ namespace Soup::Core // Add unique folder name for parameters auto parametersStream = std::stringstream(); ValueTableWriter::Serialize(globalParameters, parametersStream); - auto hashParameters = Sha3_256::HashBase64(parametersStream.str()); + auto hashParameters = CryptoPP::Sha1::HashBase64(parametersStream.str()); auto uniqueParametersFolder = Path(hashParameters + "/"); rootOutput = rootOutput + uniqueParametersFolder; diff --git a/Source/Client/Core/Source/Module.cpp b/Source/Client/Core/Source/Module.cpp index e9489dd2..61795ffc 100644 --- a/Source/Client/Core/Source/Module.cpp +++ b/Source/Client/Core/Source/Module.cpp @@ -28,10 +28,9 @@ #undef min #undef CreateProcess -#include - export module Soup.Core; +import CryptoPP; import json11; import toml11; import Monitor.Host; diff --git a/Source/Client/Core/Source/Sha3_256.h b/Source/Client/Core/Source/Sha3_256.h deleted file mode 100644 index 4a066da2..00000000 --- a/Source/Client/Core/Source/Sha3_256.h +++ /dev/null @@ -1,87 +0,0 @@ -// -// Copyright (c) Soup. All rights reserved. -// - -#pragma once - -namespace Soup::Core -{ - export class Sha3_256 - { - public: - /// - /// Hash the input value - /// - static std::string HashBase64(std::string value) - { - const EVP_MD* algorithm = EVP_sha3_256(); - - auto digestContext = EVP_MD_CTX_create(); - if (digestContext == nullptr) - throw new std::runtime_error("EVP_MD_CTX_create() failed"); - - // Initialize the digest engine - if (EVP_DigestInit_ex(digestContext, algorithm, NULL) != 1) - { - EVP_MD_CTX_destroy(digestContext); - throw new std::runtime_error("EVP_DigestInit_ex() failed"); - } - - // Pass the entire contents of the stream into the engine - if (EVP_DigestUpdate(digestContext, value.data(), value.size()) != 1) - { - EVP_MD_CTX_destroy(digestContext); - throw new std::runtime_error("EVP_DigestUpdate() failed"); - } - - // Allocate enough space for the digest - unsigned int digestLength = EVP_MD_size(algorithm); - auto digest = reinterpret_cast(OPENSSL_malloc(digestLength)); - if (digest == nullptr) - { - EVP_MD_CTX_destroy(digestContext); - throw new std::runtime_error("OPENSSL_malloc() failed"); - } - - // Produce the digest - if (EVP_DigestFinal_ex(digestContext, digest, &digestLength) != 1) - { - OPENSSL_free(digest); - EVP_MD_CTX_destroy(digestContext); - throw new std::runtime_error("EVP_DigestFinal_ex() failed"); - } - - // Base64 encode the result - // unsigned int encodedLength = 4* ((digestLength + 2) / 3); - // // +1 for the terminating null that EVP_EncodeBlock adds on - // auto encodedDigest = reinterpret_cast(OPENSSL_malloc(encodedLength + 1)); - // if (encodedDigest == nullptr) - // { - // OPENSSL_free(digest); - // EVP_MD_CTX_destroy(digestContext); - // throw new std::runtime_error("OPENSSL_malloc() failed"); - // } - - // unsigned int outLength = EVP_EncodeBlock(reinterpret_cast(encodedDigest), reinterpret_cast(digest), digestLength); - // if (encodedLength != outLength) - // { - // OPENSSL_free(digest); - // EVP_MD_CTX_destroy(digestContext); - // throw new std::runtime_error("EVP_EncodeBlock() Did not match length"); - // } - - // auto result = std::string(encodedDigest); - - std::stringstream result; - result << std::hex; - for (auto i = 0u; i < digestLength; i++) - result << (int)digest[i]; - - OPENSSL_free(digest); - // OPENSSL_free(encodedDigest); - EVP_MD_CTX_destroy(digestContext); - - return result.str(); - } - }; -} diff --git a/Source/GenerateSharp/Generate/Properties/launchSettings.json b/Source/GenerateSharp/Generate/Properties/launchSettings.json index 87954d10..da58a927 100644 --- a/Source/GenerateSharp/Generate/Properties/launchSettings.json +++ b/Source/GenerateSharp/Generate/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Soup.Build.Generate": { "commandName": "Project", - "commandLineArgs": "C:\\Users\\mwasp\\source\\repos\\SoupTest\\out\\C++\\Cpp.Sample\\3d80717e7d2695f0a7aa5c38e2849624beeaa5714331ca96898fe4b8b8023fe\\.soup\\" + "commandLineArgs": "C:\\Users\\mwasp\\source\\repos\\SoupTest\\out\\C++\\Cpp.Sample\\J3mu4cpISw6nDaCPED8gkqZ-q84\\.soup\\" } } } \ No newline at end of file diff --git a/Source/Installer/SoupInstaller/Setup.cs b/Source/Installer/SoupInstaller/Setup.cs index 3d4cf8fe..acc3f923 100644 --- a/Source/Installer/SoupInstaller/Setup.cs +++ b/Source/Installer/SoupInstaller/Setup.cs @@ -65,7 +65,7 @@ static public void Main() }; // Upgrade values - project.Version = new Version(0, 17, 5); + project.Version = new Version(0, 18, 0); Compiler.BuildMsi(project); } diff --git a/Source/Monitor/Client/Recipe.toml b/Source/Monitor/Client/Recipe.toml index cab29b3b..b92c626a 100644 --- a/Source/Monitor/Client/Recipe.toml +++ b/Source/Monitor/Client/Recipe.toml @@ -13,7 +13,7 @@ Source = [ [Dependencies] Runtime = [ - "../../../Dependencies/Detours/src/", + "Detours@4.0.1", "../Shared/", "Opal@0.3.0" ] diff --git a/Source/Monitor/Host/Recipe.toml b/Source/Monitor/Host/Recipe.toml index 7e92e636..380326f8 100644 --- a/Source/Monitor/Host/Recipe.toml +++ b/Source/Monitor/Host/Recipe.toml @@ -8,7 +8,7 @@ Interface = "Module.cpp" [Dependencies] Runtime = [ - "../../../Dependencies/Detours/src/", + "Detours@4.0.1", "../Shared/", "Opal@0.3.0", ] \ No newline at end of file diff --git a/Source/Monitor/Log/Recipe.toml b/Source/Monitor/Log/Recipe.toml index d1900e6f..9f6584ac 100644 --- a/Source/Monitor/Log/Recipe.toml +++ b/Source/Monitor/Log/Recipe.toml @@ -9,7 +9,7 @@ Source = [ [Dependencies] Runtime = [ - "../../../Dependencies/Detours/src/", + "Detours@4.0.1", "Opal@0.3.0", "../Shared/", ]