diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-09-27 18:38:35 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-09-27 18:38:35 +0200 |
| commit | d8c4d84dc75300c6d4d8b0adceafa33741960b92 (patch) | |
| tree | 00e2dfcc5c836d62fccff76c862e6ec3b0a74db8 /libs/openssl-3.6.0-beta1/projects/examples | |
| parent | fa088bb60692ba02d30d39affa9a31d9e2b688e2 (diff) | |
added http lib, working on AI invoice importing
Diffstat (limited to 'libs/openssl-3.6.0-beta1/projects/examples')
7 files changed, 307 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ImportGroup Label="PropertySheets"> + <Import Project="examples.sln.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup /> + <ItemDefinitionGroup /> + <ItemGroup /> +</Project>
\ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>17.0</VCProjectVersion> + <Keyword>Win32Proj</Keyword> + <ProjectGuid>{f4535a44-e028-4687-84d2-ae48312d86bd}</ProjectGuid> + <RootNamespace>cmac</RootNamespace> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="cmac.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="cmac.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="cmac.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="cmac.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <LanguageStandard>stdcpplatest</LanguageStandard> + <AdditionalOptions>/Zc:throwingNew /Zc:externConstexpr /Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions> + <EnforceTypeConversionRules>true</EnforceTypeConversionRules> + <BuildStlModules>true</BuildStlModules> + <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <LanguageStandard>stdcpplatest</LanguageStandard> + <AdditionalOptions>/Zc:throwingNew /Zc:externConstexpr /Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions> + <EnforceTypeConversionRules>true</EnforceTypeConversionRules> + <BuildStlModules>true</BuildStlModules> + <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <LanguageStandard>stdcpplatest</LanguageStandard> + <AdditionalOptions>/Zc:throwingNew /Zc:externConstexpr /Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions> + <EnforceTypeConversionRules>true</EnforceTypeConversionRules> + <BuildStlModules>true</BuildStlModules> + <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <LanguageStandard>stdcpplatest</LanguageStandard> + <AdditionalOptions>/Zc:throwingNew /Zc:externConstexpr /Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions> + <EnforceTypeConversionRules>true</EnforceTypeConversionRules> + <BuildStlModules>true</BuildStlModules> + <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\src\cmac.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\src\cmac.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ImportGroup Label="PropertySheets"> + <Import Project="..\..\auxiliary\build\msvc\openssl-3.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <OutDir>$(SolutionDir)build-target\$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(SolutionDir)im-build\$(Platform)\$(ProjectName)\$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup /> + <ItemGroup /> +</Project>
\ 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 <stdlib.h> + +#include <openssl/cmac.h> +#include <openssl/core_names.h> +#include <openssl/evp.h> + +template<auto fn> +using fn_constant = std::integral_constant<decltype(fn), fn>; +using cmac_ptr = std::unique_ptr<EVP_MAC, fn_constant<EVP_MAC_free>>; +using cmac_ctx_ptr = std::unique_ptr<EVP_MAC_CTX, fn_constant<EVP_MAC_CTX_free>>; + +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<char*>(cypherName), 0), + OSSL_PARAM_construct_end()}; + + std::vector<unsigned char> key(keyLength, '\0'); + unsigned int msgLength = 1024 * 1024 * 1024; + std::vector<unsigned char> 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<unsigned char> 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<double> 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; +} |
