From d8c4d84dc75300c6d4d8b0adceafa33741960b92 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 27 Sep 2025 18:38:35 +0200 Subject: added http lib, working on AI invoice importing --- .../projects/examples/msvc/.gitignore | 4 + .../projects/examples/msvc/cmac.props | 10 ++ .../projects/examples/msvc/cmac.vcxproj | 163 +++++++++++++++++++++ .../projects/examples/msvc/cmac.vcxproj.filters | 22 +++ .../projects/examples/msvc/examples.sln | 38 +++++ .../projects/examples/msvc/examples.sln.props | 13 ++ .../projects/examples/src/cmac.cpp | 57 +++++++ 7 files changed, 307 insertions(+) create mode 100644 libs/openssl-3.6.0-beta1/projects/examples/msvc/.gitignore create mode 100644 libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.props create mode 100644 libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.vcxproj create mode 100644 libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.vcxproj.filters create mode 100644 libs/openssl-3.6.0-beta1/projects/examples/msvc/examples.sln create mode 100644 libs/openssl-3.6.0-beta1/projects/examples/msvc/examples.sln.props create mode 100644 libs/openssl-3.6.0-beta1/projects/examples/src/cmac.cpp (limited to 'libs/openssl-3.6.0-beta1/projects/examples') diff --git a/libs/openssl-3.6.0-beta1/projects/examples/msvc/.gitignore b/libs/openssl-3.6.0-beta1/projects/examples/msvc/.gitignore new file mode 100644 index 0000000..ca7a019 --- /dev/null +++ b/libs/openssl-3.6.0-beta1/projects/examples/msvc/.gitignore @@ -0,0 +1,4 @@ +.vs/ +*.vcxproj.user +im-build/ +build-target/ diff --git a/libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.props b/libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.props new file mode 100644 index 0000000..86caddd --- /dev/null +++ b/libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.props @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.vcxproj b/libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.vcxproj new file mode 100644 index 0000000..3f41baa --- /dev/null +++ b/libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.vcxproj @@ -0,0 +1,163 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {f4535a44-e028-4687-84d2-ae48312d86bd} + cmac + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + true + _DEBUG;%(PreprocessorDefinitions) + true + stdcpplatest + /Zc:throwingNew /Zc:externConstexpr /Zc:__cplusplus %(AdditionalOptions) + true + true + $(IntDir)%(RelativeDir) + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;%(PreprocessorDefinitions) + true + stdcpplatest + /Zc:throwingNew /Zc:externConstexpr /Zc:__cplusplus %(AdditionalOptions) + true + true + $(IntDir)%(RelativeDir) + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;%(PreprocessorDefinitions) + true + stdcpplatest + /Zc:throwingNew /Zc:externConstexpr /Zc:__cplusplus %(AdditionalOptions) + true + true + $(IntDir)%(RelativeDir) + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;%(PreprocessorDefinitions) + true + stdcpplatest + /Zc:throwingNew /Zc:externConstexpr /Zc:__cplusplus %(AdditionalOptions) + true + true + $(IntDir)%(RelativeDir) + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.vcxproj.filters b/libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.vcxproj.filters new file mode 100644 index 0000000..8d14f3b --- /dev/null +++ b/libs/openssl-3.6.0-beta1/projects/examples/msvc/cmac.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/libs/openssl-3.6.0-beta1/projects/examples/msvc/examples.sln b/libs/openssl-3.6.0-beta1/projects/examples/msvc/examples.sln new file mode 100644 index 0000000..b5ec452 --- /dev/null +++ b/libs/openssl-3.6.0-beta1/projects/examples/msvc/examples.sln @@ -0,0 +1,38 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35122.118 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmac", "cmac.vcxproj", "{F4535A44-E028-4687-84D2-AE48312D86BD}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C914AA8D-1F0F-4DE5-A682-496B644808BC}" + ProjectSection(SolutionItems) = preProject + ..\..\.clang-format = ..\..\.clang-format + .gitignore = .gitignore + ..\..\readme.md = ..\..\readme.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F4535A44-E028-4687-84D2-AE48312D86BD}.Debug|x64.ActiveCfg = Debug|x64 + {F4535A44-E028-4687-84D2-AE48312D86BD}.Debug|x64.Build.0 = Debug|x64 + {F4535A44-E028-4687-84D2-AE48312D86BD}.Debug|x86.ActiveCfg = Debug|Win32 + {F4535A44-E028-4687-84D2-AE48312D86BD}.Debug|x86.Build.0 = Debug|Win32 + {F4535A44-E028-4687-84D2-AE48312D86BD}.Release|x64.ActiveCfg = Release|x64 + {F4535A44-E028-4687-84D2-AE48312D86BD}.Release|x64.Build.0 = Release|x64 + {F4535A44-E028-4687-84D2-AE48312D86BD}.Release|x86.ActiveCfg = Release|Win32 + {F4535A44-E028-4687-84D2-AE48312D86BD}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4E19D78C-DF54-43E6-BE8C-FDC282E3F7FC} + EndGlobalSection +EndGlobal diff --git a/libs/openssl-3.6.0-beta1/projects/examples/msvc/examples.sln.props b/libs/openssl-3.6.0-beta1/projects/examples/msvc/examples.sln.props new file mode 100644 index 0000000..5ea50fb --- /dev/null +++ b/libs/openssl-3.6.0-beta1/projects/examples/msvc/examples.sln.props @@ -0,0 +1,13 @@ + + + + + + + + $(SolutionDir)build-target\$(Platform)\$(Configuration)\ + $(SolutionDir)im-build\$(Platform)\$(ProjectName)\$(Configuration)\ + + + + \ No newline at end of file diff --git a/libs/openssl-3.6.0-beta1/projects/examples/src/cmac.cpp b/libs/openssl-3.6.0-beta1/projects/examples/src/cmac.cpp new file mode 100644 index 0000000..9e8397c --- /dev/null +++ b/libs/openssl-3.6.0-beta1/projects/examples/src/cmac.cpp @@ -0,0 +1,57 @@ +/* Simple test program for libcrypto (OpenSSL) CMAC ([found on](https://gist.github.com/enkore/56c756d32197f65ae7769e7f9e0a5d35)) + */ + +import std; +#include + +#include +#include +#include + +template +using fn_constant = std::integral_constant; +using cmac_ptr = std::unique_ptr>; +using cmac_ctx_ptr = std::unique_ptr>; + +int wmain() +{ + cmac_ptr cmac{EVP_MAC_fetch(nullptr, "CMAC", nullptr)}; + if (!cmac) { + return EXIT_FAILURE; + } + cmac_ctx_ptr ctx{EVP_MAC_CTX_new(cmac.get())}; + if (!cmac) { + return EXIT_FAILURE; + } + + /* The underlying cipher to be used */ + const EVP_CIPHER* cipher = EVP_aes_256_cbc(); + const char* cypherName = EVP_CIPHER_get0_name(cipher); + const int keyLength = EVP_CIPHER_get_key_length(cipher); + const OSSL_PARAM params[2] = {OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER, const_cast(cypherName), 0), + OSSL_PARAM_construct_end()}; + + std::vector key(keyLength, '\0'); + unsigned int msgLength = 1024 * 1024 * 1024; + std::vector msg(msgLength, '\0'); + + auto t0 = std::chrono::steady_clock::now(); + if (!EVP_MAC_init(ctx.get(), key.data(), key.size(), params)) { + return EXIT_FAILURE; + } + if (!EVP_MAC_update(ctx.get(), msg.data(), msgLength)) { + return EXIT_FAILURE; + } + size_t resultLength = 0; + EVP_MAC_final(ctx.get(), nullptr, &resultLength, 0); + std::vector result(resultLength, '\0'); + if (!EVP_MAC_final(ctx.get(), result.data(), &resultLength, resultLength)) { + return EXIT_FAILURE; + } + auto t1 = std::chrono::steady_clock::now(); + std::chrono::duration tdelta = t1 - t0; + + std::wcout << std::format(L"CMAC-AES-256'd {} bytes in {} ({:.1f} MiB/s)", msgLength, tdelta, msgLength / tdelta.count() / 1024 / 1024); + + return 0; +} -- cgit v1.2.3-70-g09d2