mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-19 00:46:03 +01:00
Crypto: complete merge to 1.4.2
This commit is contained in:
parent
e0c42bb6f4
commit
bcf1d5b6a7
60
Crypto/Crypto_vs100.sln
Normal file
60
Crypto/Crypto_vs100.sln
Normal file
@ -0,0 +1,60 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crypto", "Crypto_vs100.vcxproj", "{EEEE7259-32E9-4D56-B023-C733940AB2A0}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs100.vcxproj", "{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0} = {EEEE7259-32E9-4D56-B023-C733940AB2A0}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
debug_shared|Win32 = debug_shared|Win32
|
||||
release_shared|Win32 = release_shared|Win32
|
||||
debug_static_mt|Win32 = debug_static_mt|Win32
|
||||
release_static_mt|Win32 = release_static_mt|Win32
|
||||
debug_static_md|Win32 = debug_static_md|Win32
|
||||
release_static_md|Win32 = release_static_md|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_shared|Win32.Deploy.0 = release_shared|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_md|Win32.Build.0 = release_static_md|Win32
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_shared|Win32.Deploy.0 = release_shared|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_md|Win32.Build.0 = release_static_md|Win32
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
302
Crypto/Crypto_vs100.vcxproj
Normal file
302
Crypto/Crypto_vs100.vcxproj
Normal file
@ -0,0 +1,302 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="debug_shared|Win32">
|
||||
<Configuration>debug_shared</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_md|Win32">
|
||||
<Configuration>debug_static_md</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_mt|Win32">
|
||||
<Configuration>debug_static_mt</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_shared|Win32">
|
||||
<Configuration>release_shared</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_md|Win32">
|
||||
<Configuration>release_static_md</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_mt|Win32">
|
||||
<Configuration>release_static_mt</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>Crypto</ProjectName>
|
||||
<ProjectGuid>{EEEE7259-32E9-4D56-B023-C733940AB2A0}</ProjectGuid>
|
||||
<RootNamespace>Crypto</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
||||
<ImportGroup Label="ExtensionSettings"/>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros"/>
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">..\bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">..\bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">..\lib\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">..\lib\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">..\lib\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">..\lib\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">PocoCryptod</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">PocoCryptomdd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">PocoCryptomtd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">PocoCrypto</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">PocoCryptomd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">PocoCryptomt</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;Crypto_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;libeay32mdd.lib;ssleay32mdd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>..\bin\PocoCryptod.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>..\bin\PocoCryptod.pdb</ProgramDatabaseFile>
|
||||
<AdditionalLibraryDirectories>..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<ImportLibrary>..\lib\PocoCryptod.lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;Crypto_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;libeay32md.lib;ssleay32md.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>..\bin\PocoCrypto.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<ImportLibrary>..\lib\PocoCrypto.lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<ProgramDataBaseFileName>..\lib\PocoCryptomtd.pdb</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>..\lib\PocoCryptomtd.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>..\lib\PocoCryptomt.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<ProgramDataBaseFileName>..\lib\PocoCryptomdd.pdb</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>..\lib\PocoCryptomdd.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<ProgramDataBaseFileName>..\lib\PocoCryptomd.pdb</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;libeay32md.lib;ssleay32md.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>..\lib\PocoCryptomd.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\Poco\Crypto\Cipher.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherFactory.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherImpl.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherKey.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherKeyImpl.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CryptoStream.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CryptoTransform.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\RSACipherImpl.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\RSADigestEngine.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\RSAKey.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\RSAKeyImpl.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\X509Certificate.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\Crypto.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\OpenSSLInitializer.h"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Cipher.cpp"/>
|
||||
<ClCompile Include="src\CipherFactory.cpp"/>
|
||||
<ClCompile Include="src\CipherImpl.cpp"/>
|
||||
<ClCompile Include="src\CipherKey.cpp"/>
|
||||
<ClCompile Include="src\CipherKeyImpl.cpp"/>
|
||||
<ClCompile Include="src\CryptoStream.cpp"/>
|
||||
<ClCompile Include="src\CryptoTransform.cpp"/>
|
||||
<ClCompile Include="src\RSACipherImpl.cpp"/>
|
||||
<ClCompile Include="src\RSADigestEngine.cpp"/>
|
||||
<ClCompile Include="src\RSAKey.cpp"/>
|
||||
<ClCompile Include="src\RSAKeyImpl.cpp"/>
|
||||
<ClCompile Include="src\X509Certificate.cpp"/>
|
||||
<ClCompile Include="src\OpenSSLInitializer.cpp"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
||||
<ImportGroup Label="ExtensionTargets"/>
|
||||
</Project>
|
126
Crypto/Crypto_vs100.vcxproj.filters
Normal file
126
Crypto/Crypto_vs100.vcxproj.filters
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Cipher">
|
||||
<UniqueIdentifier>{494614b9-ff62-40c6-91bb-bee55822a32e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Cipher\Header Files">
|
||||
<UniqueIdentifier>{30fa87c2-b839-4e52-b062-de65113e61e6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Cipher\Source Files">
|
||||
<UniqueIdentifier>{9c8f63cf-3ed3-4862-aa28-ca44827a72fd}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="RSA">
|
||||
<UniqueIdentifier>{6e2c751b-f898-414c-91df-2e2e104e9d1c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="RSA\Header Files">
|
||||
<UniqueIdentifier>{e10faa98-897c-4f37-b917-ca21a0a19d70}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="RSA\Source Files">
|
||||
<UniqueIdentifier>{18391081-1244-4748-9bb5-8c5051c06e3a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Certificate">
|
||||
<UniqueIdentifier>{2489f73e-efa2-417c-8529-a381b58a8c4b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Certificate\Header Files">
|
||||
<UniqueIdentifier>{73afffe0-13d5-4f60-b6ba-f87ff4579693}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Certificate\Source Files">
|
||||
<UniqueIdentifier>{be3fb73d-748e-48a5-8fe4-e08a86aa031a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="CryptoCore">
|
||||
<UniqueIdentifier>{9e89bb4f-2da8-4ba1-a29a-4a89016afa13}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="CryptoCore\Header Files">
|
||||
<UniqueIdentifier>{14d5d623-0dd2-4e61-be3a-6eebb5138c6e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="CryptoCore\Source Files">
|
||||
<UniqueIdentifier>{953bd7b6-fa63-457d-a46f-f766e0a23659}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\Poco\Crypto\Cipher.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherFactory.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherImpl.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherKey.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherKeyImpl.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CryptoStream.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CryptoTransform.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\RSACipherImpl.h">
|
||||
<Filter>RSA\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\RSADigestEngine.h">
|
||||
<Filter>RSA\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\RSAKey.h">
|
||||
<Filter>RSA\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\RSAKeyImpl.h">
|
||||
<Filter>RSA\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\X509Certificate.h">
|
||||
<Filter>Certificate\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\Crypto.h">
|
||||
<Filter>CryptoCore\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\OpenSSLInitializer.h">
|
||||
<Filter>CryptoCore\Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Cipher.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CipherFactory.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CipherImpl.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CipherKey.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CipherKeyImpl.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CryptoStream.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CryptoTransform.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSACipherImpl.cpp">
|
||||
<Filter>RSA\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSADigestEngine.cpp">
|
||||
<Filter>RSA\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSAKey.cpp">
|
||||
<Filter>RSA\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSAKeyImpl.cpp">
|
||||
<Filter>RSA\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\X509Certificate.cpp">
|
||||
<Filter>Certificate\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\OpenSSLInitializer.cpp">
|
||||
<Filter>CryptoCore\Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
3
Crypto/Crypto_vs100.vcxproj.user
Normal file
3
Crypto/Crypto_vs100.vcxproj.user
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
60
Crypto/Crypto_x64_vs100.sln
Normal file
60
Crypto/Crypto_x64_vs100.sln
Normal file
@ -0,0 +1,60 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crypto", "Crypto_x64_vs100.vcxproj", "{EEEE7259-32E9-4D56-B023-C733940AB2A0}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_x64_vs100.vcxproj", "{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0} = {EEEE7259-32E9-4D56-B023-C733940AB2A0}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
debug_shared|x64 = debug_shared|x64
|
||||
release_shared|x64 = release_shared|x64
|
||||
debug_static_mt|x64 = debug_static_mt|x64
|
||||
release_static_mt|x64 = release_static_mt|x64
|
||||
debug_static_md|x64 = debug_static_md|x64
|
||||
release_static_md|x64 = release_static_md|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_shared|x64.ActiveCfg = debug_shared|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_shared|x64.Build.0 = debug_shared|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_shared|x64.Deploy.0 = debug_shared|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_shared|x64.ActiveCfg = release_shared|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_shared|x64.Build.0 = release_shared|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_shared|x64.Deploy.0 = release_shared|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_mt|x64.ActiveCfg = debug_static_mt|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_mt|x64.Build.0 = debug_static_mt|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_mt|x64.Deploy.0 = debug_static_mt|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_mt|x64.ActiveCfg = release_static_mt|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_mt|x64.Build.0 = release_static_mt|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_mt|x64.Deploy.0 = release_static_mt|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_md|x64.ActiveCfg = debug_static_md|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_md|x64.Build.0 = debug_static_md|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static_md|x64.Deploy.0 = debug_static_md|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_md|x64.ActiveCfg = release_static_md|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_md|x64.Build.0 = release_static_md|x64
|
||||
{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static_md|x64.Deploy.0 = release_static_md|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_shared|x64.ActiveCfg = debug_shared|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_shared|x64.Build.0 = debug_shared|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_shared|x64.Deploy.0 = debug_shared|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_shared|x64.ActiveCfg = release_shared|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_shared|x64.Build.0 = release_shared|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_shared|x64.Deploy.0 = release_shared|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_mt|x64.ActiveCfg = debug_static_mt|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_mt|x64.Build.0 = debug_static_mt|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_mt|x64.Deploy.0 = debug_static_mt|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_mt|x64.ActiveCfg = release_static_mt|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_mt|x64.Build.0 = release_static_mt|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_mt|x64.Deploy.0 = release_static_mt|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_md|x64.ActiveCfg = debug_static_md|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_md|x64.Build.0 = debug_static_md|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static_md|x64.Deploy.0 = debug_static_md|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_md|x64.ActiveCfg = release_static_md|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_md|x64.Build.0 = release_static_md|x64
|
||||
{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static_md|x64.Deploy.0 = release_static_md|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
300
Crypto/Crypto_x64_vs100.vcxproj
Normal file
300
Crypto/Crypto_x64_vs100.vcxproj
Normal file
@ -0,0 +1,300 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="debug_shared|x64">
|
||||
<Configuration>debug_shared</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_md|x64">
|
||||
<Configuration>debug_static_md</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_mt|x64">
|
||||
<Configuration>debug_static_mt</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_shared|x64">
|
||||
<Configuration>release_shared</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_md|x64">
|
||||
<Configuration>release_static_md</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_mt|x64">
|
||||
<Configuration>release_static_mt</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>Crypto</ProjectName>
|
||||
<ProjectGuid>{EEEE7259-32E9-4D56-B023-C733940AB2A0}</ProjectGuid>
|
||||
<RootNamespace>Crypto</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
||||
<ImportGroup Label="ExtensionSettings"/>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros"/>
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">..\bin64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">..\bin64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">..\lib64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">..\lib64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">..\lib64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">..\lib64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">PocoCrypto64d</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">PocoCryptomdd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">PocoCryptomtd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">PocoCrypto64</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">PocoCryptomd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">PocoCryptomt</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;Crypto_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;libeay32mdd.lib;ssleay32mdd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>..\bin64\PocoCrypto64d.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>..\bin64\PocoCrypto64d.pdb</ProgramDatabaseFile>
|
||||
<AdditionalLibraryDirectories>..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<ImportLibrary>..\lib64\PocoCryptod.lib</ImportLibrary>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;Crypto_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;libeay32md.lib;ssleay32md.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>..\bin64\PocoCrypto64.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<ImportLibrary>..\lib64\PocoCrypto.lib</ImportLibrary>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<ProgramDataBaseFileName>..\lib64\PocoCryptomtd.pdb</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>..\lib64\PocoCryptomtd.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>..\lib64\PocoCryptomt.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<ProgramDataBaseFileName>..\lib64\PocoCryptomdd.pdb</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>..\lib64\PocoCryptomdd.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>..\lib64\PocoCryptomd.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\Poco\Crypto\Cipher.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherFactory.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherImpl.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherKey.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherKeyImpl.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CryptoStream.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\CryptoTransform.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\RSACipherImpl.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\RSADigestEngine.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\RSAKey.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\RSAKeyImpl.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\X509Certificate.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\Crypto.h"/>
|
||||
<ClInclude Include="include\Poco\Crypto\OpenSSLInitializer.h"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Cipher.cpp"/>
|
||||
<ClCompile Include="src\CipherFactory.cpp"/>
|
||||
<ClCompile Include="src\CipherImpl.cpp"/>
|
||||
<ClCompile Include="src\CipherKey.cpp"/>
|
||||
<ClCompile Include="src\CipherKeyImpl.cpp"/>
|
||||
<ClCompile Include="src\CryptoStream.cpp"/>
|
||||
<ClCompile Include="src\CryptoTransform.cpp"/>
|
||||
<ClCompile Include="src\RSACipherImpl.cpp"/>
|
||||
<ClCompile Include="src\RSADigestEngine.cpp"/>
|
||||
<ClCompile Include="src\RSAKey.cpp"/>
|
||||
<ClCompile Include="src\RSAKeyImpl.cpp"/>
|
||||
<ClCompile Include="src\X509Certificate.cpp"/>
|
||||
<ClCompile Include="src\OpenSSLInitializer.cpp"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
||||
<ImportGroup Label="ExtensionTargets"/>
|
||||
</Project>
|
126
Crypto/Crypto_x64_vs100.vcxproj.filters
Normal file
126
Crypto/Crypto_x64_vs100.vcxproj.filters
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Cipher">
|
||||
<UniqueIdentifier>{fb87242a-c5c9-427d-8c5b-ff7e973a09d2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Cipher\Header Files">
|
||||
<UniqueIdentifier>{29625e7a-4c64-4f46-a160-696f5df0bf0f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Cipher\Source Files">
|
||||
<UniqueIdentifier>{863b337e-7970-47a3-8c3a-ac7ca18fff1a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="RSA">
|
||||
<UniqueIdentifier>{9bfb5ff5-db5b-4920-b1fa-4f670bb6ed15}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="RSA\Header Files">
|
||||
<UniqueIdentifier>{987d81ee-3336-4a5c-9bda-1e58081dea22}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="RSA\Source Files">
|
||||
<UniqueIdentifier>{7fd9a8fd-a722-4926-a7ed-3b4bc1bd51d3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Certificate">
|
||||
<UniqueIdentifier>{8ac4a3ba-cfae-43d5-997d-c2a61fdfd88b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Certificate\Header Files">
|
||||
<UniqueIdentifier>{78a5514f-52e9-437f-98ac-c03037383c4a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Certificate\Source Files">
|
||||
<UniqueIdentifier>{e986f474-79c0-4f8e-aace-1fa5b5c8b609}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="CryptoCore">
|
||||
<UniqueIdentifier>{0a48cb3b-08ac-4a8c-9197-1d02406f7e58}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="CryptoCore\Header Files">
|
||||
<UniqueIdentifier>{3ac5d95d-62d7-46c2-8acb-7e3b2b5e24f0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="CryptoCore\Source Files">
|
||||
<UniqueIdentifier>{52c2a894-ba8f-4207-83c1-7c10309b15fc}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\Poco\Crypto\Cipher.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherFactory.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherImpl.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherKey.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CipherKeyImpl.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CryptoStream.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\CryptoTransform.h">
|
||||
<Filter>Cipher\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\RSACipherImpl.h">
|
||||
<Filter>RSA\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\RSADigestEngine.h">
|
||||
<Filter>RSA\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\RSAKey.h">
|
||||
<Filter>RSA\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\RSAKeyImpl.h">
|
||||
<Filter>RSA\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\X509Certificate.h">
|
||||
<Filter>Certificate\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\Crypto.h">
|
||||
<Filter>CryptoCore\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Poco\Crypto\OpenSSLInitializer.h">
|
||||
<Filter>CryptoCore\Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Cipher.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CipherFactory.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CipherImpl.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CipherKey.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CipherKeyImpl.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CryptoStream.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CryptoTransform.cpp">
|
||||
<Filter>Cipher\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSACipherImpl.cpp">
|
||||
<Filter>RSA\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSADigestEngine.cpp">
|
||||
<Filter>RSA\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSAKey.cpp">
|
||||
<Filter>RSA\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSAKeyImpl.cpp">
|
||||
<Filter>RSA\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\X509Certificate.cpp">
|
||||
<Filter>Certificate\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\OpenSSLInitializer.cpp">
|
||||
<Filter>CryptoCore\Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
3
Crypto/Crypto_x64_vs100.vcxproj.user
Normal file
3
Crypto/Crypto_x64_vs100.vcxproj.user
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
@ -112,9 +112,12 @@ public:
|
||||
enum Encoding
|
||||
/// Transport encoding to use for encryptString() and decryptString().
|
||||
{
|
||||
ENC_NONE, /// Plain binary output
|
||||
ENC_BASE64, /// Base64-encoded output
|
||||
ENC_BINHEX /// BinHex-encoded output
|
||||
ENC_NONE = 0x00, /// Plain binary output
|
||||
ENC_BASE64 = 0x01, /// Base64-encoded output
|
||||
ENC_BINHEX = 0x02, /// BinHex-encoded output
|
||||
ENC_BASE64_NO_LF = 0x81, /// Base64-encoded output, no linefeeds
|
||||
ENC_BINHEX_NO_LF = 0x82, /// BinHex-encoded output, no linefeeds
|
||||
|
||||
};
|
||||
|
||||
virtual ~Cipher();
|
||||
|
@ -86,8 +86,6 @@ public:
|
||||
/// Returns the default CipherFactory.
|
||||
|
||||
private:
|
||||
static int _instanceCount;
|
||||
|
||||
CipherFactory(const CipherFactory&);
|
||||
CipherFactory& operator = (const CipherFactory&);
|
||||
};
|
||||
|
@ -1,90 +1,91 @@
|
||||
//
|
||||
// CipherImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherImpl.h#3 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherImpl
|
||||
//
|
||||
// Definition of the CipherImpl class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_CipherImpl_INCLUDED
|
||||
#define Crypto_CipherImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/Cipher.h"
|
||||
#include "Poco/Crypto/CipherKey.h"
|
||||
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class CipherImpl: public Cipher
|
||||
/// An implementation of the Cipher class for OpenSSL's crypto library.
|
||||
{
|
||||
public:
|
||||
CipherImpl(const CipherKey& key);
|
||||
/// Creates a new CipherImpl object for the given CipherKey.
|
||||
|
||||
virtual ~CipherImpl();
|
||||
/// Destroys the CipherImpl.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the cipher.
|
||||
|
||||
CryptoTransform* createEncryptor();
|
||||
/// Creates an encrytor object.
|
||||
|
||||
CryptoTransform* createDecryptor();
|
||||
/// Creates a decrytor object.
|
||||
|
||||
private:
|
||||
CipherKey _key;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Inlines
|
||||
//
|
||||
inline const std::string& CipherImpl::name() const
|
||||
{
|
||||
return _key.name();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_CipherImpl_INCLUDED
|
||||
//
|
||||
// CipherImpl.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherImpl.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherImpl
|
||||
//
|
||||
// Definition of the CipherImpl class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_CipherImpl_INCLUDED
|
||||
#define Crypto_CipherImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/Cipher.h"
|
||||
#include "Poco/Crypto/CipherKey.h"
|
||||
#include "Poco/Crypto/OpenSSLInitializer.h"
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class CipherImpl: public Cipher
|
||||
/// An implementation of the Cipher class for OpenSSL's crypto library.
|
||||
{
|
||||
public:
|
||||
CipherImpl(const CipherKey& key);
|
||||
/// Creates a new CipherImpl object for the given CipherKey.
|
||||
|
||||
virtual ~CipherImpl();
|
||||
/// Destroys the CipherImpl.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the cipher.
|
||||
|
||||
CryptoTransform* createEncryptor();
|
||||
/// Creates an encrytor object.
|
||||
|
||||
CryptoTransform* createDecryptor();
|
||||
/// Creates a decrytor object.
|
||||
|
||||
private:
|
||||
CipherKey _key;
|
||||
OpenSSLInitializer _openSSLInitializer;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Inlines
|
||||
//
|
||||
inline const std::string& CipherImpl::name() const
|
||||
{
|
||||
return _key.name();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_CipherImpl_INCLUDED
|
||||
|
@ -1,204 +1,204 @@
|
||||
//
|
||||
// CipherKey.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherKey.h#2 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherKey
|
||||
//
|
||||
// Definition of the CipherKey class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_CipherKey_INCLUDED
|
||||
#define Crypto_CipherKey_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/CipherKeyImpl.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class Crypto_API CipherKey
|
||||
/// CipherKey stores the key information for decryption/encryption of data.
|
||||
/// To create a random key, using the following code:
|
||||
///
|
||||
/// CipherKey key("aes-256");
|
||||
///
|
||||
/// Note that you won't be able to decrypt data encrypted with a random key
|
||||
/// once the Cipher is destroyed unless you persist the generated key and IV.
|
||||
/// An example usage for random keys is to encrypt data saved in a temporary
|
||||
/// file.
|
||||
///
|
||||
/// To create a key using a human-readable password
|
||||
/// string, use the following code. We create a AES Cipher and
|
||||
/// use a salt value to make the key more robust:
|
||||
///
|
||||
/// std::string password = "secret";
|
||||
/// std::string salt("asdff8723lasdf(**923412");
|
||||
/// CipherKey key("aes-256", password, salt);
|
||||
///
|
||||
{
|
||||
public:
|
||||
typedef CipherKeyImpl::Mode Mode;
|
||||
typedef CipherKeyImpl::ByteVec ByteVec;
|
||||
|
||||
enum
|
||||
{
|
||||
DEFAULT_ITERATION_COUNT = 2000
|
||||
/// Default iteration count to use with
|
||||
/// generateKey(). RSA security recommends
|
||||
/// an iteration count of at least 1000.
|
||||
};
|
||||
|
||||
CipherKey(const std::string& name,
|
||||
const std::string& passphrase,
|
||||
const std::string& salt = "",
|
||||
int iterationCount = DEFAULT_ITERATION_COUNT);
|
||||
/// Creates a new CipherKeyImpl object using the given
|
||||
/// cipher name, passphrase, salt value and iteration count.
|
||||
|
||||
CipherKey(const std::string& name,
|
||||
const ByteVec& key,
|
||||
const ByteVec& iv);
|
||||
/// Creates a new CipherKeyImpl object using the given cipher
|
||||
/// name, key and initialization vector.
|
||||
|
||||
CipherKey(const std::string& name);
|
||||
/// Creates a new CipherKeyImpl object. Autoinitializes key and
|
||||
/// initialization vector.
|
||||
|
||||
~CipherKey();
|
||||
/// Destroys the CipherKeyImpl.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the Cipher.
|
||||
|
||||
int keySize() const;
|
||||
/// Returns the key size of the Cipher.
|
||||
|
||||
int blockSize() const;
|
||||
/// Returns the block size of the Cipher.
|
||||
|
||||
int ivSize() const;
|
||||
/// Returns the IV size of the Cipher.
|
||||
|
||||
Mode mode() const;
|
||||
/// Returns the Cipher's mode of operation.
|
||||
|
||||
const ByteVec& getKey() const;
|
||||
/// Returns the key for the Cipher.
|
||||
|
||||
void setKey(const ByteVec& key);
|
||||
/// Sets the key for the Cipher.
|
||||
|
||||
const ByteVec& getIV() const;
|
||||
/// Returns the initialization vector (IV) for the Cipher.
|
||||
|
||||
void setIV(const ByteVec& iv);
|
||||
/// Sets the initialization vector (IV) for the Cipher.
|
||||
|
||||
CipherKeyImpl::Ptr impl();
|
||||
/// Returns the impl object
|
||||
|
||||
private:
|
||||
CipherKeyImpl::Ptr _pImpl;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const std::string& CipherKey::name() const
|
||||
{
|
||||
return _pImpl->name();
|
||||
}
|
||||
|
||||
|
||||
inline int CipherKey::keySize() const
|
||||
{
|
||||
return _pImpl->keySize();
|
||||
}
|
||||
|
||||
|
||||
inline int CipherKey::blockSize() const
|
||||
{
|
||||
return _pImpl->blockSize();
|
||||
}
|
||||
|
||||
|
||||
inline int CipherKey::ivSize() const
|
||||
{
|
||||
return _pImpl->ivSize();
|
||||
}
|
||||
|
||||
|
||||
inline CipherKey::Mode CipherKey::mode() const
|
||||
{
|
||||
return _pImpl->mode();
|
||||
}
|
||||
|
||||
|
||||
inline const CipherKey::ByteVec& CipherKey::getKey() const
|
||||
{
|
||||
return _pImpl->getKey();
|
||||
}
|
||||
|
||||
|
||||
inline void CipherKey::setKey(const CipherKey::ByteVec& key)
|
||||
{
|
||||
_pImpl->setKey(key);
|
||||
}
|
||||
|
||||
|
||||
inline const CipherKey::ByteVec& CipherKey::getIV() const
|
||||
{
|
||||
return _pImpl->getIV();
|
||||
}
|
||||
|
||||
|
||||
inline void CipherKey::setIV(const CipherKey::ByteVec& iv)
|
||||
{
|
||||
_pImpl->setIV(iv);
|
||||
}
|
||||
|
||||
|
||||
inline CipherKeyImpl::Ptr CipherKey::impl()
|
||||
{
|
||||
return _pImpl;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_CipherKey_INCLUDED
|
||||
//
|
||||
// CipherKey.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherKey.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherKey
|
||||
//
|
||||
// Definition of the CipherKey class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_CipherKey_INCLUDED
|
||||
#define Crypto_CipherKey_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/CipherKeyImpl.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class Crypto_API CipherKey
|
||||
/// CipherKey stores the key information for decryption/encryption of data.
|
||||
/// To create a random key, using the following code:
|
||||
///
|
||||
/// CipherKey key("aes-256");
|
||||
///
|
||||
/// Note that you won't be able to decrypt data encrypted with a random key
|
||||
/// once the Cipher is destroyed unless you persist the generated key and IV.
|
||||
/// An example usage for random keys is to encrypt data saved in a temporary
|
||||
/// file.
|
||||
///
|
||||
/// To create a key using a human-readable password
|
||||
/// string, use the following code. We create a AES Cipher and
|
||||
/// use a salt value to make the key more robust:
|
||||
///
|
||||
/// std::string password = "secret";
|
||||
/// std::string salt("asdff8723lasdf(**923412");
|
||||
/// CipherKey key("aes-256", password, salt);
|
||||
///
|
||||
{
|
||||
public:
|
||||
typedef CipherKeyImpl::Mode Mode;
|
||||
typedef CipherKeyImpl::ByteVec ByteVec;
|
||||
|
||||
enum
|
||||
{
|
||||
DEFAULT_ITERATION_COUNT = 2000
|
||||
/// Default iteration count to use with
|
||||
/// generateKey(). RSA security recommends
|
||||
/// an iteration count of at least 1000.
|
||||
};
|
||||
|
||||
CipherKey(const std::string& name,
|
||||
const std::string& passphrase,
|
||||
const std::string& salt = "",
|
||||
int iterationCount = DEFAULT_ITERATION_COUNT);
|
||||
/// Creates a new CipherKeyImpl object using the given
|
||||
/// cipher name, passphrase, salt value and iteration count.
|
||||
|
||||
CipherKey(const std::string& name,
|
||||
const ByteVec& key,
|
||||
const ByteVec& iv);
|
||||
/// Creates a new CipherKeyImpl object using the given cipher
|
||||
/// name, key and initialization vector.
|
||||
|
||||
CipherKey(const std::string& name);
|
||||
/// Creates a new CipherKeyImpl object. Autoinitializes key and
|
||||
/// initialization vector.
|
||||
|
||||
~CipherKey();
|
||||
/// Destroys the CipherKeyImpl.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the Cipher.
|
||||
|
||||
int keySize() const;
|
||||
/// Returns the key size of the Cipher.
|
||||
|
||||
int blockSize() const;
|
||||
/// Returns the block size of the Cipher.
|
||||
|
||||
int ivSize() const;
|
||||
/// Returns the IV size of the Cipher.
|
||||
|
||||
Mode mode() const;
|
||||
/// Returns the Cipher's mode of operation.
|
||||
|
||||
const ByteVec& getKey() const;
|
||||
/// Returns the key for the Cipher.
|
||||
|
||||
void setKey(const ByteVec& key);
|
||||
/// Sets the key for the Cipher.
|
||||
|
||||
const ByteVec& getIV() const;
|
||||
/// Returns the initialization vector (IV) for the Cipher.
|
||||
|
||||
void setIV(const ByteVec& iv);
|
||||
/// Sets the initialization vector (IV) for the Cipher.
|
||||
|
||||
CipherKeyImpl::Ptr impl();
|
||||
/// Returns the impl object
|
||||
|
||||
private:
|
||||
CipherKeyImpl::Ptr _pImpl;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const std::string& CipherKey::name() const
|
||||
{
|
||||
return _pImpl->name();
|
||||
}
|
||||
|
||||
|
||||
inline int CipherKey::keySize() const
|
||||
{
|
||||
return _pImpl->keySize();
|
||||
}
|
||||
|
||||
|
||||
inline int CipherKey::blockSize() const
|
||||
{
|
||||
return _pImpl->blockSize();
|
||||
}
|
||||
|
||||
|
||||
inline int CipherKey::ivSize() const
|
||||
{
|
||||
return _pImpl->ivSize();
|
||||
}
|
||||
|
||||
|
||||
inline CipherKey::Mode CipherKey::mode() const
|
||||
{
|
||||
return _pImpl->mode();
|
||||
}
|
||||
|
||||
|
||||
inline const CipherKey::ByteVec& CipherKey::getKey() const
|
||||
{
|
||||
return _pImpl->getKey();
|
||||
}
|
||||
|
||||
|
||||
inline void CipherKey::setKey(const CipherKey::ByteVec& key)
|
||||
{
|
||||
_pImpl->setKey(key);
|
||||
}
|
||||
|
||||
|
||||
inline const CipherKey::ByteVec& CipherKey::getIV() const
|
||||
{
|
||||
return _pImpl->getIV();
|
||||
}
|
||||
|
||||
|
||||
inline void CipherKey::setIV(const CipherKey::ByteVec& iv)
|
||||
{
|
||||
_pImpl->setIV(iv);
|
||||
}
|
||||
|
||||
|
||||
inline CipherKeyImpl::Ptr CipherKey::impl()
|
||||
{
|
||||
return _pImpl;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_CipherKey_INCLUDED
|
||||
|
@ -1,190 +1,192 @@
|
||||
//
|
||||
// CipherKeyImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherKeyImpl.h#2 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherKeyImpl
|
||||
//
|
||||
// Definition of the CipherKeyImpl class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_CipherKeyImpl_INCLUDED
|
||||
#define Crypto_CipherKeyImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
struct evp_cipher_st;
|
||||
typedef struct evp_cipher_st EVP_CIPHER;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class CipherKeyImpl: public RefCountedObject
|
||||
/// An implementation of the CipherKey class for OpenSSL's crypto library.
|
||||
{
|
||||
public:
|
||||
typedef std::vector<unsigned char> ByteVec;
|
||||
typedef Poco::AutoPtr<CipherKeyImpl> Ptr;
|
||||
|
||||
enum Mode
|
||||
/// Cipher mode of operation. This mode determines how multiple blocks
|
||||
/// are connected; this is essential to improve security.
|
||||
{
|
||||
MODE_STREAM_CIPHER, /// Stream cipher
|
||||
MODE_ECB, /// Electronic codebook (plain concatenation)
|
||||
MODE_CBC, /// Cipher block chaining (default)
|
||||
MODE_CFB, /// Cipher feedback
|
||||
MODE_OFB /// Output feedback
|
||||
};
|
||||
|
||||
CipherKeyImpl(const std::string& name,
|
||||
const std::string& passphrase,
|
||||
const std::string& salt,
|
||||
int iterationCount);
|
||||
/// Creates a new CipherKeyImpl object, using
|
||||
/// the given cipher name, passphrase, salt value
|
||||
/// and iteration count.
|
||||
|
||||
CipherKeyImpl(const std::string& name,
|
||||
const ByteVec& key,
|
||||
const ByteVec& iv);
|
||||
/// Creates a new CipherKeyImpl object, using the
|
||||
/// given cipher name, key and initialization vector.
|
||||
|
||||
CipherKeyImpl(const std::string& name);
|
||||
/// Creates a new CipherKeyImpl object. Autoinitializes key
|
||||
/// and initialization vector.
|
||||
|
||||
virtual ~CipherKeyImpl();
|
||||
/// Destroys the CipherKeyImpl.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the Cipher.
|
||||
|
||||
int keySize() const;
|
||||
/// Returns the key size of the Cipher.
|
||||
|
||||
int blockSize() const;
|
||||
/// Returns the block size of the Cipher.
|
||||
|
||||
int ivSize() const;
|
||||
/// Returns the IV size of the Cipher.
|
||||
|
||||
Mode mode() const;
|
||||
/// Returns the Cipher's mode of operation.
|
||||
|
||||
const ByteVec& getKey() const;
|
||||
/// Returns the key for the Cipher.
|
||||
|
||||
void setKey(const ByteVec& key);
|
||||
/// Sets the key for the Cipher.
|
||||
|
||||
const ByteVec& getIV() const;
|
||||
/// Returns the initialization vector (IV) for the Cipher.
|
||||
|
||||
void setIV(const ByteVec& iv);
|
||||
/// Sets the initialization vector (IV) for the Cipher.
|
||||
|
||||
const EVP_CIPHER* cipher();
|
||||
/// Returns the cipher object
|
||||
|
||||
private:
|
||||
void generateKey(const std::string& passphrase,
|
||||
const std::string& salt,
|
||||
int iterationCount);
|
||||
/// Generates key and IV from a password and optional salt string.
|
||||
|
||||
void generateKey();
|
||||
/// Generates key and IV from random data.
|
||||
|
||||
void getRandomBytes(ByteVec& vec, std::size_t count);
|
||||
/// Stores random bytes in vec.
|
||||
|
||||
private:
|
||||
const EVP_CIPHER* _pCipher;
|
||||
std::string _name;
|
||||
ByteVec _key;
|
||||
ByteVec _iv;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Inlines
|
||||
//
|
||||
inline const std::string& CipherKeyImpl::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getKey() const
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
|
||||
inline void CipherKeyImpl::setKey(const ByteVec& key)
|
||||
{
|
||||
poco_assert(key.size() == keySize());
|
||||
_key = key;
|
||||
}
|
||||
|
||||
|
||||
inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getIV() const
|
||||
{
|
||||
return _iv;
|
||||
}
|
||||
|
||||
|
||||
inline void CipherKeyImpl::setIV(const ByteVec& iv)
|
||||
{
|
||||
poco_assert(iv.size() == ivSize());
|
||||
_iv = iv;
|
||||
}
|
||||
|
||||
|
||||
inline const EVP_CIPHER* CipherKeyImpl::cipher()
|
||||
{
|
||||
return _pCipher;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_CipherKeyImpl_INCLUDED
|
||||
//
|
||||
// CipherKeyImpl.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherKeyImpl.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherKeyImpl
|
||||
//
|
||||
// Definition of the CipherKeyImpl class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_CipherKeyImpl_INCLUDED
|
||||
#define Crypto_CipherKeyImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/OpenSSLInitializer.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
struct evp_cipher_st;
|
||||
typedef struct evp_cipher_st EVP_CIPHER;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class CipherKeyImpl: public RefCountedObject
|
||||
/// An implementation of the CipherKey class for OpenSSL's crypto library.
|
||||
{
|
||||
public:
|
||||
typedef std::vector<unsigned char> ByteVec;
|
||||
typedef Poco::AutoPtr<CipherKeyImpl> Ptr;
|
||||
|
||||
enum Mode
|
||||
/// Cipher mode of operation. This mode determines how multiple blocks
|
||||
/// are connected; this is essential to improve security.
|
||||
{
|
||||
MODE_STREAM_CIPHER, /// Stream cipher
|
||||
MODE_ECB, /// Electronic codebook (plain concatenation)
|
||||
MODE_CBC, /// Cipher block chaining (default)
|
||||
MODE_CFB, /// Cipher feedback
|
||||
MODE_OFB /// Output feedback
|
||||
};
|
||||
|
||||
CipherKeyImpl(const std::string& name,
|
||||
const std::string& passphrase,
|
||||
const std::string& salt,
|
||||
int iterationCount);
|
||||
/// Creates a new CipherKeyImpl object, using
|
||||
/// the given cipher name, passphrase, salt value
|
||||
/// and iteration count.
|
||||
|
||||
CipherKeyImpl(const std::string& name,
|
||||
const ByteVec& key,
|
||||
const ByteVec& iv);
|
||||
/// Creates a new CipherKeyImpl object, using the
|
||||
/// given cipher name, key and initialization vector.
|
||||
|
||||
CipherKeyImpl(const std::string& name);
|
||||
/// Creates a new CipherKeyImpl object. Autoinitializes key
|
||||
/// and initialization vector.
|
||||
|
||||
virtual ~CipherKeyImpl();
|
||||
/// Destroys the CipherKeyImpl.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the Cipher.
|
||||
|
||||
int keySize() const;
|
||||
/// Returns the key size of the Cipher.
|
||||
|
||||
int blockSize() const;
|
||||
/// Returns the block size of the Cipher.
|
||||
|
||||
int ivSize() const;
|
||||
/// Returns the IV size of the Cipher.
|
||||
|
||||
Mode mode() const;
|
||||
/// Returns the Cipher's mode of operation.
|
||||
|
||||
const ByteVec& getKey() const;
|
||||
/// Returns the key for the Cipher.
|
||||
|
||||
void setKey(const ByteVec& key);
|
||||
/// Sets the key for the Cipher.
|
||||
|
||||
const ByteVec& getIV() const;
|
||||
/// Returns the initialization vector (IV) for the Cipher.
|
||||
|
||||
void setIV(const ByteVec& iv);
|
||||
/// Sets the initialization vector (IV) for the Cipher.
|
||||
|
||||
const EVP_CIPHER* cipher();
|
||||
/// Returns the cipher object
|
||||
|
||||
private:
|
||||
void generateKey(const std::string& passphrase,
|
||||
const std::string& salt,
|
||||
int iterationCount);
|
||||
/// Generates key and IV from a password and optional salt string.
|
||||
|
||||
void generateKey();
|
||||
/// Generates key and IV from random data.
|
||||
|
||||
void getRandomBytes(ByteVec& vec, std::size_t count);
|
||||
/// Stores random bytes in vec.
|
||||
|
||||
private:
|
||||
const EVP_CIPHER* _pCipher;
|
||||
std::string _name;
|
||||
ByteVec _key;
|
||||
ByteVec _iv;
|
||||
OpenSSLInitializer _openSSLInitializer;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Inlines
|
||||
//
|
||||
inline const std::string& CipherKeyImpl::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getKey() const
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
|
||||
inline void CipherKeyImpl::setKey(const ByteVec& key)
|
||||
{
|
||||
poco_assert(key.size() == keySize());
|
||||
_key = key;
|
||||
}
|
||||
|
||||
|
||||
inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getIV() const
|
||||
{
|
||||
return _iv;
|
||||
}
|
||||
|
||||
|
||||
inline void CipherKeyImpl::setIV(const ByteVec& iv)
|
||||
{
|
||||
poco_assert(iv.size() == ivSize());
|
||||
_iv = iv;
|
||||
}
|
||||
|
||||
|
||||
inline const EVP_CIPHER* CipherKeyImpl::cipher()
|
||||
{
|
||||
return _pCipher;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_CipherKeyImpl_INCLUDED
|
||||
|
@ -42,6 +42,12 @@
|
||||
#define Crypto_Crypto_INCLUDED
|
||||
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// OS X 10.7 deprecates some OpenSSL functions
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
@ -93,21 +99,37 @@ enum RSAPaddingMode
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(Crypto_EXPORTS)
|
||||
#if defined(POCO_DLL)
|
||||
#if defined(_DEBUG)
|
||||
#pragma comment(lib, "PocoCryptod.lib")
|
||||
#else
|
||||
#pragma comment(lib, "PocoCrypto.lib")
|
||||
#endif
|
||||
#else
|
||||
#if defined(_DEBUG)
|
||||
#pragma comment(lib, "PocoCryptomtd.lib")
|
||||
#else
|
||||
#pragma comment(lib, "PocoCryptomt.lib")
|
||||
#endif
|
||||
#endif
|
||||
#pragma comment(lib, "PocoCrypto" POCO_LIB_SUFFIX)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
void Crypto_API initializeCrypto();
|
||||
/// Initialize the Crypto library, as well as the underlying OpenSSL
|
||||
/// libraries, by calling OpenSSLInitializer::initialize().
|
||||
///
|
||||
/// Should be called before using any class from the Crypto library.
|
||||
/// The Crypto library will be initialized automatically, through
|
||||
/// OpenSSLInitializer instances held by various Crypto classes
|
||||
/// (Cipher, CipherKey, RSAKey, X509Certificate).
|
||||
/// However, it is recommended to call initializeCrypto()
|
||||
/// in any case at application startup.
|
||||
///
|
||||
/// Can be called multiple times; however, for every call to
|
||||
/// initializeCrypto(), a matching call to uninitializeCrypto()
|
||||
/// must be performed.
|
||||
|
||||
|
||||
void Crypto_API uninitializeCrypto();
|
||||
/// Uninitializes the Crypto library by calling
|
||||
/// OpenSSLInitializer::uninitialize().
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_Crypto_INCLUDED
|
||||
|
@ -145,8 +145,66 @@ public:
|
||||
~CryptoOutputStream();
|
||||
/// Destroys the CryptoOutputStream.
|
||||
|
||||
void close();
|
||||
/// Flushes all buffers and finishes the encryption.
|
||||
void close();
|
||||
/// Flushes all buffers and finishes the encryption.
|
||||
};
|
||||
|
||||
|
||||
class Crypto_API DecryptingInputStream: public CryptoIOS, public std::istream
|
||||
/// This stream decrypts all data passing through it using the given
|
||||
/// Cipher.
|
||||
{
|
||||
public:
|
||||
DecryptingInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize = 8192);
|
||||
/// Create a new DecryptingInputStream object using the given cipher.
|
||||
|
||||
~DecryptingInputStream();
|
||||
/// Destroys the DecryptingInputStream.
|
||||
};
|
||||
|
||||
|
||||
class Crypto_API DecryptingOutputStream: public CryptoIOS, public std::ostream
|
||||
/// This stream decrypts all data passing through it using the given
|
||||
/// Cipher.
|
||||
{
|
||||
public:
|
||||
DecryptingOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize = 8192);
|
||||
/// Create a new DecryptingOutputStream object using the given cipher.
|
||||
|
||||
~DecryptingOutputStream();
|
||||
/// Destroys the DecryptingOutputStream.
|
||||
|
||||
void close();
|
||||
/// Flushes all buffers and finishes the decryption.
|
||||
};
|
||||
|
||||
|
||||
class Crypto_API EncryptingInputStream: public CryptoIOS, public std::istream
|
||||
/// This stream encrypts all data passing through it using the given
|
||||
/// Cipher.
|
||||
{
|
||||
public:
|
||||
EncryptingInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize = 8192);
|
||||
/// Create a new EncryptingInputStream object using the given cipher.
|
||||
|
||||
~EncryptingInputStream();
|
||||
/// Destroys the EncryptingInputStream.
|
||||
};
|
||||
|
||||
|
||||
class Crypto_API EncryptingOutputStream: public CryptoIOS, public std::ostream
|
||||
/// This stream encrypts all data passing through it using the given
|
||||
/// Cipher.
|
||||
{
|
||||
public:
|
||||
EncryptingOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize = 8192);
|
||||
/// Create a new EncryptingOutputStream object using the given cipher.
|
||||
|
||||
~EncryptingOutputStream();
|
||||
/// Destroys the EncryptingOutputStream.
|
||||
|
||||
void close();
|
||||
/// Flushes all buffers and finishes the encryption.
|
||||
};
|
||||
|
||||
|
||||
|
@ -74,13 +74,13 @@ public:
|
||||
/// Transforms a chunk of data. The inputLength is arbitrary and does not
|
||||
/// need to be a multiple of the block size. The output buffer has a maximum
|
||||
/// capacity of the given outputLength that must be at least
|
||||
/// inputLength + bufferSize() - 1
|
||||
/// inputLength + blockSize() - 1
|
||||
/// Returns the number of bytes written to the output buffer.
|
||||
|
||||
virtual std::streamsize finalize(unsigned char* output, std::streamsize length) = 0;
|
||||
/// Finalizes the transformation. The output buffer must contain enough
|
||||
/// space for at least one block, ie.
|
||||
/// length >= bufferSize()
|
||||
/// space for at least two blocks, ie.
|
||||
/// length >= 2*blockSize()
|
||||
/// must be true. Returns the number of bytes written to the output
|
||||
/// buffer.
|
||||
};
|
||||
|
@ -1,101 +1,133 @@
|
||||
//
|
||||
// OpenSSLInitializer.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/include/Poco/Crypto/OpenSSLInitializer.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: CryptoCore
|
||||
// Module: OpenSSLInitializer
|
||||
//
|
||||
// Definition of the OpenSSLInitializer class.
|
||||
//
|
||||
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_OpenSSLInitializer_INCLUDED
|
||||
#define Crypto_OpenSSLInitializer_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Mutex.h"
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
struct CRYPTO_dynlock_value
|
||||
{
|
||||
Poco::FastMutex _mutex;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class Crypto_API OpenSSLInitializer
|
||||
/// Initalizes the OpenSSL library.
|
||||
///
|
||||
/// The class ensures the earliest initialization and the
|
||||
/// latest shutdown of the OpenSSL library.
|
||||
{
|
||||
public:
|
||||
OpenSSLInitializer();
|
||||
/// Automatically initialize OpenSSL on startup.
|
||||
|
||||
~OpenSSLInitializer();
|
||||
/// Automatically shut down OpenSSL on exit.
|
||||
|
||||
static void initialize();
|
||||
/// Initializes the OpenSSL machinery.
|
||||
|
||||
static void uninitialize();
|
||||
/// Shuts down the OpenSSL machinery.
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
SEEDSIZE = 256
|
||||
};
|
||||
|
||||
// OpenSSL multithreading support
|
||||
static void lock(int mode, int n, const char* file, int line);
|
||||
static unsigned long id();
|
||||
static struct CRYPTO_dynlock_value* dynlockCreate(const char* file, int line);
|
||||
static void dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line);
|
||||
static void dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line);
|
||||
|
||||
private:
|
||||
static Poco::FastMutex* _mutexes;
|
||||
static int _rc;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_OpenSSLInitializer_INCLUDED
|
||||
//
|
||||
// OpenSSLInitializer.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/OpenSSLInitializer.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: CryptoCore
|
||||
// Module: OpenSSLInitializer
|
||||
//
|
||||
// Definition of the OpenSSLInitializer class.
|
||||
//
|
||||
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_OpenSSLInitializer_INCLUDED
|
||||
#define Crypto_OpenSSLInitializer_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifdef OPENSSL_FIPS
|
||||
#include <openssl/fips.h>
|
||||
#endif
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
struct CRYPTO_dynlock_value
|
||||
{
|
||||
Poco::FastMutex _mutex;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class Crypto_API OpenSSLInitializer
|
||||
/// Initalizes the OpenSSL library.
|
||||
///
|
||||
/// The class ensures the earliest initialization and the
|
||||
/// latest shutdown of the OpenSSL library.
|
||||
{
|
||||
public:
|
||||
OpenSSLInitializer();
|
||||
/// Automatically initialize OpenSSL on startup.
|
||||
|
||||
~OpenSSLInitializer();
|
||||
/// Automatically shut down OpenSSL on exit.
|
||||
|
||||
static void initialize();
|
||||
/// Initializes the OpenSSL machinery.
|
||||
|
||||
static void uninitialize();
|
||||
/// Shuts down the OpenSSL machinery.
|
||||
|
||||
static bool isFIPSEnabled();
|
||||
// Returns true if FIPS mode is enabled, false otherwise.
|
||||
|
||||
static void enableFIPSMode(bool enabled);
|
||||
// Enable or disable FIPS mode. If FIPS is not available, this method doesn't do anything.
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
SEEDSIZE = 256
|
||||
};
|
||||
|
||||
// OpenSSL multithreading support
|
||||
static void lock(int mode, int n, const char* file, int line);
|
||||
static unsigned long id();
|
||||
static struct CRYPTO_dynlock_value* dynlockCreate(const char* file, int line);
|
||||
static void dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line);
|
||||
static void dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line);
|
||||
|
||||
private:
|
||||
static Poco::FastMutex* _mutexes;
|
||||
static Poco::FastMutex _mutex;
|
||||
static int _rc;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline bool OpenSSLInitializer::isFIPSEnabled()
|
||||
{
|
||||
#ifdef OPENSSL_FIPS
|
||||
return FIPS_mode() ? true : false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline void OpenSSLInitializer::enableFIPSMode(bool enabled)
|
||||
{
|
||||
#ifdef OPENSSL_FIPS
|
||||
FIPS_mode_set(enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_OpenSSLInitializer_INCLUDED
|
||||
|
@ -1,97 +1,99 @@
|
||||
//
|
||||
// RSACipherImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSACipherImpl.h#2 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSACipherImpl
|
||||
//
|
||||
// Definition of the RSACipherImpl class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_RSACipherImpl_INCLUDED
|
||||
#define Crypto_RSACipherImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/Cipher.h"
|
||||
#include "Poco/Crypto/RSAKey.h"
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class RSACipherImpl: public Cipher
|
||||
/// An implementation of the Cipher class for
|
||||
/// assymetric (public-private key) encryption
|
||||
/// based on the the RSA algorithm in OpenSSL's
|
||||
/// crypto library.
|
||||
///
|
||||
/// Encryption is using the public key, decryption
|
||||
/// requires the private key.
|
||||
{
|
||||
public:
|
||||
RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode);
|
||||
/// Creates a new RSACipherImpl object for the given RSAKey
|
||||
/// and using the given padding mode.
|
||||
|
||||
virtual ~RSACipherImpl();
|
||||
/// Destroys the RSACipherImpl.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the Cipher.
|
||||
|
||||
CryptoTransform* createEncryptor();
|
||||
/// Creates an encrytor object.
|
||||
|
||||
CryptoTransform* createDecryptor();
|
||||
/// Creates a decrytor object.
|
||||
|
||||
private:
|
||||
RSAKey _key;
|
||||
RSAPaddingMode _paddingMode;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Inlines
|
||||
//
|
||||
inline const std::string& RSACipherImpl::name() const
|
||||
{
|
||||
return _key.name();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_RSACipherImpl_INCLUDED
|
||||
//
|
||||
// RSACipherImpl.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSACipherImpl.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSACipherImpl
|
||||
//
|
||||
// Definition of the RSACipherImpl class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_RSACipherImpl_INCLUDED
|
||||
#define Crypto_RSACipherImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/Cipher.h"
|
||||
#include "Poco/Crypto/RSAKey.h"
|
||||
#include "Poco/Crypto/OpenSSLInitializer.h"
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class RSACipherImpl: public Cipher
|
||||
/// An implementation of the Cipher class for
|
||||
/// assymetric (public-private key) encryption
|
||||
/// based on the the RSA algorithm in OpenSSL's
|
||||
/// crypto library.
|
||||
///
|
||||
/// Encryption is using the public key, decryption
|
||||
/// requires the private key.
|
||||
{
|
||||
public:
|
||||
RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode);
|
||||
/// Creates a new RSACipherImpl object for the given RSAKey
|
||||
/// and using the given padding mode.
|
||||
|
||||
virtual ~RSACipherImpl();
|
||||
/// Destroys the RSACipherImpl.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the Cipher.
|
||||
|
||||
CryptoTransform* createEncryptor();
|
||||
/// Creates an encrytor object.
|
||||
|
||||
CryptoTransform* createDecryptor();
|
||||
/// Creates a decrytor object.
|
||||
|
||||
private:
|
||||
RSAKey _key;
|
||||
RSAPaddingMode _paddingMode;
|
||||
OpenSSLInitializer _openSSLInitializer;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Inlines
|
||||
//
|
||||
inline const std::string& RSACipherImpl::name() const
|
||||
{
|
||||
return _key.name();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_RSACipherImpl_INCLUDED
|
||||
|
@ -1,128 +1,128 @@
|
||||
//
|
||||
// RSADigestEngine.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSADigestEngine.h#2 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSADigestEngine
|
||||
//
|
||||
// Definition of the RSADigestEngine class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_RSADigestEngine_INCLUDED
|
||||
#define Crypto_RSADigestEngine_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/RSAKey.h"
|
||||
#include "Poco/DigestEngine.h"
|
||||
#include "Poco/MD5Engine.h"
|
||||
#include "Poco/SHA1Engine.h"
|
||||
#include <openssl/rsa.h>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class Crypto_API RSADigestEngine: public Poco::DigestEngine
|
||||
/// This class implements a Poco::DigestEngine that can be
|
||||
/// used to compute a secure digital signature.
|
||||
///
|
||||
/// First another Poco::DigestEngine (Poco::MD5Engine
|
||||
/// or Poco::SHA1Engine) is used to compute a cryptographic
|
||||
/// hash of the data to be signed. Then, the hash value is
|
||||
/// encrypted, using the RSA private key.
|
||||
///
|
||||
/// To verify a signature, pass it to the verify()
|
||||
/// member function. It will decrypt the signature
|
||||
/// using the RSA public key and compare the resulting
|
||||
/// hash with the actual hash of the data.
|
||||
{
|
||||
public:
|
||||
enum DigestType
|
||||
{
|
||||
DIGEST_MD5,
|
||||
DIGEST_SHA1
|
||||
};
|
||||
|
||||
RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1);
|
||||
/// Creates the RSADigestEngine with the given RSA key,
|
||||
/// using the SHA-1 hash algorithm.
|
||||
|
||||
~RSADigestEngine();
|
||||
/// Destroys the RSADigestEngine.
|
||||
|
||||
unsigned digestLength() const;
|
||||
/// Returns the length of the digest in bytes.
|
||||
|
||||
void reset();
|
||||
/// Resets the engine so that a new
|
||||
/// digest can be computed.
|
||||
|
||||
const DigestEngine::Digest& digest();
|
||||
/// Finishes the computation of the digest
|
||||
/// (the first time it's called) and
|
||||
/// returns the message digest.
|
||||
///
|
||||
/// Can be called multiple times.
|
||||
|
||||
const DigestEngine::Digest& signature();
|
||||
/// Signs the digest using the RSA algorithm
|
||||
/// and the private key (teh first time it's
|
||||
/// called) and returns the result.
|
||||
///
|
||||
/// Can be called multiple times.
|
||||
|
||||
bool verify(const DigestEngine::Digest& signature);
|
||||
/// Verifies the data against the signature.
|
||||
///
|
||||
/// Returns true if the signature can be verified, false otherwise.
|
||||
|
||||
protected:
|
||||
void updateImpl(const void* data, unsigned length);
|
||||
|
||||
private:
|
||||
RSAKey _key;
|
||||
Poco::DigestEngine& _engine;
|
||||
int _type;
|
||||
Poco::DigestEngine::Digest _digest;
|
||||
Poco::DigestEngine::Digest _signature;
|
||||
Poco::MD5Engine _md5Engine;
|
||||
Poco::SHA1Engine _sha1Engine;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_RSADigestEngine_INCLUDED
|
||||
//
|
||||
// RSADigestEngine.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSADigestEngine.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSADigestEngine
|
||||
//
|
||||
// Definition of the RSADigestEngine class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_RSADigestEngine_INCLUDED
|
||||
#define Crypto_RSADigestEngine_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/RSAKey.h"
|
||||
#include "Poco/DigestEngine.h"
|
||||
#include "Poco/MD5Engine.h"
|
||||
#include "Poco/SHA1Engine.h"
|
||||
#include <openssl/rsa.h>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class Crypto_API RSADigestEngine: public Poco::DigestEngine
|
||||
/// This class implements a Poco::DigestEngine that can be
|
||||
/// used to compute a secure digital signature.
|
||||
///
|
||||
/// First another Poco::DigestEngine (Poco::MD5Engine
|
||||
/// or Poco::SHA1Engine) is used to compute a cryptographic
|
||||
/// hash of the data to be signed. Then, the hash value is
|
||||
/// encrypted, using the RSA private key.
|
||||
///
|
||||
/// To verify a signature, pass it to the verify()
|
||||
/// member function. It will decrypt the signature
|
||||
/// using the RSA public key and compare the resulting
|
||||
/// hash with the actual hash of the data.
|
||||
{
|
||||
public:
|
||||
enum DigestType
|
||||
{
|
||||
DIGEST_MD5,
|
||||
DIGEST_SHA1
|
||||
};
|
||||
|
||||
RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1);
|
||||
/// Creates the RSADigestEngine with the given RSA key,
|
||||
/// using the SHA-1 hash algorithm.
|
||||
|
||||
~RSADigestEngine();
|
||||
/// Destroys the RSADigestEngine.
|
||||
|
||||
unsigned digestLength() const;
|
||||
/// Returns the length of the digest in bytes.
|
||||
|
||||
void reset();
|
||||
/// Resets the engine so that a new
|
||||
/// digest can be computed.
|
||||
|
||||
const DigestEngine::Digest& digest();
|
||||
/// Finishes the computation of the digest
|
||||
/// (the first time it's called) and
|
||||
/// returns the message digest.
|
||||
///
|
||||
/// Can be called multiple times.
|
||||
|
||||
const DigestEngine::Digest& signature();
|
||||
/// Signs the digest using the RSA algorithm
|
||||
/// and the private key (teh first time it's
|
||||
/// called) and returns the result.
|
||||
///
|
||||
/// Can be called multiple times.
|
||||
|
||||
bool verify(const DigestEngine::Digest& signature);
|
||||
/// Verifies the data against the signature.
|
||||
///
|
||||
/// Returns true if the signature can be verified, false otherwise.
|
||||
|
||||
protected:
|
||||
void updateImpl(const void* data, unsigned length);
|
||||
|
||||
private:
|
||||
RSAKey _key;
|
||||
Poco::DigestEngine& _engine;
|
||||
int _type;
|
||||
Poco::DigestEngine::Digest _digest;
|
||||
Poco::DigestEngine::Digest _signature;
|
||||
Poco::MD5Engine _md5Engine;
|
||||
Poco::SHA1Engine _sha1Engine;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_RSADigestEngine_INCLUDED
|
||||
|
@ -1,136 +1,145 @@
|
||||
//
|
||||
// RSAKey.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSAKey.h#4 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSAKey
|
||||
//
|
||||
// Definition of the RSAKey class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_RSAKey_INCLUDED
|
||||
#define Crypto_RSAKey_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/RSAKeyImpl.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class X509Certificate;
|
||||
|
||||
|
||||
class Crypto_API RSAKey
|
||||
/// This class stores an RSA key pair, consisting
|
||||
/// of private and public key. Storage of the private
|
||||
/// key is optional.
|
||||
///
|
||||
/// If a private key is available, the RSAKey can be
|
||||
/// used for decrypting data (encrypted with the public key)
|
||||
/// or computing secure digital signatures.
|
||||
{
|
||||
public:
|
||||
enum KeyLength
|
||||
{
|
||||
KL_512 = 512,
|
||||
KL_1024 = 1024,
|
||||
KL_2048 = 2048,
|
||||
KL_4096 = 4096
|
||||
};
|
||||
|
||||
enum Exponent
|
||||
{
|
||||
EXP_SMALL = 0,
|
||||
EXP_LARGE
|
||||
};
|
||||
|
||||
explicit RSAKey(const X509Certificate& cert);
|
||||
/// Extracts the RSA public key from the given certificate.
|
||||
|
||||
RSAKey(KeyLength keyLength, Exponent exp);
|
||||
/// Creates the RSAKey. Creates a new public/private keypair using the given parameters.
|
||||
/// Can be used to sign data and verify signatures.
|
||||
|
||||
RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
|
||||
/// Creates the RSAKey, by reading public and private key from the given files and
|
||||
/// using the given passphrase for the private key. Can only by used for signing if
|
||||
/// a private key is available.
|
||||
|
||||
RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
|
||||
/// Creates the RSAKey. Can only by used for signing if pPrivKey
|
||||
/// is not null. If a private key file is specified, you don't need to
|
||||
/// specify a public key file. OpenSSL will auto-create it from the private key.
|
||||
|
||||
~RSAKey();
|
||||
/// Destroys the RSAKey.
|
||||
|
||||
int size() const;
|
||||
/// Returns the RSA modulus size.
|
||||
|
||||
void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
|
||||
/// Exports the public and private keys to the given files.
|
||||
///
|
||||
/// If an empty filename is specified, the corresponding key
|
||||
/// is not exported.
|
||||
|
||||
void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
|
||||
/// Exports the public and private key to the given streams.
|
||||
///
|
||||
/// If a null pointer is passed for a stream, the corresponding
|
||||
/// key is not exported.
|
||||
|
||||
RSAKeyImpl::Ptr impl();
|
||||
/// Returns the impl object.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns "rsa"
|
||||
|
||||
private:
|
||||
RSAKeyImpl::Ptr _pImpl;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline RSAKeyImpl::Ptr RSAKey::impl()
|
||||
{
|
||||
return _pImpl;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_RSAKey_INCLUDED
|
||||
//
|
||||
// RSAKey.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSAKey.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSAKey
|
||||
//
|
||||
// Definition of the RSAKey class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_RSAKey_INCLUDED
|
||||
#define Crypto_RSAKey_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/RSAKeyImpl.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class X509Certificate;
|
||||
|
||||
|
||||
class Crypto_API RSAKey
|
||||
/// This class stores an RSA key pair, consisting
|
||||
/// of private and public key. Storage of the private
|
||||
/// key is optional.
|
||||
///
|
||||
/// If a private key is available, the RSAKey can be
|
||||
/// used for decrypting data (encrypted with the public key)
|
||||
/// or computing secure digital signatures.
|
||||
{
|
||||
public:
|
||||
enum KeyLength
|
||||
{
|
||||
KL_512 = 512,
|
||||
KL_1024 = 1024,
|
||||
KL_2048 = 2048,
|
||||
KL_4096 = 4096
|
||||
};
|
||||
|
||||
enum Exponent
|
||||
{
|
||||
EXP_SMALL = 0,
|
||||
EXP_LARGE
|
||||
};
|
||||
|
||||
explicit RSAKey(const X509Certificate& cert);
|
||||
/// Extracts the RSA public key from the given certificate.
|
||||
|
||||
RSAKey(KeyLength keyLength, Exponent exp);
|
||||
/// Creates the RSAKey. Creates a new public/private keypair using the given parameters.
|
||||
/// Can be used to sign data and verify signatures.
|
||||
|
||||
RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
|
||||
/// Creates the RSAKey, by reading public and private key from the given files and
|
||||
/// using the given passphrase for the private key. Can only by used for signing if
|
||||
/// a private key is available.
|
||||
|
||||
RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
|
||||
/// Creates the RSAKey. Can only by used for signing if pPrivKey
|
||||
/// is not null. If a private key file is specified, you don't need to
|
||||
/// specify a public key file. OpenSSL will auto-create it from the private key.
|
||||
|
||||
~RSAKey();
|
||||
/// Destroys the RSAKey.
|
||||
|
||||
int size() const;
|
||||
/// Returns the RSA modulus size.
|
||||
|
||||
RSAKeyImpl::ByteVec modulus() const;
|
||||
/// Returns the RSA modulus.
|
||||
|
||||
RSAKeyImpl::ByteVec encryptionExponent() const;
|
||||
/// Returns the RSA encryption exponent.
|
||||
|
||||
RSAKeyImpl::ByteVec decryptionExponent() const;
|
||||
/// Returns the RSA decryption exponent.
|
||||
|
||||
void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
|
||||
/// Exports the public and private keys to the given files.
|
||||
///
|
||||
/// If an empty filename is specified, the corresponding key
|
||||
/// is not exported.
|
||||
|
||||
void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
|
||||
/// Exports the public and private key to the given streams.
|
||||
///
|
||||
/// If a null pointer is passed for a stream, the corresponding
|
||||
/// key is not exported.
|
||||
|
||||
RSAKeyImpl::Ptr impl() const;
|
||||
/// Returns the impl object.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns "rsa"
|
||||
|
||||
private:
|
||||
RSAKeyImpl::Ptr _pImpl;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline RSAKeyImpl::Ptr RSAKey::impl() const
|
||||
{
|
||||
return _pImpl;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_RSAKey_INCLUDED
|
||||
|
@ -1,134 +1,150 @@
|
||||
//
|
||||
// RSAKeyImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSAKeyImpl.h#3 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSAKeyImpl
|
||||
//
|
||||
// Definition of the RSAKeyImpl class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_RSAKeyImplImpl_INCLUDED
|
||||
#define Crypto_RSAKeyImplImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
struct rsa_st;
|
||||
typedef struct rsa_st RSA;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class X509Certificate;
|
||||
|
||||
|
||||
class RSAKeyImpl: public Poco::RefCountedObject
|
||||
/// class RSAKeyImpl
|
||||
{
|
||||
public:
|
||||
typedef Poco::AutoPtr<RSAKeyImpl> Ptr;
|
||||
|
||||
explicit RSAKeyImpl(const X509Certificate& cert);
|
||||
/// Extracts the RSA public key from the given certificate.
|
||||
|
||||
RSAKeyImpl(int keyLength, unsigned long exponent);
|
||||
/// Creates the RSAKey. Creates a new public/private keypair using the given parameters.
|
||||
/// Can be used to sign data and verify signatures.
|
||||
|
||||
RSAKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase);
|
||||
/// Creates the RSAKey, by reading public and private key from the given files and
|
||||
/// using the given passphrase for the private key. Can only by used for signing if
|
||||
/// a private key is available.
|
||||
|
||||
RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase);
|
||||
/// Creates the RSAKey. Can only by used for signing if pPrivKey
|
||||
/// is not null. If a private key file is specified, you don't need to
|
||||
/// specify a public key file. OpenSSL will auto-create it from the private key.
|
||||
|
||||
~RSAKeyImpl();
|
||||
/// Destroys the RSAKeyImpl.
|
||||
|
||||
RSA* getRSA();
|
||||
/// Returns the OpenSSL RSA object.
|
||||
|
||||
const RSA* getRSA() const;
|
||||
/// Returns the OpenSSL RSA object.
|
||||
|
||||
int size() const;
|
||||
/// Returns the RSA modulus size.
|
||||
|
||||
void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
|
||||
/// Exports the public and private keys to the given files.
|
||||
///
|
||||
/// If an empty filename is specified, the corresponding key
|
||||
/// is not exported.
|
||||
|
||||
void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
|
||||
/// Exports the public and private key to the given streams.
|
||||
///
|
||||
/// If a null pointer is passed for a stream, the corresponding
|
||||
/// key is not exported.
|
||||
|
||||
private:
|
||||
void init(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase);
|
||||
void freeRSA();
|
||||
|
||||
private:
|
||||
RSA* _pRSA;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline RSA* RSAKeyImpl::getRSA()
|
||||
{
|
||||
return _pRSA;
|
||||
}
|
||||
|
||||
|
||||
inline const RSA* RSAKeyImpl::getRSA() const
|
||||
{
|
||||
return _pRSA;
|
||||
}
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_RSAKeyImplImpl_INCLUDED
|
||||
//
|
||||
// RSAKeyImpl.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSAKeyImpl.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSAKeyImpl
|
||||
//
|
||||
// Definition of the RSAKeyImpl class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_RSAKeyImplImpl_INCLUDED
|
||||
#define Crypto_RSAKeyImplImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/OpenSSLInitializer.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
|
||||
struct bignum_st;
|
||||
struct rsa_st;
|
||||
typedef struct bignum_st BIGNUM;
|
||||
typedef struct rsa_st RSA;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class X509Certificate;
|
||||
|
||||
|
||||
class RSAKeyImpl: public Poco::RefCountedObject
|
||||
/// class RSAKeyImpl
|
||||
{
|
||||
public:
|
||||
typedef Poco::AutoPtr<RSAKeyImpl> Ptr;
|
||||
typedef std::vector<unsigned char> ByteVec;
|
||||
|
||||
explicit RSAKeyImpl(const X509Certificate& cert);
|
||||
/// Extracts the RSA public key from the given certificate.
|
||||
|
||||
RSAKeyImpl(int keyLength, unsigned long exponent);
|
||||
/// Creates the RSAKey. Creates a new public/private keypair using the given parameters.
|
||||
/// Can be used to sign data and verify signatures.
|
||||
|
||||
RSAKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase);
|
||||
/// Creates the RSAKey, by reading public and private key from the given files and
|
||||
/// using the given passphrase for the private key. Can only by used for signing if
|
||||
/// a private key is available.
|
||||
|
||||
RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase);
|
||||
/// Creates the RSAKey. Can only by used for signing if pPrivKey
|
||||
/// is not null. If a private key file is specified, you don't need to
|
||||
/// specify a public key file. OpenSSL will auto-create it from the private key.
|
||||
|
||||
~RSAKeyImpl();
|
||||
/// Destroys the RSAKeyImpl.
|
||||
|
||||
RSA* getRSA();
|
||||
/// Returns the OpenSSL RSA object.
|
||||
|
||||
const RSA* getRSA() const;
|
||||
/// Returns the OpenSSL RSA object.
|
||||
|
||||
int size() const;
|
||||
/// Returns the RSA modulus size.
|
||||
|
||||
ByteVec modulus() const;
|
||||
/// Returns the RSA modulus.
|
||||
|
||||
ByteVec encryptionExponent() const;
|
||||
/// Returns the RSA encryption exponent.
|
||||
|
||||
ByteVec decryptionExponent() const;
|
||||
/// Returns the RSA decryption exponent.
|
||||
|
||||
void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
|
||||
/// Exports the public and private keys to the given files.
|
||||
///
|
||||
/// If an empty filename is specified, the corresponding key
|
||||
/// is not exported.
|
||||
|
||||
void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
|
||||
/// Exports the public and private key to the given streams.
|
||||
///
|
||||
/// If a null pointer is passed for a stream, the corresponding
|
||||
/// key is not exported.
|
||||
|
||||
private:
|
||||
void freeRSA();
|
||||
|
||||
static ByteVec convertToByteVec(const BIGNUM* bn);
|
||||
|
||||
private:
|
||||
RSA* _pRSA;
|
||||
OpenSSLInitializer _openSSLInitializer;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline RSA* RSAKeyImpl::getRSA()
|
||||
{
|
||||
return _pRSA;
|
||||
}
|
||||
|
||||
|
||||
inline const RSA* RSAKeyImpl::getRSA() const
|
||||
{
|
||||
return _pRSA;
|
||||
}
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_RSAKeyImplImpl_INCLUDED
|
||||
|
@ -1,197 +1,205 @@
|
||||
//
|
||||
// X509Certificate.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/include/Poco/Crypto/X509Certificate.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Certificate
|
||||
// Module: X509Certificate
|
||||
//
|
||||
// Definition of the X509Certificate class.
|
||||
//
|
||||
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_X509Certificate_INCLUDED
|
||||
#define Crypto_X509Certificate_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/DateTime.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include <set>
|
||||
#include <istream>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class Crypto_API X509Certificate
|
||||
/// This class represents a X509 Certificate.
|
||||
{
|
||||
public:
|
||||
enum NID
|
||||
/// Name identifier for extracting information from
|
||||
/// a certificate subject's or issuer's distinguished name.
|
||||
{
|
||||
NID_COMMON_NAME = 13,
|
||||
NID_COUNTRY = 14,
|
||||
NID_LOCALITY_NAME = 15,
|
||||
NID_STATE_OR_PROVINCE = 16,
|
||||
NID_ORGANIZATION_NAME = 17,
|
||||
NID_ORGANIZATION_UNIT_NAME = 18
|
||||
};
|
||||
|
||||
explicit X509Certificate(std::istream& istr);
|
||||
/// Creates the X509Certificate object by reading
|
||||
/// a certificate in PEM format from a stream.
|
||||
|
||||
explicit X509Certificate(const std::string& path);
|
||||
/// Creates the X509Certificate object by reading
|
||||
/// a certificate in PEM format from a file.
|
||||
|
||||
explicit X509Certificate(X509* pCert);
|
||||
/// Creates the X509Certificate from an existing
|
||||
/// OpenSSL certificate. Ownership is taken of
|
||||
/// the certificate.
|
||||
|
||||
X509Certificate(const X509Certificate& cert);
|
||||
/// Creates the certificate by copying another one.
|
||||
|
||||
X509Certificate& operator = (const X509Certificate& cert);
|
||||
/// Assigns a certificate.
|
||||
|
||||
void swap(X509Certificate& cert);
|
||||
/// Exchanges the certificate with another one.
|
||||
|
||||
~X509Certificate();
|
||||
/// Destroys the X509Certificate.
|
||||
|
||||
const std::string& issuerName() const;
|
||||
/// Returns the certificate issuer's distinguished name.
|
||||
|
||||
std::string issuerName(NID nid) const;
|
||||
/// Extracts the information specified by the given
|
||||
/// NID (name identifier) from the certificate issuer's
|
||||
/// distinguished name.
|
||||
|
||||
const std::string& subjectName() const;
|
||||
/// Returns the certificate subject's distinguished name.
|
||||
|
||||
std::string subjectName(NID nid) const;
|
||||
/// Extracts the information specified by the given
|
||||
/// NID (name identifier) from the certificate subject's
|
||||
/// distinguished name.
|
||||
|
||||
std::string commonName() const;
|
||||
/// Returns the common name stored in the certificate
|
||||
/// subject's distinguished name.
|
||||
|
||||
void extractNames(std::string& commonName, std::set<std::string>& domainNames) const;
|
||||
/// Extracts the common name and the alias domain names from the
|
||||
/// certificate.
|
||||
|
||||
Poco::DateTime validFrom() const;
|
||||
/// Returns the date and time the certificate is valid from.
|
||||
|
||||
Poco::DateTime expiresOn() const;
|
||||
/// Returns the date and time the certificate expires.
|
||||
|
||||
void save(std::ostream& stream) const;
|
||||
/// Writes the certificate to the given stream.
|
||||
/// The certificate is written in PEM format.
|
||||
|
||||
void save(const std::string& path) const;
|
||||
/// Writes the certificate to the file given by path.
|
||||
/// The certificate is written in PEM format.
|
||||
|
||||
bool issuedBy(const X509Certificate& issuerCertificate) const;
|
||||
/// Checks whether the certificate has been issued by
|
||||
/// the issuer given by issuerCertificate. This can be
|
||||
/// used to validate a certificate chain.
|
||||
///
|
||||
/// Verifies if the certificate has been signed with the
|
||||
/// issuer's private key, using the public key from the issuer
|
||||
/// certificate.
|
||||
///
|
||||
/// Returns true if verification against the issuer certificate
|
||||
/// was successfull, false otherwise.
|
||||
|
||||
const X509* certificate() const;
|
||||
/// Returns the underlying OpenSSL certificate.
|
||||
|
||||
protected:
|
||||
void load(std::istream& stream);
|
||||
/// Loads the certificate from the given stream. The
|
||||
/// certificate must be in PEM format.
|
||||
|
||||
void load(const std::string& path);
|
||||
/// Loads the certificate from the given file. The
|
||||
/// certificate must be in PEM format.
|
||||
|
||||
void init();
|
||||
/// Extracts issuer and subject name from the certificate.
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
NAME_BUFFER_SIZE = 256
|
||||
};
|
||||
|
||||
std::string _issuerName;
|
||||
std::string _subjectName;
|
||||
X509* _pCert;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const std::string& X509Certificate::issuerName() const
|
||||
{
|
||||
return _issuerName;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& X509Certificate::subjectName() const
|
||||
{
|
||||
return _subjectName;
|
||||
}
|
||||
|
||||
|
||||
inline const X509* X509Certificate::certificate() const
|
||||
{
|
||||
return _pCert;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_X509Certificate_INCLUDED
|
||||
//
|
||||
// X509Certificate.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/include/Poco/Crypto/X509Certificate.h#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Certificate
|
||||
// Module: X509Certificate
|
||||
//
|
||||
// Definition of the X509Certificate class.
|
||||
//
|
||||
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Crypto_X509Certificate_INCLUDED
|
||||
#define Crypto_X509Certificate_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "Poco/Crypto/OpenSSLInitializer.h"
|
||||
#include "Poco/DateTime.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include <set>
|
||||
#include <istream>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
class Crypto_API X509Certificate
|
||||
/// This class represents a X509 Certificate.
|
||||
{
|
||||
public:
|
||||
enum NID
|
||||
/// Name identifier for extracting information from
|
||||
/// a certificate subject's or issuer's distinguished name.
|
||||
{
|
||||
NID_COMMON_NAME = 13,
|
||||
NID_COUNTRY = 14,
|
||||
NID_LOCALITY_NAME = 15,
|
||||
NID_STATE_OR_PROVINCE = 16,
|
||||
NID_ORGANIZATION_NAME = 17,
|
||||
NID_ORGANIZATION_UNIT_NAME = 18
|
||||
};
|
||||
|
||||
explicit X509Certificate(std::istream& istr);
|
||||
/// Creates the X509Certificate object by reading
|
||||
/// a certificate in PEM format from a stream.
|
||||
|
||||
explicit X509Certificate(const std::string& path);
|
||||
/// Creates the X509Certificate object by reading
|
||||
/// a certificate in PEM format from a file.
|
||||
|
||||
explicit X509Certificate(X509* pCert);
|
||||
/// Creates the X509Certificate from an existing
|
||||
/// OpenSSL certificate. Ownership is taken of
|
||||
/// the certificate.
|
||||
|
||||
X509Certificate(X509* pCert, bool shared);
|
||||
/// Creates the X509Certificate from an existing
|
||||
/// OpenSSL certificate. Ownership is taken of
|
||||
/// the certificate. If shared is true, the
|
||||
/// certificate's reference count is incremented.
|
||||
|
||||
X509Certificate(const X509Certificate& cert);
|
||||
/// Creates the certificate by copying another one.
|
||||
|
||||
X509Certificate& operator = (const X509Certificate& cert);
|
||||
/// Assigns a certificate.
|
||||
|
||||
void swap(X509Certificate& cert);
|
||||
/// Exchanges the certificate with another one.
|
||||
|
||||
~X509Certificate();
|
||||
/// Destroys the X509Certificate.
|
||||
|
||||
const std::string& issuerName() const;
|
||||
/// Returns the certificate issuer's distinguished name.
|
||||
|
||||
std::string issuerName(NID nid) const;
|
||||
/// Extracts the information specified by the given
|
||||
/// NID (name identifier) from the certificate issuer's
|
||||
/// distinguished name.
|
||||
|
||||
const std::string& subjectName() const;
|
||||
/// Returns the certificate subject's distinguished name.
|
||||
|
||||
std::string subjectName(NID nid) const;
|
||||
/// Extracts the information specified by the given
|
||||
/// NID (name identifier) from the certificate subject's
|
||||
/// distinguished name.
|
||||
|
||||
std::string commonName() const;
|
||||
/// Returns the common name stored in the certificate
|
||||
/// subject's distinguished name.
|
||||
|
||||
void extractNames(std::string& commonName, std::set<std::string>& domainNames) const;
|
||||
/// Extracts the common name and the alias domain names from the
|
||||
/// certificate.
|
||||
|
||||
Poco::DateTime validFrom() const;
|
||||
/// Returns the date and time the certificate is valid from.
|
||||
|
||||
Poco::DateTime expiresOn() const;
|
||||
/// Returns the date and time the certificate expires.
|
||||
|
||||
void save(std::ostream& stream) const;
|
||||
/// Writes the certificate to the given stream.
|
||||
/// The certificate is written in PEM format.
|
||||
|
||||
void save(const std::string& path) const;
|
||||
/// Writes the certificate to the file given by path.
|
||||
/// The certificate is written in PEM format.
|
||||
|
||||
bool issuedBy(const X509Certificate& issuerCertificate) const;
|
||||
/// Checks whether the certificate has been issued by
|
||||
/// the issuer given by issuerCertificate. This can be
|
||||
/// used to validate a certificate chain.
|
||||
///
|
||||
/// Verifies if the certificate has been signed with the
|
||||
/// issuer's private key, using the public key from the issuer
|
||||
/// certificate.
|
||||
///
|
||||
/// Returns true if verification against the issuer certificate
|
||||
/// was successfull, false otherwise.
|
||||
|
||||
const X509* certificate() const;
|
||||
/// Returns the underlying OpenSSL certificate.
|
||||
|
||||
protected:
|
||||
void load(std::istream& stream);
|
||||
/// Loads the certificate from the given stream. The
|
||||
/// certificate must be in PEM format.
|
||||
|
||||
void load(const std::string& path);
|
||||
/// Loads the certificate from the given file. The
|
||||
/// certificate must be in PEM format.
|
||||
|
||||
void init();
|
||||
/// Extracts issuer and subject name from the certificate.
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
NAME_BUFFER_SIZE = 256
|
||||
};
|
||||
|
||||
std::string _issuerName;
|
||||
std::string _subjectName;
|
||||
X509* _pCert;
|
||||
OpenSSLInitializer _openSSLInitializer;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const std::string& X509Certificate::issuerName() const
|
||||
{
|
||||
return _issuerName;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& X509Certificate::subjectName() const
|
||||
{
|
||||
return _subjectName;
|
||||
}
|
||||
|
||||
|
||||
inline const X509* X509Certificate::certificate() const
|
||||
{
|
||||
return _pCert;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
||||
|
||||
#endif // Crypto_X509Certificate_INCLUDED
|
||||
|
299
Crypto/samples/genrsakey/genrsakey_vs100.vcxproj
Normal file
299
Crypto/samples/genrsakey/genrsakey_vs100.vcxproj
Normal file
@ -0,0 +1,299 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="debug_shared|Win32">
|
||||
<Configuration>debug_shared</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_md|Win32">
|
||||
<Configuration>debug_static_md</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_mt|Win32">
|
||||
<Configuration>debug_static_mt</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_shared|Win32">
|
||||
<Configuration>release_shared</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_md|Win32">
|
||||
<Configuration>release_static_md</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_mt|Win32">
|
||||
<Configuration>release_static_mt</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>genrsakey</ProjectName>
|
||||
<ProjectGuid>{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}</ProjectGuid>
|
||||
<RootNamespace>genrsakey</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
||||
<ImportGroup Label="ExtensionSettings"/>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros"/>
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">bin\static_mt\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">bin\static_mt\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">bin\static_md\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">bin\static_md\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">false</LinkIncremental>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">genrsakeyd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">genrsakeyd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">genrsakeyd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">genrsakey</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">genrsakey</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">genrsakey</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\genrsakeyd.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin\genrsakeyd.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\genrsakey.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mtd.lib;ssleay32mtd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\static_mt\genrsakeyd.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin\static_mt\genrsakeyd.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mt.lib;ssleay32mt.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\static_mt\genrsakey.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\static_md\genrsakeyd.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin\static_md\genrsakeyd.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\static_md\genrsakey.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\genrsakey.cpp"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
||||
<ImportGroup Label="ExtensionTargets"/>
|
||||
</Project>
|
16
Crypto/samples/genrsakey/genrsakey_vs100.vcxproj.filters
Normal file
16
Crypto/samples/genrsakey/genrsakey_vs100.vcxproj.filters
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{2f5e2e4e-b67c-4294-a0e8-ab365c385188}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{ddceacf3-18d3-4f0e-9c38-52ef1facbdb2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\genrsakey.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
3
Crypto/samples/genrsakey/genrsakey_vs100.vcxproj.user
Normal file
3
Crypto/samples/genrsakey/genrsakey_vs100.vcxproj.user
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
299
Crypto/samples/genrsakey/genrsakey_x64_vs100.vcxproj
Normal file
299
Crypto/samples/genrsakey/genrsakey_x64_vs100.vcxproj
Normal file
@ -0,0 +1,299 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="debug_shared|x64">
|
||||
<Configuration>debug_shared</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_md|x64">
|
||||
<Configuration>debug_static_md</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_mt|x64">
|
||||
<Configuration>debug_static_mt</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_shared|x64">
|
||||
<Configuration>release_shared</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_md|x64">
|
||||
<Configuration>release_static_md</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_mt|x64">
|
||||
<Configuration>release_static_mt</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>genrsakey</ProjectName>
|
||||
<ProjectGuid>{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}</ProjectGuid>
|
||||
<RootNamespace>genrsakey</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
||||
<ImportGroup Label="ExtensionSettings"/>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros"/>
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">bin64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">bin64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">bin64\static_mt\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">bin64\static_mt\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">bin64\static_md\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">bin64\static_md\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">false</LinkIncremental>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">genrsakeyd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">genrsakeyd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">genrsakeyd</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">genrsakey</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">genrsakey</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">genrsakey</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\genrsakeyd.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin64\genrsakeyd.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\genrsakey.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mtd.lib;ssleay32mtd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\static_mt\genrsakeyd.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin64\static_mt\genrsakeyd.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mt.lib;ssleay32mt.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\static_mt\genrsakey.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32mdd.lib;ssleay32mdd.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\static_md\genrsakeyd.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin64\static_md\genrsakeyd.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Crypto\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>iphlpapi.lib;winmm.lib;libeay32md.lib;ssleay32md.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\static_md\genrsakey.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\genrsakey.cpp"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
||||
<ImportGroup Label="ExtensionTargets"/>
|
||||
</Project>
|
16
Crypto/samples/genrsakey/genrsakey_x64_vs100.vcxproj.filters
Normal file
16
Crypto/samples/genrsakey/genrsakey_x64_vs100.vcxproj.filters
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{d5e71565-88ad-4723-be38-89454c846186}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{956a2b06-5184-458d-8776-0a95bd329772}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\genrsakey.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
@ -1,212 +1,218 @@
|
||||
//
|
||||
// genrsakey.cpp
|
||||
//
|
||||
//
|
||||
// genrsakey.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/samples/genrsakey/src/genrsakey.cpp#1 $
|
||||
//
|
||||
// This sample demonstrates the XYZ class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Util/Application.h"
|
||||
#include "Poco/Util/Option.h"
|
||||
#include "Poco/Util/OptionException.h"
|
||||
#include "Poco/Util/OptionSet.h"
|
||||
#include "Poco/Util/HelpFormatter.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/Crypto/RSAKey.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using Poco::Util::Application;
|
||||
using Poco::Util::Option;
|
||||
using Poco::Util::OptionSet;
|
||||
using Poco::Util::HelpFormatter;
|
||||
using Poco::Util::AbstractConfiguration;
|
||||
using Poco::Util::OptionCallback;
|
||||
using Poco::AutoPtr;
|
||||
using Poco::NumberParser;
|
||||
using Poco::Crypto::RSAKey;
|
||||
|
||||
|
||||
class RSAApp: public Application
|
||||
/// This sample demonstrates some of the features of the Util::Application class,
|
||||
/// such as configuration file handling and command line arguments processing.
|
||||
///
|
||||
/// Try genrsakey --help (on Unix platforms) or genrsakey /help (elsewhere) for
|
||||
/// more information.
|
||||
{
|
||||
public:
|
||||
RSAApp():
|
||||
_helpRequested(false),
|
||||
_length(RSAKey::KL_1024),
|
||||
_exp(RSAKey::EXP_LARGE),
|
||||
_name(),
|
||||
_pwd()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void initialize(Application& self)
|
||||
{
|
||||
loadConfiguration(); // load default configuration files, if present
|
||||
Application::initialize(self);
|
||||
}
|
||||
|
||||
void uninitialize()
|
||||
{
|
||||
Application::uninitialize();
|
||||
}
|
||||
|
||||
void reinitialize(Application& self)
|
||||
{
|
||||
Application::reinitialize(self);
|
||||
}
|
||||
|
||||
void defineOptions(OptionSet& options)
|
||||
{
|
||||
Application::defineOptions(options);
|
||||
|
||||
options.addOption(
|
||||
Option("help", "h", "display help information on command line arguments")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleHelp)));
|
||||
|
||||
options.addOption(
|
||||
Option("?", "?", "display help information on command line arguments")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleHelp)));
|
||||
|
||||
options.addOption(
|
||||
Option("key", "k", "define the key length")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.argument("512|1024|2048|4096")
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleKeyLength)));
|
||||
|
||||
options.addOption(
|
||||
Option("exponent", "e", "defines the exponent of the key")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.argument("small|large")
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleExponent)));
|
||||
|
||||
options.addOption(
|
||||
Option("file", "f", "defines the file base name. creates a file.pub and a file.priv")
|
||||
.required(true)
|
||||
.repeatable(false)
|
||||
.argument("filebasename")
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleFilePrefix)));
|
||||
|
||||
options.addOption(
|
||||
Option("password", "p", "defines the password used to encrypt the private key file. If not defined user will be asked via stdin to provide in")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.argument("pwd")
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handlePassword)));
|
||||
}
|
||||
|
||||
void handleHelp(const std::string& name, const std::string& value)
|
||||
{
|
||||
_helpRequested = true;
|
||||
displayHelp();
|
||||
stopOptionsProcessing();
|
||||
}
|
||||
|
||||
void handleKeyLength(const std::string& name, const std::string& value)
|
||||
{
|
||||
int keyLen = Poco::NumberParser::parse(value);
|
||||
if (keyLen == 512 || keyLen == 1024 || keyLen == 2048 || keyLen == 4096)
|
||||
_length = (RSAKey::KeyLength)keyLen;
|
||||
else
|
||||
throw Poco::Util::IncompatibleOptionsException("Illegal key length value");
|
||||
}
|
||||
|
||||
void handleExponent(const std::string& name, const std::string& value)
|
||||
{
|
||||
if (Poco::icompare(value, "small") == 0)
|
||||
_exp = RSAKey::EXP_SMALL;
|
||||
else
|
||||
_exp = RSAKey::EXP_LARGE;
|
||||
}
|
||||
|
||||
void handleFilePrefix(const std::string& name, const std::string& value)
|
||||
{
|
||||
if (value.empty())
|
||||
throw Poco::Util::IncompatibleOptionsException("Empty file prefix forbidden");
|
||||
_name = value;
|
||||
}
|
||||
|
||||
void handlePassword(const std::string& name, const std::string& value)
|
||||
{
|
||||
_pwd = value;
|
||||
}
|
||||
|
||||
void displayHelp()
|
||||
{
|
||||
HelpFormatter helpFormatter(options());
|
||||
helpFormatter.setCommand(commandName());
|
||||
helpFormatter.setUsage("OPTIONS");
|
||||
helpFormatter.setHeader("Application for generating RSA public/private key pairs.");
|
||||
helpFormatter.format(std::cout);
|
||||
}
|
||||
|
||||
int main(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!_helpRequested)
|
||||
{
|
||||
logger().information("Generating key with length " + Poco::NumberFormatter::format((int)_length));
|
||||
logger().information(std::string("Exponent is ") + ((_exp == RSAKey::EXP_SMALL)?"small":"large"));
|
||||
logger().information("Generating key");
|
||||
RSAKey key(_length, _exp);
|
||||
logger().information("Generating key: DONE");
|
||||
std::string pubFile(_name + ".pub");
|
||||
std::string privFile(_name + ".priv");
|
||||
|
||||
logger().information("Saving key to " + pubFile + " and " + privFile);
|
||||
key.save(pubFile, privFile, _pwd);
|
||||
logger().information("Key saved");
|
||||
}
|
||||
return Application::EXIT_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
bool _helpRequested;
|
||||
RSAKey::KeyLength _length;
|
||||
RSAKey::Exponent _exp;
|
||||
std::string _name;
|
||||
std::string _pwd;
|
||||
};
|
||||
|
||||
|
||||
POCO_APP_MAIN(RSAApp)
|
||||
//
|
||||
// This sample demonstrates the XYZ class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Util/Application.h"
|
||||
#include "Poco/Util/Option.h"
|
||||
#include "Poco/Util/OptionException.h"
|
||||
#include "Poco/Util/OptionSet.h"
|
||||
#include "Poco/Util/HelpFormatter.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/Crypto/RSAKey.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using Poco::Util::Application;
|
||||
using Poco::Util::Option;
|
||||
using Poco::Util::OptionSet;
|
||||
using Poco::Util::HelpFormatter;
|
||||
using Poco::Util::AbstractConfiguration;
|
||||
using Poco::Util::OptionCallback;
|
||||
using Poco::AutoPtr;
|
||||
using Poco::NumberParser;
|
||||
using Poco::Crypto::RSAKey;
|
||||
|
||||
|
||||
class RSAApp: public Application
|
||||
/// This sample demonstrates some of the features of the Util::Application class,
|
||||
/// such as configuration file handling and command line arguments processing.
|
||||
///
|
||||
/// Try genrsakey --help (on Unix platforms) or genrsakey /help (elsewhere) for
|
||||
/// more information.
|
||||
{
|
||||
public:
|
||||
RSAApp():
|
||||
_helpRequested(false),
|
||||
_length(RSAKey::KL_1024),
|
||||
_exp(RSAKey::EXP_LARGE),
|
||||
_name(),
|
||||
_pwd()
|
||||
{
|
||||
Poco::Crypto::initializeCrypto();
|
||||
}
|
||||
|
||||
~RSAApp()
|
||||
{
|
||||
Poco::Crypto::uninitializeCrypto();
|
||||
}
|
||||
|
||||
protected:
|
||||
void initialize(Application& self)
|
||||
{
|
||||
loadConfiguration(); // load default configuration files, if present
|
||||
Application::initialize(self);
|
||||
}
|
||||
|
||||
void uninitialize()
|
||||
{
|
||||
Application::uninitialize();
|
||||
}
|
||||
|
||||
void reinitialize(Application& self)
|
||||
{
|
||||
Application::reinitialize(self);
|
||||
}
|
||||
|
||||
void defineOptions(OptionSet& options)
|
||||
{
|
||||
Application::defineOptions(options);
|
||||
|
||||
options.addOption(
|
||||
Option("help", "h", "display help information on command line arguments")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleHelp)));
|
||||
|
||||
options.addOption(
|
||||
Option("?", "?", "display help information on command line arguments")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleHelp)));
|
||||
|
||||
options.addOption(
|
||||
Option("key", "k", "define the key length")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.argument("512|1024|2048|4096")
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleKeyLength)));
|
||||
|
||||
options.addOption(
|
||||
Option("exponent", "e", "defines the exponent of the key")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.argument("small|large")
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleExponent)));
|
||||
|
||||
options.addOption(
|
||||
Option("file", "f", "defines the file base name. creates a file.pub and a file.priv")
|
||||
.required(true)
|
||||
.repeatable(false)
|
||||
.argument("filebasename")
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleFilePrefix)));
|
||||
|
||||
options.addOption(
|
||||
Option("password", "p", "defines the password used to encrypt the private key file. If not defined user will be asked via stdin to provide in")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.argument("pwd")
|
||||
.callback(OptionCallback<RSAApp>(this, &RSAApp::handlePassword)));
|
||||
}
|
||||
|
||||
void handleHelp(const std::string& name, const std::string& value)
|
||||
{
|
||||
_helpRequested = true;
|
||||
displayHelp();
|
||||
stopOptionsProcessing();
|
||||
}
|
||||
|
||||
void handleKeyLength(const std::string& name, const std::string& value)
|
||||
{
|
||||
int keyLen = Poco::NumberParser::parse(value);
|
||||
if (keyLen == 512 || keyLen == 1024 || keyLen == 2048 || keyLen == 4096)
|
||||
_length = (RSAKey::KeyLength)keyLen;
|
||||
else
|
||||
throw Poco::Util::IncompatibleOptionsException("Illegal key length value");
|
||||
}
|
||||
|
||||
void handleExponent(const std::string& name, const std::string& value)
|
||||
{
|
||||
if (Poco::icompare(value, "small") == 0)
|
||||
_exp = RSAKey::EXP_SMALL;
|
||||
else
|
||||
_exp = RSAKey::EXP_LARGE;
|
||||
}
|
||||
|
||||
void handleFilePrefix(const std::string& name, const std::string& value)
|
||||
{
|
||||
if (value.empty())
|
||||
throw Poco::Util::IncompatibleOptionsException("Empty file prefix forbidden");
|
||||
_name = value;
|
||||
}
|
||||
|
||||
void handlePassword(const std::string& name, const std::string& value)
|
||||
{
|
||||
_pwd = value;
|
||||
}
|
||||
|
||||
void displayHelp()
|
||||
{
|
||||
HelpFormatter helpFormatter(options());
|
||||
helpFormatter.setCommand(commandName());
|
||||
helpFormatter.setUsage("OPTIONS");
|
||||
helpFormatter.setHeader("Application for generating RSA public/private key pairs.");
|
||||
helpFormatter.format(std::cout);
|
||||
}
|
||||
|
||||
int main(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!_helpRequested)
|
||||
{
|
||||
logger().information("Generating key with length " + Poco::NumberFormatter::format((int)_length));
|
||||
logger().information(std::string("Exponent is ") + ((_exp == RSAKey::EXP_SMALL)?"small":"large"));
|
||||
logger().information("Generating key");
|
||||
RSAKey key(_length, _exp);
|
||||
logger().information("Generating key: DONE");
|
||||
std::string pubFile(_name + ".pub");
|
||||
std::string privFile(_name + ".priv");
|
||||
|
||||
logger().information("Saving key to " + pubFile + " and " + privFile);
|
||||
key.save(pubFile, privFile, _pwd);
|
||||
logger().information("Key saved");
|
||||
}
|
||||
return Application::EXIT_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
bool _helpRequested;
|
||||
RSAKey::KeyLength _length;
|
||||
RSAKey::Exponent _exp;
|
||||
std::string _name;
|
||||
std::string _pwd;
|
||||
};
|
||||
|
||||
|
||||
POCO_APP_MAIN(RSAApp)
|
||||
|
37
Crypto/samples/samples_vs100.sln
Normal file
37
Crypto/samples/samples_vs100.sln
Normal file
@ -0,0 +1,37 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genrsakey", "genrsakey\genrsakey_vs100.vcxproj", "{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
debug_shared|Win32 = debug_shared|Win32
|
||||
release_shared|Win32 = release_shared|Win32
|
||||
debug_static_mt|Win32 = debug_static_mt|Win32
|
||||
release_static_mt|Win32 = release_static_mt|Win32
|
||||
debug_static_md|Win32 = debug_static_md|Win32
|
||||
release_static_md|Win32 = release_static_md|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_shared|Win32.Deploy.0 = debug_shared|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_shared|Win32.Deploy.0 = release_shared|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_mt|Win32.Deploy.0 = debug_static_mt|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_mt|Win32.Deploy.0 = release_static_mt|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_md|Win32.Deploy.0 = debug_static_md|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_md|Win32.Build.0 = release_static_md|Win32
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_md|Win32.Deploy.0 = release_static_md|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
37
Crypto/samples/samples_x64_vs100.sln
Normal file
37
Crypto/samples/samples_x64_vs100.sln
Normal file
@ -0,0 +1,37 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genrsakey", "genrsakey\genrsakey_x64_vs100.vcxproj", "{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
debug_shared|x64 = debug_shared|x64
|
||||
release_shared|x64 = release_shared|x64
|
||||
debug_static_mt|x64 = debug_static_mt|x64
|
||||
release_static_mt|x64 = release_static_mt|x64
|
||||
debug_static_md|x64 = debug_static_md|x64
|
||||
release_static_md|x64 = release_static_md|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_shared|x64.ActiveCfg = debug_shared|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_shared|x64.Build.0 = debug_shared|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_shared|x64.Deploy.0 = debug_shared|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_shared|x64.ActiveCfg = release_shared|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_shared|x64.Build.0 = release_shared|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_shared|x64.Deploy.0 = release_shared|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_mt|x64.ActiveCfg = debug_static_mt|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_mt|x64.Build.0 = debug_static_mt|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_mt|x64.Deploy.0 = debug_static_mt|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_mt|x64.ActiveCfg = release_static_mt|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_mt|x64.Build.0 = release_static_mt|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_mt|x64.Deploy.0 = release_static_mt|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_md|x64.ActiveCfg = debug_static_md|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_md|x64.Build.0 = debug_static_md|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.debug_static_md|x64.Deploy.0 = debug_static_md|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_md|x64.ActiveCfg = release_static_md|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_md|x64.Build.0 = release_static_md|x64
|
||||
{D6BE1AD9-4CB6-3184-8DF8-5210AE7D6947}.release_static_md|x64.Deploy.0 = release_static_md|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -93,16 +93,26 @@ void Cipher::encrypt(std::istream& source, std::ostream& sink, Encoding encoding
|
||||
break;
|
||||
|
||||
case ENC_BASE64:
|
||||
case ENC_BASE64_NO_LF:
|
||||
{
|
||||
Poco::Base64Encoder encoder(sink);
|
||||
if (encoding == ENC_BASE64_NO_LF)
|
||||
{
|
||||
encoder.rdbuf()->setLineLength(0);
|
||||
}
|
||||
StreamCopier::copyStream(encryptor, encoder);
|
||||
encoder.close();
|
||||
}
|
||||
break;
|
||||
|
||||
case ENC_BINHEX:
|
||||
case ENC_BINHEX_NO_LF:
|
||||
{
|
||||
Poco::HexBinaryEncoder encoder(sink);
|
||||
if (encoding == ENC_BINHEX_NO_LF)
|
||||
{
|
||||
encoder.rdbuf()->setLineLength(0);
|
||||
}
|
||||
StreamCopier::copyStream(encryptor, encoder);
|
||||
encoder.close();
|
||||
}
|
||||
@ -126,6 +136,7 @@ void Cipher::decrypt(std::istream& source, std::ostream& sink, Encoding encoding
|
||||
break;
|
||||
|
||||
case ENC_BASE64:
|
||||
case ENC_BASE64_NO_LF:
|
||||
{
|
||||
Poco::Base64Decoder decoder(source);
|
||||
StreamCopier::copyStream(decoder, decryptor);
|
||||
@ -134,6 +145,7 @@ void Cipher::decrypt(std::istream& source, std::ostream& sink, Encoding encoding
|
||||
break;
|
||||
|
||||
case ENC_BINHEX:
|
||||
case ENC_BINHEX_NO_LF:
|
||||
{
|
||||
Poco::HexBinaryDecoder decoder(source);
|
||||
StreamCopier::copyStream(decoder, decryptor);
|
||||
|
@ -50,35 +50,25 @@ namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
int CipherFactory::_instanceCount = 0;
|
||||
|
||||
|
||||
CipherFactory::CipherFactory()
|
||||
{
|
||||
if (_instanceCount == 0)
|
||||
{
|
||||
OpenSSL_add_all_algorithms();
|
||||
ERR_load_crypto_strings();
|
||||
}
|
||||
++_instanceCount;
|
||||
}
|
||||
|
||||
|
||||
CipherFactory::~CipherFactory()
|
||||
{
|
||||
--_instanceCount;
|
||||
if (_instanceCount == 0)
|
||||
{
|
||||
ERR_free_strings();
|
||||
EVP_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
static Poco::SingletonHolder<CipherFactory> holder;
|
||||
}
|
||||
|
||||
|
||||
CipherFactory& CipherFactory::defaultFactory()
|
||||
{
|
||||
static Poco::SingletonHolder<CipherFactory> holder;
|
||||
return *holder.get();
|
||||
return *holder.get();
|
||||
}
|
||||
|
||||
|
||||
|
@ -176,7 +176,7 @@ namespace
|
||||
|
||||
|
||||
CipherImpl::CipherImpl(const CipherKey& key):
|
||||
_key(key)
|
||||
_key(key)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,72 +1,67 @@
|
||||
//
|
||||
// CipherKey.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/src/CipherKey.cpp#2 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherKey
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/CipherKey.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
CipherKey::CipherKey(const std::string& name,
|
||||
const std::string& passphrase,
|
||||
const std::string& salt,
|
||||
int iterationCount):
|
||||
_pImpl(new CipherKeyImpl(name, passphrase, salt, iterationCount))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CipherKey::CipherKey(const std::string& name,
|
||||
const ByteVec& key,
|
||||
const ByteVec& iv):
|
||||
_pImpl(new CipherKeyImpl(name, key, iv))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CipherKey::CipherKey(const std::string& name):
|
||||
_pImpl(new CipherKeyImpl(name))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CipherKey::~CipherKey()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
//
|
||||
// CipherKey.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/src/CipherKey.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherKey
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/CipherKey.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
CipherKey::CipherKey(const std::string& name, const std::string& passphrase, const std::string& salt, int iterationCount):
|
||||
_pImpl(new CipherKeyImpl(name, passphrase, salt, iterationCount))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CipherKey::CipherKey(const std::string& name, const ByteVec& key, const ByteVec& iv):
|
||||
_pImpl(new CipherKeyImpl(name, key, iv))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CipherKey::CipherKey(const std::string& name):
|
||||
_pImpl(new CipherKeyImpl(name))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CipherKey::~CipherKey()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
@ -1,218 +1,218 @@
|
||||
//
|
||||
// CipherKeyImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/src/CipherKeyImpl.cpp#3 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherKeyImpl
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/CipherKeyImpl.h"
|
||||
#include "Poco/Crypto/CryptoTransform.h"
|
||||
#include "Poco/Crypto/CipherFactory.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/RandomStream.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
CipherKeyImpl::CipherKeyImpl(const std::string& name,
|
||||
const std::string& passphrase,
|
||||
const std::string& salt,
|
||||
int iterationCount):
|
||||
_pCipher(0),
|
||||
_name(name),
|
||||
_key(),
|
||||
_iv()
|
||||
{
|
||||
// dummy access to Cipherfactory so that the EVP lib is initilaized
|
||||
CipherFactory::defaultFactory();
|
||||
_pCipher = EVP_get_cipherbyname(name.c_str());
|
||||
|
||||
if (!_pCipher)
|
||||
throw Poco::NotFoundException("Cipher " + name + " was not found");
|
||||
_key = ByteVec(keySize());
|
||||
_iv = ByteVec(ivSize());
|
||||
generateKey(passphrase, salt, iterationCount);
|
||||
}
|
||||
|
||||
|
||||
CipherKeyImpl::CipherKeyImpl(const std::string& name,
|
||||
const ByteVec& key,
|
||||
const ByteVec& iv):
|
||||
_pCipher(0),
|
||||
_name(name),
|
||||
_key(key),
|
||||
_iv(iv)
|
||||
{
|
||||
// dummy access to Cipherfactory so that the EVP lib is initilaized
|
||||
CipherFactory::defaultFactory();
|
||||
_pCipher = EVP_get_cipherbyname(name.c_str());
|
||||
|
||||
if (!_pCipher)
|
||||
throw Poco::NotFoundException("Cipher " + name + " was not found");
|
||||
}
|
||||
|
||||
|
||||
CipherKeyImpl::CipherKeyImpl(const std::string& name):
|
||||
_pCipher(0),
|
||||
_name(name),
|
||||
_key(),
|
||||
_iv()
|
||||
{
|
||||
// dummy access to Cipherfactory so that the EVP lib is initilaized
|
||||
CipherFactory::defaultFactory();
|
||||
_pCipher = EVP_get_cipherbyname(name.c_str());
|
||||
|
||||
if (!_pCipher)
|
||||
throw Poco::NotFoundException("Cipher " + name + " was not found");
|
||||
_key = ByteVec(keySize());
|
||||
_iv = ByteVec(ivSize());
|
||||
generateKey();
|
||||
}
|
||||
|
||||
|
||||
CipherKeyImpl::~CipherKeyImpl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CipherKeyImpl::Mode CipherKeyImpl::mode() const
|
||||
{
|
||||
switch (EVP_CIPHER_mode(_pCipher))
|
||||
{
|
||||
case EVP_CIPH_STREAM_CIPHER:
|
||||
return MODE_STREAM_CIPHER;
|
||||
|
||||
case EVP_CIPH_ECB_MODE:
|
||||
return MODE_ECB;
|
||||
|
||||
case EVP_CIPH_CBC_MODE:
|
||||
return MODE_CBC;
|
||||
|
||||
case EVP_CIPH_CFB_MODE:
|
||||
return MODE_CFB;
|
||||
|
||||
case EVP_CIPH_OFB_MODE:
|
||||
return MODE_OFB;
|
||||
}
|
||||
throw Poco::IllegalStateException("Unexpected value of EVP_CIPHER_mode()");
|
||||
}
|
||||
|
||||
|
||||
void CipherKeyImpl::generateKey()
|
||||
{
|
||||
ByteVec vec;
|
||||
|
||||
getRandomBytes(vec, keySize());
|
||||
setKey(vec);
|
||||
|
||||
getRandomBytes(vec, ivSize());
|
||||
setIV(vec);
|
||||
}
|
||||
|
||||
|
||||
void CipherKeyImpl::getRandomBytes(ByteVec& vec, std::size_t count)
|
||||
{
|
||||
Poco::RandomInputStream random;
|
||||
|
||||
vec.clear();
|
||||
vec.reserve(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
vec.push_back(static_cast<unsigned char>(random.get()));
|
||||
}
|
||||
|
||||
|
||||
void CipherKeyImpl::generateKey(
|
||||
const std::string& password,
|
||||
const std::string& salt,
|
||||
int iterationCount)
|
||||
{
|
||||
unsigned char keyBytes[EVP_MAX_KEY_LENGTH];
|
||||
unsigned char ivBytes[EVP_MAX_IV_LENGTH];
|
||||
|
||||
// OpenSSL documentation specifies that the salt must be an 8-byte array.
|
||||
unsigned char saltBytes[8];
|
||||
|
||||
if (!salt.empty())
|
||||
{
|
||||
int len = static_cast<int>(salt.size());
|
||||
// Create the salt array from the salt string
|
||||
for (int i = 0; i < 8; ++i)
|
||||
saltBytes[i] = salt.at(i % len);
|
||||
for (int i = 8; i < len; ++i)
|
||||
saltBytes[i % 8] ^= salt.at(i);
|
||||
}
|
||||
|
||||
// Now create the key and IV, using the MD5 digest algorithm.
|
||||
int keySize = EVP_BytesToKey(
|
||||
_pCipher,
|
||||
EVP_md5(),
|
||||
(salt.empty() ? 0 : saltBytes),
|
||||
reinterpret_cast<const unsigned char*>(password.data()),
|
||||
static_cast<int>(password.size()),
|
||||
iterationCount,
|
||||
keyBytes,
|
||||
ivBytes);
|
||||
|
||||
// Copy the buffers to our member byte vectors.
|
||||
_key.assign(keyBytes, keyBytes + keySize);
|
||||
|
||||
if (ivSize() == 0)
|
||||
_iv.clear();
|
||||
else
|
||||
_iv.assign(ivBytes, ivBytes + ivSize());
|
||||
}
|
||||
|
||||
|
||||
int CipherKeyImpl::keySize() const
|
||||
{
|
||||
return EVP_CIPHER_key_length(_pCipher);
|
||||
}
|
||||
|
||||
|
||||
int CipherKeyImpl::blockSize() const
|
||||
{
|
||||
return EVP_CIPHER_block_size(_pCipher);
|
||||
}
|
||||
|
||||
|
||||
int CipherKeyImpl::ivSize() const
|
||||
{
|
||||
return EVP_CIPHER_iv_length(_pCipher);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
//
|
||||
// CipherKeyImpl.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/src/CipherKeyImpl.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Cipher
|
||||
// Module: CipherKeyImpl
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/CipherKeyImpl.h"
|
||||
#include "Poco/Crypto/CryptoTransform.h"
|
||||
#include "Poco/Crypto/CipherFactory.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/RandomStream.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
CipherKeyImpl::CipherKeyImpl(const std::string& name,
|
||||
const std::string& passphrase,
|
||||
const std::string& salt,
|
||||
int iterationCount):
|
||||
_pCipher(0),
|
||||
_name(name),
|
||||
_key(),
|
||||
_iv()
|
||||
{
|
||||
// dummy access to Cipherfactory so that the EVP lib is initilaized
|
||||
CipherFactory::defaultFactory();
|
||||
_pCipher = EVP_get_cipherbyname(name.c_str());
|
||||
|
||||
if (!_pCipher)
|
||||
throw Poco::NotFoundException("Cipher " + name + " was not found");
|
||||
_key = ByteVec(keySize());
|
||||
_iv = ByteVec(ivSize());
|
||||
generateKey(passphrase, salt, iterationCount);
|
||||
}
|
||||
|
||||
|
||||
CipherKeyImpl::CipherKeyImpl(const std::string& name,
|
||||
const ByteVec& key,
|
||||
const ByteVec& iv):
|
||||
_pCipher(0),
|
||||
_name(name),
|
||||
_key(key),
|
||||
_iv(iv)
|
||||
{
|
||||
// dummy access to Cipherfactory so that the EVP lib is initilaized
|
||||
CipherFactory::defaultFactory();
|
||||
_pCipher = EVP_get_cipherbyname(name.c_str());
|
||||
|
||||
if (!_pCipher)
|
||||
throw Poco::NotFoundException("Cipher " + name + " was not found");
|
||||
}
|
||||
|
||||
|
||||
CipherKeyImpl::CipherKeyImpl(const std::string& name):
|
||||
_pCipher(0),
|
||||
_name(name),
|
||||
_key(),
|
||||
_iv()
|
||||
{
|
||||
// dummy access to Cipherfactory so that the EVP lib is initilaized
|
||||
CipherFactory::defaultFactory();
|
||||
_pCipher = EVP_get_cipherbyname(name.c_str());
|
||||
|
||||
if (!_pCipher)
|
||||
throw Poco::NotFoundException("Cipher " + name + " was not found");
|
||||
_key = ByteVec(keySize());
|
||||
_iv = ByteVec(ivSize());
|
||||
generateKey();
|
||||
}
|
||||
|
||||
|
||||
CipherKeyImpl::~CipherKeyImpl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CipherKeyImpl::Mode CipherKeyImpl::mode() const
|
||||
{
|
||||
switch (EVP_CIPHER_mode(_pCipher))
|
||||
{
|
||||
case EVP_CIPH_STREAM_CIPHER:
|
||||
return MODE_STREAM_CIPHER;
|
||||
|
||||
case EVP_CIPH_ECB_MODE:
|
||||
return MODE_ECB;
|
||||
|
||||
case EVP_CIPH_CBC_MODE:
|
||||
return MODE_CBC;
|
||||
|
||||
case EVP_CIPH_CFB_MODE:
|
||||
return MODE_CFB;
|
||||
|
||||
case EVP_CIPH_OFB_MODE:
|
||||
return MODE_OFB;
|
||||
}
|
||||
throw Poco::IllegalStateException("Unexpected value of EVP_CIPHER_mode()");
|
||||
}
|
||||
|
||||
|
||||
void CipherKeyImpl::generateKey()
|
||||
{
|
||||
ByteVec vec;
|
||||
|
||||
getRandomBytes(vec, keySize());
|
||||
setKey(vec);
|
||||
|
||||
getRandomBytes(vec, ivSize());
|
||||
setIV(vec);
|
||||
}
|
||||
|
||||
|
||||
void CipherKeyImpl::getRandomBytes(ByteVec& vec, std::size_t count)
|
||||
{
|
||||
Poco::RandomInputStream random;
|
||||
|
||||
vec.clear();
|
||||
vec.reserve(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
vec.push_back(static_cast<unsigned char>(random.get()));
|
||||
}
|
||||
|
||||
|
||||
void CipherKeyImpl::generateKey(
|
||||
const std::string& password,
|
||||
const std::string& salt,
|
||||
int iterationCount)
|
||||
{
|
||||
unsigned char keyBytes[EVP_MAX_KEY_LENGTH];
|
||||
unsigned char ivBytes[EVP_MAX_IV_LENGTH];
|
||||
|
||||
// OpenSSL documentation specifies that the salt must be an 8-byte array.
|
||||
unsigned char saltBytes[8];
|
||||
|
||||
if (!salt.empty())
|
||||
{
|
||||
int len = static_cast<int>(salt.size());
|
||||
// Create the salt array from the salt string
|
||||
for (int i = 0; i < 8; ++i)
|
||||
saltBytes[i] = salt.at(i % len);
|
||||
for (int i = 8; i < len; ++i)
|
||||
saltBytes[i % 8] ^= salt.at(i);
|
||||
}
|
||||
|
||||
// Now create the key and IV, using the MD5 digest algorithm.
|
||||
int keySize = EVP_BytesToKey(
|
||||
_pCipher,
|
||||
EVP_md5(),
|
||||
(salt.empty() ? 0 : saltBytes),
|
||||
reinterpret_cast<const unsigned char*>(password.data()),
|
||||
static_cast<int>(password.size()),
|
||||
iterationCount,
|
||||
keyBytes,
|
||||
ivBytes);
|
||||
|
||||
// Copy the buffers to our member byte vectors.
|
||||
_key.assign(keyBytes, keyBytes + keySize);
|
||||
|
||||
if (ivSize() == 0)
|
||||
_iv.clear();
|
||||
else
|
||||
_iv.assign(ivBytes, ivBytes + ivSize());
|
||||
}
|
||||
|
||||
|
||||
int CipherKeyImpl::keySize() const
|
||||
{
|
||||
return EVP_CIPHER_key_length(_pCipher);
|
||||
}
|
||||
|
||||
|
||||
int CipherKeyImpl::blockSize() const
|
||||
{
|
||||
return EVP_CIPHER_block_size(_pCipher);
|
||||
}
|
||||
|
||||
|
||||
int CipherKeyImpl::ivSize() const
|
||||
{
|
||||
return EVP_CIPHER_iv_length(_pCipher);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
@ -54,35 +54,29 @@ namespace Crypto {
|
||||
//
|
||||
|
||||
|
||||
CryptoStreamBuf::CryptoStreamBuf(
|
||||
std::istream& istr,
|
||||
CryptoTransform* pTransform,
|
||||
std::streamsize bufferSize) :
|
||||
Poco::BufferedStreamBuf(bufferSize, std::ios::in),
|
||||
_pTransform(pTransform),
|
||||
_pIstr(&istr),
|
||||
_pOstr(0),
|
||||
_eof(false),
|
||||
_buffer(bufferSize)
|
||||
CryptoStreamBuf::CryptoStreamBuf(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize):
|
||||
Poco::BufferedStreamBuf(bufferSize, std::ios::in),
|
||||
_pTransform(pTransform),
|
||||
_pIstr(&istr),
|
||||
_pOstr(0),
|
||||
_eof(false),
|
||||
_buffer(static_cast<std::size_t>(bufferSize))
|
||||
{
|
||||
poco_check_ptr(pTransform);
|
||||
poco_assert(bufferSize >= 2 * pTransform->blockSize());
|
||||
poco_check_ptr (pTransform);
|
||||
poco_assert (bufferSize > 2 * pTransform->blockSize());
|
||||
}
|
||||
|
||||
|
||||
CryptoStreamBuf::CryptoStreamBuf(
|
||||
std::ostream& ostr,
|
||||
CryptoTransform* pTransform,
|
||||
std::streamsize bufferSize) :
|
||||
Poco::BufferedStreamBuf(bufferSize, std::ios::out),
|
||||
_pTransform(pTransform),
|
||||
_pIstr(0),
|
||||
_pOstr(&ostr),
|
||||
_eof(false),
|
||||
_buffer(bufferSize)
|
||||
CryptoStreamBuf::CryptoStreamBuf(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize):
|
||||
Poco::BufferedStreamBuf(bufferSize, std::ios::out),
|
||||
_pTransform(pTransform),
|
||||
_pIstr(0),
|
||||
_pOstr(&ostr),
|
||||
_eof(false),
|
||||
_buffer(static_cast<std::size_t>(bufferSize))
|
||||
{
|
||||
poco_check_ptr(pTransform);
|
||||
poco_assert(bufferSize >= 2 * pTransform->blockSize());
|
||||
poco_check_ptr (pTransform);
|
||||
poco_assert (bufferSize > 2 * pTransform->blockSize());
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +110,7 @@ void CryptoStreamBuf::close()
|
||||
_pOstr = 0;
|
||||
|
||||
// Finalize transformation.
|
||||
int n = _pTransform->finalize(_buffer.begin(), static_cast<std::streamsize>(_buffer.size()));
|
||||
std::streamsize n = _pTransform->finalize(_buffer.begin(), static_cast<std::streamsize>(_buffer.size()));
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
@ -137,12 +131,12 @@ int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
||||
|
||||
while (!_eof)
|
||||
{
|
||||
int m = static_cast<int>(length) - count - static_cast<int>(_pTransform->blockSize() - 1);
|
||||
int m = (static_cast<int>(length) - count)/2 - static_cast<int>(_pTransform->blockSize());
|
||||
|
||||
// Make sure we can read at least one more block. Explicitely check
|
||||
// for m < 0 since blockSize() returns an unsigned int and the
|
||||
// comparison might give fals results for m < 0.
|
||||
if (m < 0 || m < _pTransform->blockSize())
|
||||
// comparison might give false results for m < 0.
|
||||
if (m <= 0)
|
||||
break;
|
||||
|
||||
int n = 0;
|
||||
@ -158,18 +152,18 @@ int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
||||
_eof = true;
|
||||
|
||||
// No more data, finalize transformation
|
||||
count += _pTransform->finalize(
|
||||
count += static_cast<int>(_pTransform->finalize(
|
||||
reinterpret_cast<unsigned char*>(buffer + count),
|
||||
length - count);
|
||||
static_cast<int>(length) - count));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Transform next chunk of data
|
||||
count += _pTransform->transform(
|
||||
count += static_cast<int>(_pTransform->transform(
|
||||
_buffer.begin(),
|
||||
n,
|
||||
reinterpret_cast<unsigned char*>(buffer + count),
|
||||
length - count);
|
||||
static_cast<int>(length) - count));
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,18 +176,18 @@ int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
|
||||
if (!_pOstr)
|
||||
return 0;
|
||||
|
||||
std::size_t maxChunkSize = _buffer.size() - (_pTransform->blockSize() - 1);
|
||||
std::size_t maxChunkSize = _buffer.size()/2;
|
||||
std::size_t count = 0;
|
||||
|
||||
while (count < length)
|
||||
{
|
||||
// Truncate chunk size so that the maximum output fits into _buffer.
|
||||
std::size_t n = length - count;
|
||||
std::size_t n = static_cast<std::size_t>(length) - count;
|
||||
if (n > maxChunkSize)
|
||||
n = maxChunkSize;
|
||||
|
||||
// Transform next chunk of data
|
||||
int k = _pTransform->transform(
|
||||
std::streamsize k = _pTransform->transform(
|
||||
reinterpret_cast<const unsigned char*>(buffer + count),
|
||||
static_cast<std::streamsize>(n),
|
||||
_buffer.begin(),
|
||||
@ -221,21 +215,15 @@ int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
|
||||
//
|
||||
|
||||
|
||||
CryptoIOS::CryptoIOS(
|
||||
std::istream& istr,
|
||||
CryptoTransform* pTransform,
|
||||
std::streamsize bufferSize) :
|
||||
_buf(istr, pTransform, bufferSize)
|
||||
CryptoIOS::CryptoIOS(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize):
|
||||
_buf(istr, pTransform, bufferSize)
|
||||
{
|
||||
poco_ios_init(&_buf);
|
||||
}
|
||||
|
||||
|
||||
CryptoIOS::CryptoIOS(
|
||||
std::ostream& ostr,
|
||||
CryptoTransform* pTransform,
|
||||
std::streamsize bufferSize) :
|
||||
_buf(ostr, pTransform, bufferSize)
|
||||
CryptoIOS::CryptoIOS(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize):
|
||||
_buf(ostr, pTransform, bufferSize)
|
||||
{
|
||||
poco_ios_init(&_buf);
|
||||
}
|
||||
@ -257,22 +245,16 @@ CryptoStreamBuf* CryptoIOS::rdbuf()
|
||||
//
|
||||
|
||||
|
||||
CryptoInputStream::CryptoInputStream(
|
||||
std::istream& istr,
|
||||
CryptoTransform* pTransform,
|
||||
std::streamsize bufferSize) :
|
||||
CryptoIOS(istr, pTransform, bufferSize),
|
||||
std::istream(&_buf)
|
||||
CryptoInputStream::CryptoInputStream(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize):
|
||||
CryptoIOS(istr, pTransform, bufferSize),
|
||||
std::istream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CryptoInputStream::CryptoInputStream(
|
||||
std::istream& istr,
|
||||
Cipher& cipher,
|
||||
std::streamsize bufferSize) :
|
||||
CryptoIOS(istr, cipher.createEncryptor(), bufferSize),
|
||||
std::istream(&_buf)
|
||||
CryptoInputStream::CryptoInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize):
|
||||
CryptoIOS(istr, cipher.createEncryptor(), bufferSize),
|
||||
std::istream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
@ -287,22 +269,16 @@ CryptoInputStream::~CryptoInputStream()
|
||||
//
|
||||
|
||||
|
||||
CryptoOutputStream::CryptoOutputStream(
|
||||
std::ostream& ostr,
|
||||
CryptoTransform* pTransform,
|
||||
std::streamsize bufferSize) :
|
||||
CryptoIOS(ostr, pTransform, bufferSize),
|
||||
std::ostream(&_buf)
|
||||
CryptoOutputStream::CryptoOutputStream(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize):
|
||||
CryptoIOS(ostr, pTransform, bufferSize),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CryptoOutputStream::CryptoOutputStream(
|
||||
std::ostream& ostr,
|
||||
Cipher& cipher,
|
||||
std::streamsize bufferSize):
|
||||
CryptoIOS(ostr, cipher.createDecryptor(), bufferSize),
|
||||
std::ostream(&_buf)
|
||||
CryptoOutputStream::CryptoOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize):
|
||||
CryptoIOS(ostr, cipher.createDecryptor(), bufferSize),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
@ -314,7 +290,87 @@ CryptoOutputStream::~CryptoOutputStream()
|
||||
|
||||
void CryptoOutputStream::close()
|
||||
{
|
||||
_buf.close();
|
||||
_buf.close();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// EncryptingInputStream
|
||||
//
|
||||
|
||||
|
||||
EncryptingInputStream::EncryptingInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize):
|
||||
CryptoIOS(istr, cipher.createEncryptor(), bufferSize),
|
||||
std::istream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
EncryptingInputStream::~EncryptingInputStream()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// EncryptingOuputStream
|
||||
//
|
||||
|
||||
|
||||
EncryptingOutputStream::EncryptingOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize):
|
||||
CryptoIOS(ostr, cipher.createEncryptor(), bufferSize),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
EncryptingOutputStream::~EncryptingOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void EncryptingOutputStream::close()
|
||||
{
|
||||
_buf.close();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DecryptingInputStream
|
||||
//
|
||||
|
||||
|
||||
DecryptingInputStream::DecryptingInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize):
|
||||
CryptoIOS(istr, cipher.createDecryptor(), bufferSize),
|
||||
std::istream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DecryptingInputStream::~DecryptingInputStream()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DecryptingOuputStream
|
||||
//
|
||||
|
||||
|
||||
DecryptingOutputStream::DecryptingOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize):
|
||||
CryptoIOS(ostr, cipher.createDecryptor(), bufferSize),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DecryptingOutputStream::~DecryptingOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DecryptingOutputStream::close()
|
||||
{
|
||||
_buf.close();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,150 +1,172 @@
|
||||
//
|
||||
// OpenSSLInitializer.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/src/OpenSSLInitializer.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: CryotpCore
|
||||
// Module: OpenSSLInitializer
|
||||
//
|
||||
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/OpenSSLInitializer.h"
|
||||
#include "Poco/RandomStream.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
|
||||
using Poco::RandomInputStream;
|
||||
using Poco::Thread;
|
||||
using Poco::FastMutex;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
FastMutex* OpenSSLInitializer::_mutexes(0);
|
||||
int OpenSSLInitializer::_rc(0);
|
||||
|
||||
|
||||
static OpenSSLInitializer initializer;
|
||||
|
||||
|
||||
OpenSSLInitializer::OpenSSLInitializer()
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
OpenSSLInitializer::~OpenSSLInitializer()
|
||||
{
|
||||
uninitialize();
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::initialize()
|
||||
{
|
||||
if (++_rc == 1)
|
||||
{
|
||||
poco_assert (1 == SSL_library_init()); // always returns 1
|
||||
SSL_load_error_strings();
|
||||
|
||||
char seed[SEEDSIZE];
|
||||
RandomInputStream rnd;
|
||||
rnd.read(seed, sizeof(seed));
|
||||
RAND_seed(seed, SEEDSIZE);
|
||||
|
||||
int nMutexes = CRYPTO_num_locks();
|
||||
_mutexes = new FastMutex[nMutexes];
|
||||
CRYPTO_set_locking_callback(&OpenSSLInitializer::lock);
|
||||
#ifndef POCO_OS_FAMILY_WINDOWS // SF# 1828231: random unhandled exceptions when linking with ssl
|
||||
CRYPTO_set_id_callback(&OpenSSLInitializer::id);
|
||||
#endif
|
||||
CRYPTO_set_dynlock_create_callback(&OpenSSLInitializer::dynlockCreate);
|
||||
CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock);
|
||||
CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::uninitialize()
|
||||
{
|
||||
if (--_rc == 0)
|
||||
{
|
||||
EVP_cleanup();
|
||||
ERR_free_strings();
|
||||
CRYPTO_set_locking_callback(0);
|
||||
delete [] _mutexes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::lock(int mode, int n, const char* file, int line)
|
||||
{
|
||||
if (mode & CRYPTO_LOCK)
|
||||
_mutexes[n].lock();
|
||||
else
|
||||
_mutexes[n].unlock();
|
||||
}
|
||||
|
||||
|
||||
unsigned long OpenSSLInitializer::id()
|
||||
{
|
||||
Thread* pThread = Thread::current();
|
||||
return pThread ? pThread->id() : 0;
|
||||
}
|
||||
|
||||
|
||||
struct CRYPTO_dynlock_value* OpenSSLInitializer::dynlockCreate(const char* file, int line)
|
||||
{
|
||||
return new CRYPTO_dynlock_value;
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line)
|
||||
{
|
||||
poco_check_ptr (lock);
|
||||
|
||||
if (mode & CRYPTO_LOCK)
|
||||
lock->_mutex.lock();
|
||||
else
|
||||
lock->_mutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line)
|
||||
{
|
||||
delete lock;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
//
|
||||
// OpenSSLInitializer.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/src/OpenSSLInitializer.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: CryotpCore
|
||||
// Module: OpenSSLInitializer
|
||||
//
|
||||
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/OpenSSLInitializer.h"
|
||||
#include "Poco/RandomStream.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/err.h>
|
||||
#if SSLEAY_VERSION_NUMBER >= 0x0907000L
|
||||
#include <openssl/conf.h>
|
||||
#endif
|
||||
|
||||
|
||||
using Poco::RandomInputStream;
|
||||
using Poco::Thread;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
Poco::FastMutex* OpenSSLInitializer::_mutexes(0);
|
||||
Poco::FastMutex OpenSSLInitializer::_mutex;
|
||||
int OpenSSLInitializer::_rc(0);
|
||||
|
||||
|
||||
OpenSSLInitializer::OpenSSLInitializer()
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
OpenSSLInitializer::~OpenSSLInitializer()
|
||||
{
|
||||
uninitialize();
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::initialize()
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (++_rc == 1)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x0907000L
|
||||
OPENSSL_config(NULL);
|
||||
#endif
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
OpenSSL_add_all_algorithms();
|
||||
|
||||
char seed[SEEDSIZE];
|
||||
RandomInputStream rnd;
|
||||
rnd.read(seed, sizeof(seed));
|
||||
RAND_seed(seed, SEEDSIZE);
|
||||
|
||||
int nMutexes = CRYPTO_num_locks();
|
||||
_mutexes = new Poco::FastMutex[nMutexes];
|
||||
CRYPTO_set_locking_callback(&OpenSSLInitializer::lock);
|
||||
#ifndef POCO_OS_FAMILY_WINDOWS // SF# 1828231: random unhandled exceptions when linking with ssl
|
||||
CRYPTO_set_id_callback(&OpenSSLInitializer::id);
|
||||
#endif
|
||||
CRYPTO_set_dynlock_create_callback(&OpenSSLInitializer::dynlockCreate);
|
||||
CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock);
|
||||
CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::uninitialize()
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (--_rc == 0)
|
||||
{
|
||||
EVP_cleanup();
|
||||
ERR_free_strings();
|
||||
CRYPTO_set_locking_callback(0);
|
||||
delete [] _mutexes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::lock(int mode, int n, const char* file, int line)
|
||||
{
|
||||
if (mode & CRYPTO_LOCK)
|
||||
_mutexes[n].lock();
|
||||
else
|
||||
_mutexes[n].unlock();
|
||||
}
|
||||
|
||||
|
||||
unsigned long OpenSSLInitializer::id()
|
||||
{
|
||||
// Note: we use an old-style C cast here because
|
||||
// neither static_cast<> nor reinterpret_cast<>
|
||||
// work uniformly across all platforms.
|
||||
return (unsigned long) Poco::Thread::currentTid();
|
||||
}
|
||||
|
||||
|
||||
struct CRYPTO_dynlock_value* OpenSSLInitializer::dynlockCreate(const char* file, int line)
|
||||
{
|
||||
return new CRYPTO_dynlock_value;
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line)
|
||||
{
|
||||
poco_check_ptr (lock);
|
||||
|
||||
if (mode & CRYPTO_LOCK)
|
||||
lock->_mutex.lock();
|
||||
else
|
||||
lock->_mutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
void OpenSSLInitializer::dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line)
|
||||
{
|
||||
delete lock;
|
||||
}
|
||||
|
||||
|
||||
void initializeCrypto()
|
||||
{
|
||||
OpenSSLInitializer::initialize();
|
||||
}
|
||||
|
||||
|
||||
void uninitializeCrypto()
|
||||
{
|
||||
OpenSSLInitializer::uninitialize();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
@ -1,333 +1,340 @@
|
||||
//
|
||||
// RSACipherImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/src/RSACipherImpl.cpp#2 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSACipherImpl
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/RSACipherImpl.h"
|
||||
#include "Poco/Crypto/CryptoTransform.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
void throwError()
|
||||
{
|
||||
unsigned long err;
|
||||
std::string msg;
|
||||
|
||||
while ((err = ERR_get_error()))
|
||||
{
|
||||
if (!msg.empty())
|
||||
msg.append("; ");
|
||||
msg.append(ERR_error_string(err, 0));
|
||||
}
|
||||
|
||||
throw Poco::IOException(msg);
|
||||
}
|
||||
|
||||
|
||||
int mapPaddingMode(RSAPaddingMode paddingMode)
|
||||
{
|
||||
switch (paddingMode)
|
||||
{
|
||||
case RSA_PADDING_PKCS1:
|
||||
return RSA_PKCS1_PADDING;
|
||||
case RSA_PADDING_PKCS1_OAEP:
|
||||
return RSA_PKCS1_OAEP_PADDING;
|
||||
case RSA_PADDING_SSLV23:
|
||||
return RSA_SSLV23_PADDING;
|
||||
case RSA_PADDING_NONE:
|
||||
return RSA_NO_PADDING;
|
||||
default:
|
||||
poco_bugcheck();
|
||||
return RSA_NO_PADDING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class RSAEncryptImpl: public CryptoTransform
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
OVERFLOW = 11
|
||||
};
|
||||
|
||||
RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode);
|
||||
~RSAEncryptImpl();
|
||||
|
||||
std::size_t blockSize() const;
|
||||
|
||||
std::streamsize transform(
|
||||
const unsigned char* input,
|
||||
std::streamsize inputLength,
|
||||
unsigned char* output,
|
||||
std::streamsize outputLength);
|
||||
|
||||
std::streamsize finalize(unsigned char* output, std::streamsize length);
|
||||
|
||||
private:
|
||||
const RSA* _pRSA;
|
||||
RSAPaddingMode _paddingMode;
|
||||
std::streamsize _pos;
|
||||
unsigned char* _pBuf;
|
||||
};
|
||||
|
||||
|
||||
RSAEncryptImpl::RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode):
|
||||
_pRSA(pRSA),
|
||||
_paddingMode(paddingMode),
|
||||
_pos(0),
|
||||
_pBuf(0)
|
||||
{
|
||||
_pBuf = new unsigned char[blockSize()];
|
||||
}
|
||||
|
||||
|
||||
RSAEncryptImpl::~RSAEncryptImpl()
|
||||
{
|
||||
delete _pBuf;
|
||||
}
|
||||
|
||||
|
||||
std::size_t RSAEncryptImpl::blockSize() const
|
||||
{
|
||||
return RSA_size(_pRSA);
|
||||
}
|
||||
|
||||
|
||||
std::streamsize RSAEncryptImpl::transform(
|
||||
const unsigned char* input,
|
||||
std::streamsize inputLength,
|
||||
unsigned char* output,
|
||||
std::streamsize outputLength)
|
||||
{
|
||||
// always fill up the buffer before writing!
|
||||
std::streamsize rsaSize = static_cast<std::streamsize>(blockSize());
|
||||
poco_assert_dbg(_pos <= rsaSize);
|
||||
poco_assert (outputLength >= rsaSize);
|
||||
int rc = 0;
|
||||
while (inputLength > 0)
|
||||
{
|
||||
// check how many data bytes we are missing to get the buffer full
|
||||
poco_assert_dbg (rsaSize >= _pos);
|
||||
std::streamsize missing = rsaSize - _pos;
|
||||
if (missing == 0)
|
||||
{
|
||||
poco_assert (outputLength >= rsaSize);
|
||||
int tmp = RSA_public_encrypt(rsaSize, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_NO_PADDING);
|
||||
if (tmp == -1)
|
||||
throwError();
|
||||
rc += tmp;
|
||||
output += tmp;
|
||||
outputLength -= tmp;
|
||||
_pos = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (missing > inputLength)
|
||||
missing = inputLength;
|
||||
|
||||
std::memcpy(_pBuf+_pos, input, missing);
|
||||
input += missing;
|
||||
_pos += missing;
|
||||
inputLength -= missing;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
std::streamsize RSAEncryptImpl::finalize(unsigned char* output, std::streamsize length)
|
||||
{
|
||||
poco_assert (length >= blockSize());
|
||||
int rc = 0;
|
||||
if (_pos > 0)
|
||||
{
|
||||
rc = RSA_public_encrypt(_pos, _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
|
||||
if (rc == -1)
|
||||
throwError();
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
class RSADecryptImpl: public CryptoTransform
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
OVERFLOW = 11
|
||||
};
|
||||
|
||||
RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode);
|
||||
~RSADecryptImpl();
|
||||
|
||||
std::size_t blockSize() const;
|
||||
|
||||
std::streamsize transform(
|
||||
const unsigned char* input,
|
||||
std::streamsize inputLength,
|
||||
unsigned char* output,
|
||||
std::streamsize outputLength);
|
||||
|
||||
std::streamsize finalize(
|
||||
unsigned char* output,
|
||||
std::streamsize length);
|
||||
|
||||
private:
|
||||
const RSA* _pRSA;
|
||||
RSAPaddingMode _paddingMode;
|
||||
std::streamsize _pos;
|
||||
unsigned char* _pBuf;
|
||||
};
|
||||
|
||||
|
||||
RSADecryptImpl::RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode):
|
||||
_pRSA(pRSA),
|
||||
_paddingMode(paddingMode),
|
||||
_pos(0),
|
||||
_pBuf(0)
|
||||
{
|
||||
_pBuf = new unsigned char[blockSize()];
|
||||
}
|
||||
|
||||
|
||||
RSADecryptImpl::~RSADecryptImpl()
|
||||
{
|
||||
delete _pBuf;
|
||||
}
|
||||
|
||||
|
||||
std::size_t RSADecryptImpl::blockSize() const
|
||||
{
|
||||
return RSA_size(_pRSA);
|
||||
}
|
||||
|
||||
|
||||
std::streamsize RSADecryptImpl::transform(
|
||||
const unsigned char* input,
|
||||
std::streamsize inputLength,
|
||||
unsigned char* output,
|
||||
std::streamsize outputLength)
|
||||
{
|
||||
|
||||
// always fill up the buffer before decrypting!
|
||||
std::streamsize rsaSize = static_cast<std::streamsize>(blockSize());
|
||||
poco_assert_dbg(_pos <= rsaSize);
|
||||
poco_assert (outputLength >= rsaSize);
|
||||
int rc = 0;
|
||||
while (inputLength > 0)
|
||||
{
|
||||
// check how many data bytes we are missing to get the buffer full
|
||||
poco_assert_dbg (rsaSize >= _pos);
|
||||
std::streamsize missing = rsaSize - _pos;
|
||||
if (missing == 0)
|
||||
{
|
||||
int tmp = RSA_private_decrypt(rsaSize, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_NO_PADDING);
|
||||
if (tmp == -1)
|
||||
throwError();
|
||||
rc += tmp;
|
||||
output += tmp;
|
||||
outputLength -= tmp;
|
||||
_pos = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (missing > inputLength)
|
||||
missing = inputLength;
|
||||
|
||||
std::memcpy(_pBuf+_pos, input, missing);
|
||||
input += missing;
|
||||
_pos += missing;
|
||||
inputLength -= missing;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
std::streamsize RSADecryptImpl::finalize(unsigned char* output, std::streamsize length)
|
||||
{
|
||||
poco_assert (length >= blockSize());
|
||||
int rc = 0;
|
||||
if (_pos > 0)
|
||||
{
|
||||
rc = RSA_private_decrypt(_pos, _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
|
||||
if (rc == -1)
|
||||
throwError();
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RSACipherImpl::RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode):
|
||||
_key(key),
|
||||
_paddingMode(paddingMode)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSACipherImpl::~RSACipherImpl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CryptoTransform* RSACipherImpl::createEncryptor()
|
||||
{
|
||||
return new RSAEncryptImpl(_key.impl()->getRSA(), _paddingMode);
|
||||
}
|
||||
|
||||
|
||||
CryptoTransform* RSACipherImpl::createDecryptor()
|
||||
{
|
||||
return new RSADecryptImpl(_key.impl()->getRSA(), _paddingMode);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
//
|
||||
// RSACipherImpl.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/src/RSACipherImpl.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSACipherImpl
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/RSACipherImpl.h"
|
||||
#include "Poco/Crypto/CryptoTransform.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
void throwError()
|
||||
{
|
||||
unsigned long err;
|
||||
std::string msg;
|
||||
|
||||
while ((err = ERR_get_error()))
|
||||
{
|
||||
if (!msg.empty())
|
||||
msg.append("; ");
|
||||
msg.append(ERR_error_string(err, 0));
|
||||
}
|
||||
|
||||
throw Poco::IOException(msg);
|
||||
}
|
||||
|
||||
|
||||
int mapPaddingMode(RSAPaddingMode paddingMode)
|
||||
{
|
||||
switch (paddingMode)
|
||||
{
|
||||
case RSA_PADDING_PKCS1:
|
||||
return RSA_PKCS1_PADDING;
|
||||
case RSA_PADDING_PKCS1_OAEP:
|
||||
return RSA_PKCS1_OAEP_PADDING;
|
||||
case RSA_PADDING_SSLV23:
|
||||
return RSA_SSLV23_PADDING;
|
||||
case RSA_PADDING_NONE:
|
||||
return RSA_NO_PADDING;
|
||||
default:
|
||||
poco_bugcheck();
|
||||
return RSA_NO_PADDING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class RSAEncryptImpl: public CryptoTransform
|
||||
{
|
||||
public:
|
||||
RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode);
|
||||
~RSAEncryptImpl();
|
||||
|
||||
std::size_t blockSize() const;
|
||||
std::size_t maxDataSize() const;
|
||||
|
||||
std::streamsize transform(
|
||||
const unsigned char* input,
|
||||
std::streamsize inputLength,
|
||||
unsigned char* output,
|
||||
std::streamsize outputLength);
|
||||
|
||||
std::streamsize finalize(unsigned char* output, std::streamsize length);
|
||||
|
||||
private:
|
||||
const RSA* _pRSA;
|
||||
RSAPaddingMode _paddingMode;
|
||||
std::streamsize _pos;
|
||||
unsigned char* _pBuf;
|
||||
};
|
||||
|
||||
|
||||
RSAEncryptImpl::RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode):
|
||||
_pRSA(pRSA),
|
||||
_paddingMode(paddingMode),
|
||||
_pos(0),
|
||||
_pBuf(0)
|
||||
{
|
||||
_pBuf = new unsigned char[blockSize()];
|
||||
}
|
||||
|
||||
|
||||
RSAEncryptImpl::~RSAEncryptImpl()
|
||||
{
|
||||
delete [] _pBuf;
|
||||
}
|
||||
|
||||
|
||||
std::size_t RSAEncryptImpl::blockSize() const
|
||||
{
|
||||
return RSA_size(_pRSA);
|
||||
}
|
||||
|
||||
|
||||
std::size_t RSAEncryptImpl::maxDataSize() const
|
||||
{
|
||||
std::size_t size = blockSize();
|
||||
switch (_paddingMode)
|
||||
{
|
||||
case RSA_PADDING_PKCS1:
|
||||
case RSA_PADDING_SSLV23:
|
||||
size -= 11;
|
||||
break;
|
||||
case RSA_PADDING_PKCS1_OAEP:
|
||||
size -= 41;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
std::streamsize RSAEncryptImpl::transform(
|
||||
const unsigned char* input,
|
||||
std::streamsize inputLength,
|
||||
unsigned char* output,
|
||||
std::streamsize outputLength)
|
||||
{
|
||||
// always fill up the buffer before writing!
|
||||
std::streamsize maxSize = static_cast<std::streamsize>(maxDataSize());
|
||||
std::streamsize rsaSize = static_cast<std::streamsize>(blockSize());
|
||||
poco_assert_dbg(_pos <= maxSize);
|
||||
poco_assert (outputLength >= rsaSize);
|
||||
int rc = 0;
|
||||
while (inputLength > 0)
|
||||
{
|
||||
// check how many data bytes we are missing to get the buffer full
|
||||
poco_assert_dbg (maxSize >= _pos);
|
||||
std::streamsize missing = maxSize - _pos;
|
||||
if (missing == 0)
|
||||
{
|
||||
poco_assert (outputLength >= rsaSize);
|
||||
int n = RSA_public_encrypt(static_cast<int>(maxSize), _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
|
||||
if (n == -1)
|
||||
throwError();
|
||||
rc += n;
|
||||
output += n;
|
||||
outputLength -= n;
|
||||
_pos = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (missing > inputLength)
|
||||
missing = inputLength;
|
||||
|
||||
std::memcpy(_pBuf + _pos, input, static_cast<std::size_t>(missing));
|
||||
input += missing;
|
||||
_pos += missing;
|
||||
inputLength -= missing;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
std::streamsize RSAEncryptImpl::finalize(unsigned char* output, std::streamsize length)
|
||||
{
|
||||
poco_assert (length >= blockSize());
|
||||
poco_assert (_pos <= maxDataSize());
|
||||
int rc = 0;
|
||||
if (_pos > 0)
|
||||
{
|
||||
rc = RSA_public_encrypt(static_cast<int>(_pos), _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
|
||||
if (rc == -1) throwError();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
class RSADecryptImpl: public CryptoTransform
|
||||
{
|
||||
public:
|
||||
RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode);
|
||||
~RSADecryptImpl();
|
||||
|
||||
std::size_t blockSize() const;
|
||||
|
||||
std::streamsize transform(
|
||||
const unsigned char* input,
|
||||
std::streamsize inputLength,
|
||||
unsigned char* output,
|
||||
std::streamsize outputLength);
|
||||
|
||||
std::streamsize finalize(
|
||||
unsigned char* output,
|
||||
std::streamsize length);
|
||||
|
||||
private:
|
||||
const RSA* _pRSA;
|
||||
RSAPaddingMode _paddingMode;
|
||||
std::streamsize _pos;
|
||||
unsigned char* _pBuf;
|
||||
};
|
||||
|
||||
|
||||
RSADecryptImpl::RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode):
|
||||
_pRSA(pRSA),
|
||||
_paddingMode(paddingMode),
|
||||
_pos(0),
|
||||
_pBuf(0)
|
||||
{
|
||||
_pBuf = new unsigned char[blockSize()];
|
||||
}
|
||||
|
||||
|
||||
RSADecryptImpl::~RSADecryptImpl()
|
||||
{
|
||||
delete [] _pBuf;
|
||||
}
|
||||
|
||||
|
||||
std::size_t RSADecryptImpl::blockSize() const
|
||||
{
|
||||
return RSA_size(_pRSA);
|
||||
}
|
||||
|
||||
|
||||
std::streamsize RSADecryptImpl::transform(
|
||||
const unsigned char* input,
|
||||
std::streamsize inputLength,
|
||||
unsigned char* output,
|
||||
std::streamsize outputLength)
|
||||
{
|
||||
|
||||
// always fill up the buffer before decrypting!
|
||||
std::streamsize rsaSize = static_cast<std::streamsize>(blockSize());
|
||||
poco_assert_dbg(_pos <= rsaSize);
|
||||
poco_assert (outputLength >= rsaSize);
|
||||
int rc = 0;
|
||||
while (inputLength > 0)
|
||||
{
|
||||
// check how many data bytes we are missing to get the buffer full
|
||||
poco_assert_dbg (rsaSize >= _pos);
|
||||
std::streamsize missing = rsaSize - _pos;
|
||||
if (missing == 0)
|
||||
{
|
||||
int tmp = RSA_private_decrypt(static_cast<int>(rsaSize), _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
|
||||
if (tmp == -1)
|
||||
throwError();
|
||||
rc += tmp;
|
||||
output += tmp;
|
||||
outputLength -= tmp;
|
||||
_pos = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (missing > inputLength)
|
||||
missing = inputLength;
|
||||
|
||||
std::memcpy(_pBuf + _pos, input, static_cast<std::size_t>(missing));
|
||||
input += missing;
|
||||
_pos += missing;
|
||||
inputLength -= missing;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
std::streamsize RSADecryptImpl::finalize(unsigned char* output, std::streamsize length)
|
||||
{
|
||||
poco_assert (length >= blockSize());
|
||||
int rc = 0;
|
||||
if (_pos > 0)
|
||||
{
|
||||
rc = RSA_private_decrypt(static_cast<int>(_pos), _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
|
||||
if (rc == -1)
|
||||
throwError();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RSACipherImpl::RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode):
|
||||
_key(key),
|
||||
_paddingMode(paddingMode)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSACipherImpl::~RSACipherImpl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CryptoTransform* RSACipherImpl::createEncryptor()
|
||||
{
|
||||
return new RSAEncryptImpl(_key.impl()->getRSA(), _paddingMode);
|
||||
}
|
||||
|
||||
|
||||
CryptoTransform* RSACipherImpl::createDecryptor()
|
||||
{
|
||||
return new RSADecryptImpl(_key.impl()->getRSA(), _paddingMode);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
@ -1,113 +1,113 @@
|
||||
//
|
||||
// RSADigestEngine.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/src/RSADigestEngine.cpp#3 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSADigestEngine
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/RSADigestEngine.h"
|
||||
#include <openssl/pem.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
RSADigestEngine::RSADigestEngine(const RSAKey& key, DigestType digestType):
|
||||
_key(key),
|
||||
_engine(digestType == DIGEST_MD5 ? static_cast<Poco::DigestEngine&>(_md5Engine) : static_cast<Poco::DigestEngine&>(_sha1Engine)),
|
||||
_type(digestType == DIGEST_MD5 ? NID_md5 : NID_sha1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSADigestEngine::~RSADigestEngine()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unsigned RSADigestEngine::digestLength() const
|
||||
{
|
||||
return _engine.digestLength();
|
||||
}
|
||||
|
||||
|
||||
void RSADigestEngine::reset()
|
||||
{
|
||||
_engine.reset();
|
||||
_digest.clear();
|
||||
_signature.clear();
|
||||
}
|
||||
|
||||
|
||||
const DigestEngine::Digest& RSADigestEngine::digest()
|
||||
{
|
||||
if (_digest.empty())
|
||||
{
|
||||
_digest = _engine.digest();
|
||||
}
|
||||
return _digest;
|
||||
}
|
||||
|
||||
|
||||
const DigestEngine::Digest& RSADigestEngine::signature()
|
||||
{
|
||||
if (_signature.empty())
|
||||
{
|
||||
digest();
|
||||
_signature.resize(_key.size());
|
||||
unsigned sigLen = static_cast<unsigned>(_signature.size());
|
||||
RSA_sign(_type, &_digest[0], static_cast<unsigned>(_digest.size()), &_signature[0], &sigLen, _key.impl()->getRSA());
|
||||
// truncate _sig to sigLen
|
||||
if (sigLen < _signature.size())
|
||||
_signature.resize(sigLen);
|
||||
}
|
||||
return _signature;
|
||||
}
|
||||
|
||||
|
||||
bool RSADigestEngine::verify(const DigestEngine::Digest& sig)
|
||||
{
|
||||
digest();
|
||||
DigestEngine::Digest sigCpy = sig; // copy becausse RSA_verify can modify sigCpy
|
||||
int ret = RSA_verify(_type, &_digest[0], static_cast<unsigned>(_digest.size()), &sigCpy[0], static_cast<unsigned>(sigCpy.size()), _key.impl()->getRSA());
|
||||
return ret != 0;
|
||||
}
|
||||
|
||||
|
||||
void RSADigestEngine::updateImpl(const void* data, unsigned length)
|
||||
{
|
||||
_engine.update(data, length);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
//
|
||||
// RSADigestEngine.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/src/RSADigestEngine.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSADigestEngine
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/RSADigestEngine.h"
|
||||
#include <openssl/pem.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
RSADigestEngine::RSADigestEngine(const RSAKey& key, DigestType digestType):
|
||||
_key(key),
|
||||
_engine(digestType == DIGEST_MD5 ? static_cast<Poco::DigestEngine&>(_md5Engine) : static_cast<Poco::DigestEngine&>(_sha1Engine)),
|
||||
_type(digestType == DIGEST_MD5 ? NID_md5 : NID_sha1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSADigestEngine::~RSADigestEngine()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unsigned RSADigestEngine::digestLength() const
|
||||
{
|
||||
return _engine.digestLength();
|
||||
}
|
||||
|
||||
|
||||
void RSADigestEngine::reset()
|
||||
{
|
||||
_engine.reset();
|
||||
_digest.clear();
|
||||
_signature.clear();
|
||||
}
|
||||
|
||||
|
||||
const DigestEngine::Digest& RSADigestEngine::digest()
|
||||
{
|
||||
if (_digest.empty())
|
||||
{
|
||||
_digest = _engine.digest();
|
||||
}
|
||||
return _digest;
|
||||
}
|
||||
|
||||
|
||||
const DigestEngine::Digest& RSADigestEngine::signature()
|
||||
{
|
||||
if (_signature.empty())
|
||||
{
|
||||
digest();
|
||||
_signature.resize(_key.size());
|
||||
unsigned sigLen = static_cast<unsigned>(_signature.size());
|
||||
RSA_sign(_type, &_digest[0], static_cast<unsigned>(_digest.size()), &_signature[0], &sigLen, _key.impl()->getRSA());
|
||||
// truncate _sig to sigLen
|
||||
if (sigLen < _signature.size())
|
||||
_signature.resize(sigLen);
|
||||
}
|
||||
return _signature;
|
||||
}
|
||||
|
||||
|
||||
bool RSADigestEngine::verify(const DigestEngine::Digest& sig)
|
||||
{
|
||||
digest();
|
||||
DigestEngine::Digest sigCpy = sig; // copy becausse RSA_verify can modify sigCpy
|
||||
int ret = RSA_verify(_type, &_digest[0], static_cast<unsigned>(_digest.size()), &sigCpy[0], static_cast<unsigned>(sigCpy.size()), _key.impl()->getRSA());
|
||||
return ret != 0;
|
||||
}
|
||||
|
||||
|
||||
void RSADigestEngine::updateImpl(const void* data, unsigned length)
|
||||
{
|
||||
_engine.update(data, length);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
@ -1,104 +1,127 @@
|
||||
//
|
||||
// RSAKey.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/src/RSAKey.cpp#4 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSAKey
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/RSAKey.h"
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
RSAKey::RSAKey(const X509Certificate& cert):
|
||||
_pImpl(new RSAKeyImpl(cert))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSAKey::RSAKey(KeyLength keyLength, Exponent exp):
|
||||
_pImpl(0)
|
||||
{
|
||||
int keyLen = keyLength;
|
||||
unsigned long expVal = RSA_3;
|
||||
if (expVal == EXP_LARGE)
|
||||
expVal = RSA_F4;
|
||||
_pImpl = new RSAKeyImpl(keyLen, expVal);
|
||||
}
|
||||
|
||||
|
||||
RSAKey::RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase):
|
||||
_pImpl(new RSAKeyImpl(publicKeyFile, privateKeyFile, privateKeyPassphrase))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSAKey::RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
|
||||
_pImpl(new RSAKeyImpl(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSAKey::~RSAKey()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int RSAKey::size() const
|
||||
{
|
||||
return _pImpl->size();
|
||||
}
|
||||
|
||||
|
||||
void RSAKey::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
|
||||
{
|
||||
_pImpl->save(publicKeyFile, privateKeyFile, privateKeyPassphrase);
|
||||
}
|
||||
|
||||
|
||||
void RSAKey::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase)
|
||||
{
|
||||
_pImpl->save(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase);
|
||||
}
|
||||
|
||||
|
||||
const std::string& RSAKey::name() const
|
||||
{
|
||||
static const std::string n("rsa");
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
//
|
||||
// RSAKey.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/src/RSAKey.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSAKey
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/RSAKey.h"
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
RSAKey::RSAKey(const X509Certificate& cert):
|
||||
_pImpl(new RSAKeyImpl(cert))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSAKey::RSAKey(KeyLength keyLength, Exponent exp):
|
||||
_pImpl(0)
|
||||
{
|
||||
int keyLen = keyLength;
|
||||
unsigned long expVal = RSA_3;
|
||||
if (exp == EXP_LARGE)
|
||||
expVal = RSA_F4;
|
||||
_pImpl = new RSAKeyImpl(keyLen, expVal);
|
||||
}
|
||||
|
||||
|
||||
RSAKey::RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase):
|
||||
_pImpl(new RSAKeyImpl(publicKeyFile, privateKeyFile, privateKeyPassphrase))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSAKey::RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
|
||||
_pImpl(new RSAKeyImpl(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSAKey::~RSAKey()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int RSAKey::size() const
|
||||
{
|
||||
return _pImpl->size();
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::ByteVec RSAKey::modulus() const
|
||||
{
|
||||
return _pImpl->modulus();
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::ByteVec RSAKey::encryptionExponent() const
|
||||
{
|
||||
return _pImpl->encryptionExponent();
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::ByteVec RSAKey::decryptionExponent() const
|
||||
{
|
||||
return _pImpl->decryptionExponent();
|
||||
}
|
||||
|
||||
|
||||
void RSAKey::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
|
||||
{
|
||||
_pImpl->save(publicKeyFile, privateKeyFile, privateKeyPassphrase);
|
||||
}
|
||||
|
||||
|
||||
void RSAKey::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase)
|
||||
{
|
||||
_pImpl->save(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase);
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
static const std::string RSA("rsa");
|
||||
}
|
||||
|
||||
|
||||
const std::string& RSAKey::name() const
|
||||
{
|
||||
return RSA;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
@ -1,291 +1,339 @@
|
||||
//
|
||||
// RSAKeyImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/src/RSAKeyImpl.cpp#3 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSAKeyImpl
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/RSAKeyImpl.h"
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include "Poco/TemporaryFile.h"
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert):
|
||||
_pRSA(0)
|
||||
{
|
||||
const X509* pCert = cert.certificate();
|
||||
EVP_PKEY* pKey = X509_get_pubkey(const_cast<X509*>(pCert));
|
||||
|
||||
RSA* pRSA = pKey->pkey.rsa;
|
||||
_pRSA = RSAPublicKey_dup(pRSA);
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent):
|
||||
_pRSA(0)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x00908000L
|
||||
_pRSA = RSA_new();
|
||||
int ret = 0;
|
||||
BIGNUM* bn = 0;
|
||||
try
|
||||
{
|
||||
bn = BN_new();
|
||||
BN_set_word(bn, exponent);
|
||||
ret = RSA_generate_key_ex(_pRSA, keyLength, bn, 0);
|
||||
BN_free(bn);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BN_free(bn);
|
||||
throw;
|
||||
}
|
||||
if (!ret) throw Poco::InvalidArgumentException("Failed to create RSA context");
|
||||
#else
|
||||
_pRSA = RSA_generate_key(keyLength, exponent, 0, 0);
|
||||
if (!_pRSA) throw Poco::InvalidArgumentException("Failed to create RSA context");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(
|
||||
const std::string& publicKeyFile,
|
||||
const std::string& privateKeyFile,
|
||||
const std::string& privateKeyPassphrase):
|
||||
_pRSA(0)
|
||||
{
|
||||
init(publicKeyFile, privateKeyFile, privateKeyPassphrase);
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
|
||||
_pRSA(0)
|
||||
{
|
||||
// due to C lib not supporting streams, we create two temporary files
|
||||
std::string publicKeyFile;
|
||||
Poco::TemporaryFile pubFile;
|
||||
if (pPublicKeyStream)
|
||||
{
|
||||
if (!pubFile.createFile())
|
||||
throw Poco::CreateFileException("Cannot create temporary file for writing public key");
|
||||
publicKeyFile = pubFile.path();
|
||||
Poco::FileOutputStream fout(publicKeyFile);
|
||||
Poco::StreamCopier::copyStream(*pPublicKeyStream, fout);
|
||||
}
|
||||
std::string privateKeyFile;
|
||||
Poco::TemporaryFile privFile;
|
||||
if (pPrivateKeyStream)
|
||||
{
|
||||
if (!privFile.createFile())
|
||||
throw Poco::CreateFileException("Cannot create temporary file for writing private key");
|
||||
privateKeyFile = privFile.path();
|
||||
Poco::FileOutputStream fout(privateKeyFile);
|
||||
Poco::StreamCopier::copyStream(*pPrivateKeyStream, fout);
|
||||
|
||||
}
|
||||
init(publicKeyFile, privateKeyFile, privateKeyPassphrase);
|
||||
}
|
||||
|
||||
|
||||
void RSAKeyImpl::init(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
|
||||
{
|
||||
poco_assert_dbg(_pRSA == 0);
|
||||
|
||||
_pRSA = RSA_new();
|
||||
if (!publicKeyFile.empty())
|
||||
{
|
||||
BIO* out = BIO_new(BIO_s_file());
|
||||
if (!out) throw Poco::IOException("Cannot create BIO for reading public key", publicKeyFile);
|
||||
int rc = BIO_read_filename(out, publicKeyFile.c_str());
|
||||
if (rc)
|
||||
{
|
||||
RSA* pubKey = PEM_read_bio_RSAPublicKey(out, &_pRSA, 0, 0);
|
||||
BIO_free(out);
|
||||
if (!pubKey)
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileException("Failed to load public key", publicKeyFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileNotFoundException("Public key file", publicKeyFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (!privateKeyFile.empty())
|
||||
{
|
||||
BIO* out = BIO_new(BIO_s_file());
|
||||
if (!out) throw Poco::IOException("Cannot create BIO for reading private key", privateKeyFile);
|
||||
int rc = BIO_read_filename(out, privateKeyFile.c_str());
|
||||
if (rc)
|
||||
{
|
||||
RSA* privKey = 0;
|
||||
if (privateKeyPassphrase.empty())
|
||||
privKey = PEM_read_bio_RSAPrivateKey(out, &_pRSA, 0, 0);
|
||||
else
|
||||
privKey = PEM_read_bio_RSAPrivateKey(out, &_pRSA, 0, const_cast<char*>(privateKeyPassphrase.c_str()));
|
||||
BIO_free(out);
|
||||
if (!privKey)
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileException("Failed to load private key", privateKeyFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileNotFoundException("Private key file", privateKeyFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::~RSAKeyImpl()
|
||||
{
|
||||
freeRSA();
|
||||
}
|
||||
|
||||
|
||||
void RSAKeyImpl::freeRSA()
|
||||
{
|
||||
if (_pRSA)
|
||||
RSA_free(_pRSA);
|
||||
_pRSA = 0;
|
||||
}
|
||||
|
||||
|
||||
int RSAKeyImpl::size() const
|
||||
{
|
||||
return RSA_size(_pRSA);
|
||||
}
|
||||
|
||||
|
||||
void RSAKeyImpl::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
|
||||
{
|
||||
if (!publicKeyFile.empty())
|
||||
{
|
||||
BIO* out = BIO_new(BIO_s_file());
|
||||
if (!out) throw Poco::IOException("Cannot create BIO for writing public key file", publicKeyFile);
|
||||
try
|
||||
{
|
||||
if (BIO_write_filename(out, const_cast<char*>(publicKeyFile.c_str())))
|
||||
{
|
||||
if (!PEM_write_bio_RSAPublicKey(out, _pRSA))
|
||||
throw Poco::WriteFileException("Failed to write public key to file", publicKeyFile);
|
||||
}
|
||||
else throw Poco::CreateFileException("Cannot create public key file");
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BIO_free(out);
|
||||
throw;
|
||||
}
|
||||
BIO_free(out);
|
||||
}
|
||||
|
||||
if (!privateKeyFile.empty())
|
||||
{
|
||||
BIO* out = BIO_new(BIO_s_file());
|
||||
if (!out) throw Poco::IOException("Cannot create BIO for writing private key file", privateKeyFile);
|
||||
try
|
||||
{
|
||||
if (BIO_write_filename(out, const_cast<char*>(privateKeyFile.c_str())))
|
||||
{
|
||||
int rc = 0;
|
||||
if (privateKeyPassphrase.empty())
|
||||
rc = PEM_write_bio_RSAPrivateKey(out, _pRSA, EVP_des_ede3_cbc(), 0, 0, 0, 0);
|
||||
else
|
||||
rc = PEM_write_bio_RSAPrivateKey(out, _pRSA, EVP_des_ede3_cbc(),
|
||||
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())),
|
||||
static_cast<int>(privateKeyPassphrase.length()), 0, 0);
|
||||
if (!rc) throw Poco::FileException("Failed to write private key to file", privateKeyFile);
|
||||
}
|
||||
else throw Poco::CreateFileException("Cannot create private key file", privateKeyFile);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BIO_free(out);
|
||||
throw;
|
||||
}
|
||||
BIO_free(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RSAKeyImpl::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase)
|
||||
{
|
||||
if (!pPublicKeyStream && !pPrivateKeyStream) return;
|
||||
|
||||
// due to C lib not supporting streams, we create two temporary files
|
||||
std::string publicKeyFile;
|
||||
Poco::TemporaryFile pubFile;
|
||||
if (pPublicKeyStream)
|
||||
{
|
||||
publicKeyFile = pubFile.path();
|
||||
if (!pubFile.createFile())
|
||||
throw Poco::CreateFileException("Cannot create temporary public file");
|
||||
}
|
||||
std::string privateKeyFile;
|
||||
Poco::TemporaryFile privFile;
|
||||
if (pPrivateKeyStream)
|
||||
{
|
||||
privateKeyFile = privFile.path();
|
||||
if (!privFile.createFile())
|
||||
throw Poco::FileException("Cannot crate temporary private key file");
|
||||
}
|
||||
save(publicKeyFile, privateKeyFile, privateKeyPassphrase);
|
||||
|
||||
// now copy everything from the temp files to the original streams
|
||||
if (pPublicKeyStream)
|
||||
{
|
||||
Poco::FileInputStream istr(publicKeyFile);
|
||||
Poco::StreamCopier::copyStream(istr, *pPublicKeyStream);
|
||||
}
|
||||
if (pPrivateKeyStream)
|
||||
{
|
||||
Poco::FileInputStream istr(privateKeyFile);
|
||||
Poco::StreamCopier::copyStream(istr, *pPrivateKeyStream);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
//
|
||||
// RSAKeyImpl.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/src/RSAKeyImpl.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: RSA
|
||||
// Module: RSAKeyImpl
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/RSAKeyImpl.h"
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include <sstream>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/evp.h>
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x00908000L
|
||||
#include <openssl/bn.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert):
|
||||
_pRSA(0)
|
||||
{
|
||||
const X509* pCert = cert.certificate();
|
||||
EVP_PKEY* pKey = X509_get_pubkey(const_cast<X509*>(pCert));
|
||||
_pRSA = EVP_PKEY_get1_RSA(pKey);
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent):
|
||||
_pRSA(0)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x00908000L
|
||||
_pRSA = RSA_new();
|
||||
int ret = 0;
|
||||
BIGNUM* bn = 0;
|
||||
try
|
||||
{
|
||||
bn = BN_new();
|
||||
BN_set_word(bn, exponent);
|
||||
ret = RSA_generate_key_ex(_pRSA, keyLength, bn, 0);
|
||||
BN_free(bn);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BN_free(bn);
|
||||
throw;
|
||||
}
|
||||
if (!ret) throw Poco::InvalidArgumentException("Failed to create RSA context");
|
||||
#else
|
||||
_pRSA = RSA_generate_key(keyLength, exponent, 0, 0);
|
||||
if (!_pRSA) throw Poco::InvalidArgumentException("Failed to create RSA context");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(
|
||||
const std::string& publicKeyFile,
|
||||
const std::string& privateKeyFile,
|
||||
const std::string& privateKeyPassphrase):
|
||||
_pRSA(0)
|
||||
{
|
||||
poco_assert_dbg(_pRSA == 0);
|
||||
|
||||
_pRSA = RSA_new();
|
||||
if (!publicKeyFile.empty())
|
||||
{
|
||||
BIO* bio = BIO_new(BIO_s_file());
|
||||
if (!bio) throw Poco::IOException("Cannot create BIO for reading public key", publicKeyFile);
|
||||
int rc = BIO_read_filename(bio, publicKeyFile.c_str());
|
||||
if (rc)
|
||||
{
|
||||
RSA* pubKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0);
|
||||
BIO_free(bio);
|
||||
if (!pubKey)
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileException("Failed to load public key", publicKeyFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileNotFoundException("Public key file", publicKeyFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (!privateKeyFile.empty())
|
||||
{
|
||||
BIO* bio = BIO_new(BIO_s_file());
|
||||
if (!bio) throw Poco::IOException("Cannot create BIO for reading private key", privateKeyFile);
|
||||
int rc = BIO_read_filename(bio, privateKeyFile.c_str());
|
||||
if (rc)
|
||||
{
|
||||
RSA* privKey = 0;
|
||||
if (privateKeyPassphrase.empty())
|
||||
privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, 0);
|
||||
else
|
||||
privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, const_cast<char*>(privateKeyPassphrase.c_str()));
|
||||
BIO_free(bio);
|
||||
if (!privKey)
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileException("Failed to load private key", privateKeyFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileNotFoundException("Private key file", privateKeyFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
|
||||
_pRSA(0)
|
||||
{
|
||||
poco_assert_dbg(_pRSA == 0);
|
||||
|
||||
_pRSA = RSA_new();
|
||||
if (pPublicKeyStream)
|
||||
{
|
||||
std::string publicKeyData;
|
||||
Poco::StreamCopier::copyToString(*pPublicKeyStream, publicKeyData);
|
||||
BIO* bio = BIO_new_mem_buf(const_cast<char*>(publicKeyData.data()), static_cast<int>(publicKeyData.size()));
|
||||
if (!bio) throw Poco::IOException("Cannot create BIO for reading public key");
|
||||
RSA* publicKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0);
|
||||
BIO_free(bio);
|
||||
if (!publicKey)
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileException("Failed to load public key");
|
||||
}
|
||||
}
|
||||
|
||||
if (pPrivateKeyStream)
|
||||
{
|
||||
std::string privateKeyData;
|
||||
Poco::StreamCopier::copyToString(*pPrivateKeyStream, privateKeyData);
|
||||
BIO* bio = BIO_new_mem_buf(const_cast<char*>(privateKeyData.data()), static_cast<int>(privateKeyData.size()));
|
||||
if (!bio) throw Poco::IOException("Cannot create BIO for reading private key");
|
||||
RSA* privateKey = 0;
|
||||
if (privateKeyPassphrase.empty())
|
||||
privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, 0);
|
||||
else
|
||||
privateKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, const_cast<char*>(privateKeyPassphrase.c_str()));
|
||||
BIO_free(bio);
|
||||
if (!privateKey)
|
||||
{
|
||||
freeRSA();
|
||||
throw Poco::FileException("Failed to load private key");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::~RSAKeyImpl()
|
||||
{
|
||||
freeRSA();
|
||||
}
|
||||
|
||||
|
||||
void RSAKeyImpl::freeRSA()
|
||||
{
|
||||
if (_pRSA)
|
||||
RSA_free(_pRSA);
|
||||
_pRSA = 0;
|
||||
}
|
||||
|
||||
|
||||
int RSAKeyImpl::size() const
|
||||
{
|
||||
return RSA_size(_pRSA);
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::ByteVec RSAKeyImpl::modulus() const
|
||||
{
|
||||
return convertToByteVec(_pRSA->n);
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::ByteVec RSAKeyImpl::encryptionExponent() const
|
||||
{
|
||||
return convertToByteVec(_pRSA->e);
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::ByteVec RSAKeyImpl::decryptionExponent() const
|
||||
{
|
||||
return convertToByteVec(_pRSA->d);
|
||||
}
|
||||
|
||||
|
||||
void RSAKeyImpl::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
|
||||
{
|
||||
if (!publicKeyFile.empty())
|
||||
{
|
||||
BIO* bio = BIO_new(BIO_s_file());
|
||||
if (!bio) throw Poco::IOException("Cannot create BIO for writing public key file", publicKeyFile);
|
||||
try
|
||||
{
|
||||
if (BIO_write_filename(bio, const_cast<char*>(publicKeyFile.c_str())))
|
||||
{
|
||||
if (!PEM_write_bio_RSAPublicKey(bio, _pRSA))
|
||||
throw Poco::WriteFileException("Failed to write public key to file", publicKeyFile);
|
||||
}
|
||||
else throw Poco::CreateFileException("Cannot create public key file");
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BIO_free(bio);
|
||||
throw;
|
||||
}
|
||||
BIO_free(bio);
|
||||
}
|
||||
|
||||
if (!privateKeyFile.empty())
|
||||
{
|
||||
BIO* bio = BIO_new(BIO_s_file());
|
||||
if (!bio) throw Poco::IOException("Cannot create BIO for writing private key file", privateKeyFile);
|
||||
try
|
||||
{
|
||||
if (BIO_write_filename(bio, const_cast<char*>(privateKeyFile.c_str())))
|
||||
{
|
||||
int rc = 0;
|
||||
if (privateKeyPassphrase.empty())
|
||||
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(), 0, 0, 0, 0);
|
||||
else
|
||||
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(),
|
||||
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())),
|
||||
static_cast<int>(privateKeyPassphrase.length()), 0, 0);
|
||||
if (!rc) throw Poco::FileException("Failed to write private key to file", privateKeyFile);
|
||||
}
|
||||
else throw Poco::CreateFileException("Cannot create private key file", privateKeyFile);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BIO_free(bio);
|
||||
throw;
|
||||
}
|
||||
BIO_free(bio);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RSAKeyImpl::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase)
|
||||
{
|
||||
if (pPublicKeyStream)
|
||||
{
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
if (!bio) throw Poco::IOException("Cannot create BIO for writing public key");
|
||||
if (!PEM_write_bio_RSAPublicKey(bio, _pRSA))
|
||||
{
|
||||
BIO_free(bio);
|
||||
throw Poco::WriteFileException("Failed to write public key to stream");
|
||||
}
|
||||
char* pData;
|
||||
long size = BIO_get_mem_data(bio, &pData);
|
||||
pPublicKeyStream->write(pData, static_cast<std::streamsize>(size));
|
||||
BIO_free(bio);
|
||||
}
|
||||
|
||||
if (pPrivateKeyStream)
|
||||
{
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
if (!bio) throw Poco::IOException("Cannot create BIO for writing public key");
|
||||
int rc = 0;
|
||||
if (privateKeyPassphrase.empty())
|
||||
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(), 0, 0, 0, 0);
|
||||
else
|
||||
rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(),
|
||||
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())),
|
||||
static_cast<int>(privateKeyPassphrase.length()), 0, 0);
|
||||
if (!rc)
|
||||
{
|
||||
BIO_free(bio);
|
||||
throw Poco::FileException("Failed to write private key to stream");
|
||||
}
|
||||
char* pData;
|
||||
long size = BIO_get_mem_data(bio, &pData);
|
||||
pPrivateKeyStream->write(pData, static_cast<std::streamsize>(size));
|
||||
BIO_free(bio);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RSAKeyImpl::ByteVec RSAKeyImpl::convertToByteVec(const BIGNUM* bn)
|
||||
{
|
||||
int numBytes = BN_num_bytes(bn);
|
||||
ByteVec byteVector(numBytes);
|
||||
|
||||
ByteVec::value_type* buffer = new ByteVec::value_type[numBytes];
|
||||
BN_bn2bin(bn, buffer);
|
||||
|
||||
for (int i = 0; i < numBytes; ++i)
|
||||
byteVector[i] = buffer[i];
|
||||
|
||||
delete [] buffer;
|
||||
|
||||
return byteVector;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
@ -1,290 +1,303 @@
|
||||
//
|
||||
// X509Certificate.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/src/X509Certificate.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Certificate
|
||||
// Module: X509Certificate
|
||||
//
|
||||
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/DateTimeParser.h"
|
||||
#include <sstream>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(std::istream& istr):
|
||||
_pCert(0)
|
||||
{
|
||||
load(istr);
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(const std::string& path):
|
||||
_pCert(0)
|
||||
{
|
||||
load(path);
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(X509* pCert):
|
||||
_pCert(pCert)
|
||||
{
|
||||
poco_check_ptr(_pCert);
|
||||
|
||||
_pCert = X509_dup(_pCert);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(const X509Certificate& cert):
|
||||
_issuerName(cert._issuerName),
|
||||
_subjectName(cert._subjectName),
|
||||
_pCert(cert._pCert)
|
||||
{
|
||||
_pCert = X509_dup(_pCert);
|
||||
}
|
||||
|
||||
|
||||
X509Certificate& X509Certificate::operator = (const X509Certificate& cert)
|
||||
{
|
||||
X509Certificate tmp(cert);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::swap(X509Certificate& cert)
|
||||
{
|
||||
using std::swap;
|
||||
swap(cert._issuerName, _issuerName);
|
||||
swap(cert._subjectName, _subjectName);
|
||||
swap(cert._pCert, _pCert);
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::~X509Certificate()
|
||||
{
|
||||
X509_free(_pCert);
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::load(std::istream& istr)
|
||||
{
|
||||
poco_assert (!_pCert);
|
||||
|
||||
std::stringstream certStream;
|
||||
Poco::StreamCopier::copyStream(istr, certStream);
|
||||
std::string cert = certStream.str();
|
||||
|
||||
BIO *pBIO = BIO_new_mem_buf(const_cast<char*>(cert.data()), static_cast<int>(cert.size()));
|
||||
if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate");
|
||||
_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
|
||||
BIO_free(pBIO);
|
||||
|
||||
if (!_pCert) throw Poco::IOException("Faild to load certificate from stream");
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::load(const std::string& path)
|
||||
{
|
||||
poco_assert (!_pCert);
|
||||
|
||||
BIO *pBIO = BIO_new(BIO_s_file());
|
||||
if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate file", path);
|
||||
if (!BIO_read_filename(pBIO, path.c_str()))
|
||||
{
|
||||
BIO_free(pBIO);
|
||||
throw Poco::OpenFileException("Cannot open certificate file for reading", path);
|
||||
}
|
||||
|
||||
_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
|
||||
BIO_free(pBIO);
|
||||
|
||||
if (!_pCert) throw Poco::ReadFileException("Faild to load certificate from", path);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::save(std::ostream& stream) const
|
||||
{
|
||||
BIO *pBIO = BIO_new(BIO_s_mem());
|
||||
if (!pBIO) throw Poco::IOException("Cannot create BIO for writing certificate");
|
||||
try
|
||||
{
|
||||
if (!PEM_write_bio_X509(pBIO, _pCert))
|
||||
throw Poco::IOException("Failed to write certificate to stream");
|
||||
|
||||
char *pData;
|
||||
long size;
|
||||
size = BIO_get_mem_data(pBIO, &pData);
|
||||
stream.write(pData, size);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BIO_free(pBIO);
|
||||
throw;
|
||||
}
|
||||
BIO_free(pBIO);
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::save(const std::string& path) const
|
||||
{
|
||||
BIO *pBIO = BIO_new(BIO_s_file());
|
||||
if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate file", path);
|
||||
if (!BIO_write_filename(pBIO, const_cast<char*>(path.c_str())))
|
||||
{
|
||||
BIO_free(pBIO);
|
||||
throw Poco::CreateFileException("Cannot create certificate file", path);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (!PEM_write_bio_X509(pBIO, _pCert))
|
||||
throw Poco::WriteFileException("Failed to write certificate to file", path);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BIO_free(pBIO);
|
||||
throw;
|
||||
}
|
||||
BIO_free(pBIO);
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::init()
|
||||
{
|
||||
char buffer[NAME_BUFFER_SIZE];
|
||||
X509_NAME_oneline(X509_get_issuer_name(_pCert), buffer, sizeof(buffer));
|
||||
_issuerName = buffer;
|
||||
X509_NAME_oneline(X509_get_subject_name(_pCert), buffer, sizeof(buffer));
|
||||
_subjectName = buffer;
|
||||
}
|
||||
|
||||
|
||||
std::string X509Certificate::commonName() const
|
||||
{
|
||||
return subjectName(NID_COMMON_NAME);
|
||||
}
|
||||
|
||||
|
||||
std::string X509Certificate::issuerName(NID nid) const
|
||||
{
|
||||
if (X509_NAME* issuer = X509_get_issuer_name(_pCert))
|
||||
{
|
||||
char buffer[NAME_BUFFER_SIZE];
|
||||
X509_NAME_get_text_by_NID(issuer, nid, buffer, sizeof(buffer));
|
||||
return std::string(buffer);
|
||||
}
|
||||
else return std::string();
|
||||
}
|
||||
|
||||
|
||||
std::string X509Certificate::subjectName(NID nid) const
|
||||
{
|
||||
if (X509_NAME* subj = X509_get_subject_name(_pCert))
|
||||
{
|
||||
char buffer[NAME_BUFFER_SIZE];
|
||||
X509_NAME_get_text_by_NID(subj, nid, buffer, sizeof(buffer));
|
||||
return std::string(buffer);
|
||||
}
|
||||
else return std::string();
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>& domainNames) const
|
||||
{
|
||||
domainNames.clear();
|
||||
if (STACK_OF(GENERAL_NAME)* names = static_cast<STACK_OF(GENERAL_NAME)*>(X509_get_ext_d2i(_pCert, NID_subject_alt_name, 0, 0)))
|
||||
{
|
||||
for (int i = 0; i < sk_GENERAL_NAME_num(names); ++i)
|
||||
{
|
||||
const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i);
|
||||
if (name->type == GEN_DNS)
|
||||
{
|
||||
const char* data = reinterpret_cast<char*>(ASN1_STRING_data(name->d.ia5));
|
||||
std::size_t len = ASN1_STRING_length(name->d.ia5);
|
||||
domainNames.insert(std::string(data, len));
|
||||
}
|
||||
}
|
||||
GENERAL_NAMES_free(names);
|
||||
}
|
||||
|
||||
cmnName = commonName();
|
||||
if (!cmnName.empty() && domainNames.empty())
|
||||
{
|
||||
domainNames.insert(cmnName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Poco::DateTime X509Certificate::validFrom() const
|
||||
{
|
||||
ASN1_TIME* certTime = X509_get_notBefore(_pCert);
|
||||
std::string dateTime(reinterpret_cast<char*>(certTime->data));
|
||||
int tzd;
|
||||
return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
|
||||
}
|
||||
|
||||
|
||||
Poco::DateTime X509Certificate::expiresOn() const
|
||||
{
|
||||
ASN1_TIME* certTime = X509_get_notAfter(_pCert);
|
||||
std::string dateTime(reinterpret_cast<char*>(certTime->data));
|
||||
int tzd;
|
||||
return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
|
||||
}
|
||||
|
||||
|
||||
bool X509Certificate::issuedBy(const X509Certificate& issuerCertificate) const
|
||||
{
|
||||
X509* pCert = const_cast<X509*>(_pCert);
|
||||
X509* pIssuerCert = const_cast<X509*>(issuerCertificate.certificate());
|
||||
EVP_PKEY* pIssuerPublicKey = X509_get_pubkey(pIssuerCert);
|
||||
if (!pIssuerPublicKey) throw Poco::InvalidArgumentException("Issuer certificate has no public key");
|
||||
int rc = X509_verify(pCert, pIssuerPublicKey);
|
||||
EVP_PKEY_free(pIssuerPublicKey);
|
||||
return rc != 0;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
//
|
||||
// X509Certificate.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/src/X509Certificate.cpp#1 $
|
||||
//
|
||||
// Library: Crypto
|
||||
// Package: Certificate
|
||||
// Module: X509Certificate
|
||||
//
|
||||
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/DateTimeParser.h"
|
||||
#include <sstream>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Crypto {
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(std::istream& istr):
|
||||
_pCert(0)
|
||||
{
|
||||
load(istr);
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(const std::string& path):
|
||||
_pCert(0)
|
||||
{
|
||||
load(path);
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(X509* pCert):
|
||||
_pCert(pCert)
|
||||
{
|
||||
poco_check_ptr(_pCert);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(X509* pCert, bool shared):
|
||||
_pCert(pCert)
|
||||
{
|
||||
poco_check_ptr(_pCert);
|
||||
|
||||
if (shared)
|
||||
{
|
||||
_pCert->references++;
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::X509Certificate(const X509Certificate& cert):
|
||||
_issuerName(cert._issuerName),
|
||||
_subjectName(cert._subjectName),
|
||||
_pCert(cert._pCert)
|
||||
{
|
||||
_pCert = X509_dup(_pCert);
|
||||
}
|
||||
|
||||
|
||||
X509Certificate& X509Certificate::operator = (const X509Certificate& cert)
|
||||
{
|
||||
X509Certificate tmp(cert);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::swap(X509Certificate& cert)
|
||||
{
|
||||
using std::swap;
|
||||
swap(cert._issuerName, _issuerName);
|
||||
swap(cert._subjectName, _subjectName);
|
||||
swap(cert._pCert, _pCert);
|
||||
}
|
||||
|
||||
|
||||
X509Certificate::~X509Certificate()
|
||||
{
|
||||
X509_free(_pCert);
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::load(std::istream& istr)
|
||||
{
|
||||
poco_assert (!_pCert);
|
||||
|
||||
std::stringstream certStream;
|
||||
Poco::StreamCopier::copyStream(istr, certStream);
|
||||
std::string cert = certStream.str();
|
||||
|
||||
BIO *pBIO = BIO_new_mem_buf(const_cast<char*>(cert.data()), static_cast<int>(cert.size()));
|
||||
if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate");
|
||||
_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
|
||||
BIO_free(pBIO);
|
||||
|
||||
if (!_pCert) throw Poco::IOException("Faild to load certificate from stream");
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::load(const std::string& path)
|
||||
{
|
||||
poco_assert (!_pCert);
|
||||
|
||||
BIO *pBIO = BIO_new(BIO_s_file());
|
||||
if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate file", path);
|
||||
if (!BIO_read_filename(pBIO, path.c_str()))
|
||||
{
|
||||
BIO_free(pBIO);
|
||||
throw Poco::OpenFileException("Cannot open certificate file for reading", path);
|
||||
}
|
||||
|
||||
_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
|
||||
BIO_free(pBIO);
|
||||
|
||||
if (!_pCert) throw Poco::ReadFileException("Faild to load certificate from", path);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::save(std::ostream& stream) const
|
||||
{
|
||||
BIO *pBIO = BIO_new(BIO_s_mem());
|
||||
if (!pBIO) throw Poco::IOException("Cannot create BIO for writing certificate");
|
||||
try
|
||||
{
|
||||
if (!PEM_write_bio_X509(pBIO, _pCert))
|
||||
throw Poco::IOException("Failed to write certificate to stream");
|
||||
|
||||
char *pData;
|
||||
long size;
|
||||
size = BIO_get_mem_data(pBIO, &pData);
|
||||
stream.write(pData, size);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BIO_free(pBIO);
|
||||
throw;
|
||||
}
|
||||
BIO_free(pBIO);
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::save(const std::string& path) const
|
||||
{
|
||||
BIO *pBIO = BIO_new(BIO_s_file());
|
||||
if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate file", path);
|
||||
if (!BIO_write_filename(pBIO, const_cast<char*>(path.c_str())))
|
||||
{
|
||||
BIO_free(pBIO);
|
||||
throw Poco::CreateFileException("Cannot create certificate file", path);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (!PEM_write_bio_X509(pBIO, _pCert))
|
||||
throw Poco::WriteFileException("Failed to write certificate to file", path);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
BIO_free(pBIO);
|
||||
throw;
|
||||
}
|
||||
BIO_free(pBIO);
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::init()
|
||||
{
|
||||
char buffer[NAME_BUFFER_SIZE];
|
||||
X509_NAME_oneline(X509_get_issuer_name(_pCert), buffer, sizeof(buffer));
|
||||
_issuerName = buffer;
|
||||
X509_NAME_oneline(X509_get_subject_name(_pCert), buffer, sizeof(buffer));
|
||||
_subjectName = buffer;
|
||||
}
|
||||
|
||||
|
||||
std::string X509Certificate::commonName() const
|
||||
{
|
||||
return subjectName(NID_COMMON_NAME);
|
||||
}
|
||||
|
||||
|
||||
std::string X509Certificate::issuerName(NID nid) const
|
||||
{
|
||||
if (X509_NAME* issuer = X509_get_issuer_name(_pCert))
|
||||
{
|
||||
char buffer[NAME_BUFFER_SIZE];
|
||||
X509_NAME_get_text_by_NID(issuer, nid, buffer, sizeof(buffer));
|
||||
return std::string(buffer);
|
||||
}
|
||||
else return std::string();
|
||||
}
|
||||
|
||||
|
||||
std::string X509Certificate::subjectName(NID nid) const
|
||||
{
|
||||
if (X509_NAME* subj = X509_get_subject_name(_pCert))
|
||||
{
|
||||
char buffer[NAME_BUFFER_SIZE];
|
||||
X509_NAME_get_text_by_NID(subj, nid, buffer, sizeof(buffer));
|
||||
return std::string(buffer);
|
||||
}
|
||||
else return std::string();
|
||||
}
|
||||
|
||||
|
||||
void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>& domainNames) const
|
||||
{
|
||||
domainNames.clear();
|
||||
if (STACK_OF(GENERAL_NAME)* names = static_cast<STACK_OF(GENERAL_NAME)*>(X509_get_ext_d2i(_pCert, NID_subject_alt_name, 0, 0)))
|
||||
{
|
||||
for (int i = 0; i < sk_GENERAL_NAME_num(names); ++i)
|
||||
{
|
||||
const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i);
|
||||
if (name->type == GEN_DNS)
|
||||
{
|
||||
const char* data = reinterpret_cast<char*>(ASN1_STRING_data(name->d.ia5));
|
||||
std::size_t len = ASN1_STRING_length(name->d.ia5);
|
||||
domainNames.insert(std::string(data, len));
|
||||
}
|
||||
}
|
||||
GENERAL_NAMES_free(names);
|
||||
}
|
||||
|
||||
cmnName = commonName();
|
||||
if (!cmnName.empty() && domainNames.empty())
|
||||
{
|
||||
domainNames.insert(cmnName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Poco::DateTime X509Certificate::validFrom() const
|
||||
{
|
||||
ASN1_TIME* certTime = X509_get_notBefore(_pCert);
|
||||
std::string dateTime(reinterpret_cast<char*>(certTime->data));
|
||||
int tzd;
|
||||
return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
|
||||
}
|
||||
|
||||
|
||||
Poco::DateTime X509Certificate::expiresOn() const
|
||||
{
|
||||
ASN1_TIME* certTime = X509_get_notAfter(_pCert);
|
||||
std::string dateTime(reinterpret_cast<char*>(certTime->data));
|
||||
int tzd;
|
||||
return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
|
||||
}
|
||||
|
||||
|
||||
bool X509Certificate::issuedBy(const X509Certificate& issuerCertificate) const
|
||||
{
|
||||
X509* pCert = const_cast<X509*>(_pCert);
|
||||
X509* pIssuerCert = const_cast<X509*>(issuerCertificate.certificate());
|
||||
EVP_PKEY* pIssuerPublicKey = X509_get_pubkey(pIssuerCert);
|
||||
if (!pIssuerPublicKey) throw Poco::InvalidArgumentException("Issuer certificate has no public key");
|
||||
int rc = X509_verify(pCert, pIssuerPublicKey);
|
||||
EVP_PKEY_free(pIssuerPublicKey);
|
||||
return rc != 0;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Crypto
|
||||
|
315
Crypto/testsuite/TestSuite_vs100.vcxproj
Normal file
315
Crypto/testsuite/TestSuite_vs100.vcxproj
Normal file
@ -0,0 +1,315 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="debug_shared|Win32">
|
||||
<Configuration>debug_shared</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_md|Win32">
|
||||
<Configuration>debug_static_md</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_mt|Win32">
|
||||
<Configuration>debug_static_mt</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_shared|Win32">
|
||||
<Configuration>release_shared</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_md|Win32">
|
||||
<Configuration>release_static_md</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_mt|Win32">
|
||||
<Configuration>release_static_mt</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>TestSuite</ProjectName>
|
||||
<ProjectGuid>{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}</ProjectGuid>
|
||||
<RootNamespace>TestSuite</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
||||
<ImportGroup Label="ExtensionSettings"/>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros"/>
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">bin\static_mt\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">bin\static_mt\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">bin\static_md\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">bin\static_md\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">obj\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">false</LinkIncremental>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">TestSuited</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">TestSuited</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">TestSuited</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">TestSuite</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">TestSuite</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">TestSuite</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitd.lib;WinTestRunnerd.lib;ws2_32.lib;iphlpapi.lib;libeay32mdd.lib;ssleay32mdd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\TestSuited.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin\TestSuited.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnit.lib;WinTestRunner.lib;ws2_32.lib;iphlpapi.lib;libeay32md.lib;ssleay32md.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\TestSuite.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitmtd.lib;WinTestRunnermtd.lib;iphlpapi.lib;winmm.lib;nafxcwd.lib;libcmtd.lib;WinTestRunner.res;ws2_32.lib;iphlpapi.lib;libeay32mtd.lib;ssleay32mtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\static_mt\TestSuited.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>nafxcwd.lib;libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin\static_mt\TestSuited.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitmt.lib;WinTestRunnermt.lib;iphlpapi.lib;winmm.lib;nafxcw.lib;libcmt.lib;WinTestRunner.res;ws2_32.lib;iphlpapi.lib;libeay32mt.lib;ssleay32mt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\static_mt\TestSuite.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>nafxcw.lib;libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitmdd.lib;WinTestRunnermdd.lib;iphlpapi.lib;winmm.lib;WinTestRunner.res;ws2_32.lib;iphlpapi.lib;libeay32mdd.lib;ssleay32mdd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\static_md\TestSuited.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin\static_md\TestSuited.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitmd.lib;WinTestRunnermd.lib;iphlpapi.lib;winmm.lib;WinTestRunner.res;ws2_32.lib;iphlpapi.lib;libeay32md.lib;ssleay32md.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin\static_md\TestSuite.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\CryptoTest.h"/>
|
||||
<ClInclude Include="src\RSATest.h"/>
|
||||
<ClInclude Include="src\CryptoTestSuite.h"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\CryptoTest.cpp"/>
|
||||
<ClCompile Include="src\RSATest.cpp"/>
|
||||
<ClCompile Include="src\CryptoTestSuite.cpp"/>
|
||||
<ClCompile Include="src\WinDriver.cpp"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
||||
<ImportGroup Label="ExtensionTargets"/>
|
||||
</Project>
|
54
Crypto/testsuite/TestSuite_vs100.vcxproj.filters
Normal file
54
Crypto/testsuite/TestSuite_vs100.vcxproj.filters
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Crypto">
|
||||
<UniqueIdentifier>{02debdde-8664-412b-ba6c-4c13197de6f9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Crypto\Header Files">
|
||||
<UniqueIdentifier>{2311d4f4-8f52-459d-8caa-4febea4f0654}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Crypto\Source Files">
|
||||
<UniqueIdentifier>{536bcab9-b11f-4dc2-bb55-ed2fc7101adf}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Suite">
|
||||
<UniqueIdentifier>{4d25d62e-2b08-4863-8e6e-a37a27784732}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Suite\Header Files">
|
||||
<UniqueIdentifier>{a197b9e5-7e95-4f57-a438-237041d9a3c4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Suite\Source Files">
|
||||
<UniqueIdentifier>{9df90fce-71cf-4b62-af6b-b1edadb7e6e2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Driver">
|
||||
<UniqueIdentifier>{a248980e-d5c3-41f7-a739-cd98b2f9f766}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Driver\Source Files">
|
||||
<UniqueIdentifier>{e3b401c0-2adc-4abc-96a3-07d3520ba75d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\CryptoTest.h">
|
||||
<Filter>Crypto\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\RSATest.h">
|
||||
<Filter>Crypto\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\CryptoTestSuite.h">
|
||||
<Filter>_Suite\Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\CryptoTest.cpp">
|
||||
<Filter>Crypto\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSATest.cpp">
|
||||
<Filter>Crypto\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CryptoTestSuite.cpp">
|
||||
<Filter>_Suite\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\WinDriver.cpp">
|
||||
<Filter>_Driver\Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
3
Crypto/testsuite/TestSuite_vs100.vcxproj.user
Normal file
3
Crypto/testsuite/TestSuite_vs100.vcxproj.user
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
315
Crypto/testsuite/TestSuite_x64_vs100.vcxproj
Normal file
315
Crypto/testsuite/TestSuite_x64_vs100.vcxproj
Normal file
@ -0,0 +1,315 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="debug_shared|x64">
|
||||
<Configuration>debug_shared</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_md|x64">
|
||||
<Configuration>debug_static_md</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="debug_static_mt|x64">
|
||||
<Configuration>debug_static_mt</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_shared|x64">
|
||||
<Configuration>release_shared</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_md|x64">
|
||||
<Configuration>release_static_md</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="release_static_mt|x64">
|
||||
<Configuration>release_static_mt</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>TestSuite</ProjectName>
|
||||
<ProjectGuid>{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}</ProjectGuid>
|
||||
<RootNamespace>TestSuite</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
||||
<ImportGroup Label="ExtensionSettings"/>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'" Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros"/>
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">bin64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">bin64\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">bin64\static_mt\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">bin64\static_mt\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">bin64\static_md\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">bin64\static_md\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">obj64\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">false</LinkIncremental>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">TestSuited</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">TestSuited</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">TestSuited</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">TestSuite</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">TestSuite</TargetName>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">TestSuite</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitd.lib;WinTestRunnerd.lib;ws2_32.lib;iphlpapi.lib;libeay32mdd.lib;ssleay32mdd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\TestSuited.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin64\TestSuited.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnit.lib;WinTestRunner.lib;ws2_32.lib;iphlpapi.lib;libeay32md.lib;ssleay32md.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\TestSuite.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitmtd.lib;WinTestRunnermtd.lib;iphlpapi.lib;winmm.lib;nafxcwd.lib;libcmtd.lib;WinTestRunner.res;ws2_32.lib;iphlpapi.lib;libeay32mtd.lib;ssleay32mtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\static_mt\TestSuited.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>nafxcwd.lib;libcmtd.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin64\static_mt\TestSuited.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitmt.lib;WinTestRunnermt.lib;iphlpapi.lib;winmm.lib;nafxcw.lib;libcmt.lib;WinTestRunner.res;ws2_32.lib;iphlpapi.lib;libeay32mt.lib;ssleay32mt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\static_mt\TestSuite.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>nafxcw.lib;libcmt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitmdd.lib;WinTestRunnermdd.lib;iphlpapi.lib;winmm.lib;WinTestRunner.res;ws2_32.lib;iphlpapi.lib;libeay32mdd.lib;ssleay32mdd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\static_md\TestSuited.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>bin64\static_md\TestSuited.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader/>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat/>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>CppUnitmd.lib;WinTestRunnermd.lib;iphlpapi.lib;winmm.lib;WinTestRunner.res;ws2_32.lib;iphlpapi.lib;libeay32md.lib;ssleay32md.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>bin64\static_md\TestSuite.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\CryptoTest.h"/>
|
||||
<ClInclude Include="src\RSATest.h"/>
|
||||
<ClInclude Include="src\CryptoTestSuite.h"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\CryptoTest.cpp"/>
|
||||
<ClCompile Include="src\RSATest.cpp"/>
|
||||
<ClCompile Include="src\CryptoTestSuite.cpp"/>
|
||||
<ClCompile Include="src\WinDriver.cpp"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
||||
<ImportGroup Label="ExtensionTargets"/>
|
||||
</Project>
|
54
Crypto/testsuite/TestSuite_x64_vs100.vcxproj.filters
Normal file
54
Crypto/testsuite/TestSuite_x64_vs100.vcxproj.filters
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Crypto">
|
||||
<UniqueIdentifier>{45de6552-2469-4aa8-8899-1ba5f38d254e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Crypto\Header Files">
|
||||
<UniqueIdentifier>{4bee1bf3-cc02-4a05-9641-75f380833200}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Crypto\Source Files">
|
||||
<UniqueIdentifier>{7f034d6f-f9ca-473d-ac5f-8b3c77ded478}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Suite">
|
||||
<UniqueIdentifier>{f60d96dc-db3f-45df-be9d-db76636df680}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Suite\Header Files">
|
||||
<UniqueIdentifier>{d213663c-3c68-41c6-b524-0106d1081ec9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Suite\Source Files">
|
||||
<UniqueIdentifier>{640d3c67-4362-495e-adf0-09a264035999}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Driver">
|
||||
<UniqueIdentifier>{6da1fb8e-0d60-4331-b7c8-b0b1e13f7213}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="_Driver\Source Files">
|
||||
<UniqueIdentifier>{4f158ef4-cabf-4331-bdd3-ad8fef86f624}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\CryptoTest.h">
|
||||
<Filter>Crypto\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\RSATest.h">
|
||||
<Filter>Crypto\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\CryptoTestSuite.h">
|
||||
<Filter>_Suite\Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\CryptoTest.cpp">
|
||||
<Filter>Crypto\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RSATest.cpp">
|
||||
<Filter>Crypto\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CryptoTestSuite.cpp">
|
||||
<Filter>_Suite\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\WinDriver.cpp">
|
||||
<Filter>_Driver\Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
3
Crypto/testsuite/TestSuite_x64_vs100.vcxproj.user
Normal file
3
Crypto/testsuite/TestSuite_x64_vs100.vcxproj.user
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
@ -1,156 +1,225 @@
|
||||
//
|
||||
// CryptoTest.cpp
|
||||
//
|
||||
//
|
||||
// CryptoTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/testsuite/src/CryptoTest.cpp#3 $
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "CryptoTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Crypto/CipherFactory.h"
|
||||
#include "Poco/Crypto/Cipher.h"
|
||||
#include "Poco/Crypto/CipherKey.h"
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using namespace Poco::Crypto;
|
||||
|
||||
|
||||
static const std::string APPINF_PEM(
|
||||
"-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIESzCCAzOgAwIBAgIBATALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu\n"
|
||||
"Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n\n"
|
||||
"aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh\n"
|
||||
"cmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl\n"
|
||||
"bnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu\n"
|
||||
"Y29tMB4XDTA5MDUwNzE0NTY1NloXDTI5MDUwMjE0NTY1NlowgdMxEzARBgNVBAMM\n"
|
||||
"CmFwcGluZi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdh\n"
|
||||
"cmUgRW5naW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNV\n"
|
||||
"BAgMCUNhcmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBp\n"
|
||||
"bSBSb3NlbnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0Bh\n"
|
||||
"cHBpbmYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA89GolWCR\n"
|
||||
"KtLQclJ2M2QtpFqzNC54hUQdR6n8+DAeruH9WFwLSdWW2fEi+jrtd/WEWCdt4PxX\n"
|
||||
"F2/eBYeURus7Hg2ZtJGDd3je0+Ygsv7+we4cMN/knaBY7rATqhmnZWk+yBpkf5F2\n"
|
||||
"IHp9gBxUaJWmt/bq3XrvTtzrDXpCd4zg4zPXZ8IC8ket5o3K2vnkAOsIsgN+Ffqd\n"
|
||||
"4GjF4dsblG6u6E3VarGRLwGtgB8BAZOA/33mV4FHSMkc4OXpAChaK3tM8YhrLw+m\n"
|
||||
"XtsfqDiv1825S6OWFCKGj/iX8X2QAkrdB63vXCSpb3de/ByIUfp31PpMlMh6dKo1\n"
|
||||
"vf7yj0nb2w0utQIDAQABoyowKDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAww\n"
|
||||
"CgYIKwYBBQUHAwMwDQYJKoZIhvcNAQEFBQADggEBAM0cpfb4BgiU/rkYe121P581\n"
|
||||
"ftg5Ck1PYYda1Fy/FgzbgJh2AwVo/6sn6GF79/QkEcWEgtCMNNO3LMTTddUUApuP\n"
|
||||
"jnEimyfmUhIThyud/vryzTMNa/eZMwaAqUQWqLf+AwgqjUsBSMenbSHavzJOpsvR\n"
|
||||
"LI0PQ1VvqB+3UGz0JUnBJiKvHs83Fdm4ewPAf3M5fGcIa+Fl2nU5Plzwzskj84f6\n"
|
||||
"73ZlEEi3aW9JieNy7RWsMM+1E8Sj2CGRZC4BM9V1Fgnsh4+VHX8Eu7eHucvfeIYx\n"
|
||||
"3mmLMoK4sCayL/FGhrUDw5AkWb8tKNpRXY+W60Et281yxQSeWLPIbatVzIWI0/M=\n"
|
||||
"-----END CERTIFICATE-----\n"
|
||||
);
|
||||
|
||||
|
||||
CryptoTest::CryptoTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CryptoTest::~CryptoTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::testEncryptDecrypt()
|
||||
{
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
|
||||
|
||||
std::string in("1234567890");
|
||||
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
|
||||
std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64);
|
||||
poco_assert (in == result);
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::testEncryptDecryptWithSalt()
|
||||
{
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
|
||||
|
||||
std::string in("1234567890");
|
||||
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
|
||||
|
||||
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
|
||||
|
||||
std::string result = pCipher2->decryptString(out, Cipher::ENC_BASE64);
|
||||
poco_assert (in == result);
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::testCertificate()
|
||||
{
|
||||
std::istringstream certStream(APPINF_PEM);
|
||||
X509Certificate cert(certStream);
|
||||
|
||||
std::string subjectName(cert.subjectName());
|
||||
std::string issuerName(cert.issuerName());
|
||||
std::string commonName(cert.commonName());
|
||||
std::string country(cert.subjectName(X509Certificate::NID_COUNTRY));
|
||||
std::string localityName(cert.subjectName(X509Certificate::NID_LOCALITY_NAME));
|
||||
std::string stateOrProvince(cert.subjectName(X509Certificate::NID_STATE_OR_PROVINCE));
|
||||
std::string organizationName(cert.subjectName(X509Certificate::NID_ORGANIZATION_NAME));
|
||||
std::string organizationUnitName(cert.subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME));
|
||||
|
||||
assert (subjectName == "/CN=appinf.com/O=Applied Informatics Software Engineering GmbH/OU=Development/ST=Carinthia/C=AT/L=St. Jakob im Rosental/emailAddress=guenter.obiltschnig@appinf.com");
|
||||
assert (issuerName == subjectName);
|
||||
assert (commonName == "appinf.com");
|
||||
assert (country == "AT");
|
||||
assert (localityName == "St. Jakob im Rosental");
|
||||
assert (stateOrProvince == "Carinthia");
|
||||
assert (organizationName == "Applied Informatics Software Engineering GmbH");
|
||||
assert (organizationUnitName == "Development");
|
||||
|
||||
assert (cert.issuedBy(cert));
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* CryptoTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("CryptoTest");
|
||||
|
||||
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecrypt);
|
||||
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptWithSalt);
|
||||
CppUnit_addTest(pSuite, CryptoTest, testCertificate);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "CryptoTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Crypto/CipherFactory.h"
|
||||
#include "Poco/Crypto/Cipher.h"
|
||||
#include "Poco/Crypto/CipherKey.h"
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include "Poco/Crypto/CryptoStream.h"
|
||||
#include "Poco/StreamCopier.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using namespace Poco::Crypto;
|
||||
|
||||
|
||||
static const std::string APPINF_PEM(
|
||||
"-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIESzCCAzOgAwIBAgIBATALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu\n"
|
||||
"Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n\n"
|
||||
"aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh\n"
|
||||
"cmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl\n"
|
||||
"bnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu\n"
|
||||
"Y29tMB4XDTA5MDUwNzE0NTY1NloXDTI5MDUwMjE0NTY1NlowgdMxEzARBgNVBAMM\n"
|
||||
"CmFwcGluZi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdh\n"
|
||||
"cmUgRW5naW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNV\n"
|
||||
"BAgMCUNhcmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBp\n"
|
||||
"bSBSb3NlbnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0Bh\n"
|
||||
"cHBpbmYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA89GolWCR\n"
|
||||
"KtLQclJ2M2QtpFqzNC54hUQdR6n8+DAeruH9WFwLSdWW2fEi+jrtd/WEWCdt4PxX\n"
|
||||
"F2/eBYeURus7Hg2ZtJGDd3je0+Ygsv7+we4cMN/knaBY7rATqhmnZWk+yBpkf5F2\n"
|
||||
"IHp9gBxUaJWmt/bq3XrvTtzrDXpCd4zg4zPXZ8IC8ket5o3K2vnkAOsIsgN+Ffqd\n"
|
||||
"4GjF4dsblG6u6E3VarGRLwGtgB8BAZOA/33mV4FHSMkc4OXpAChaK3tM8YhrLw+m\n"
|
||||
"XtsfqDiv1825S6OWFCKGj/iX8X2QAkrdB63vXCSpb3de/ByIUfp31PpMlMh6dKo1\n"
|
||||
"vf7yj0nb2w0utQIDAQABoyowKDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAww\n"
|
||||
"CgYIKwYBBQUHAwMwDQYJKoZIhvcNAQEFBQADggEBAM0cpfb4BgiU/rkYe121P581\n"
|
||||
"ftg5Ck1PYYda1Fy/FgzbgJh2AwVo/6sn6GF79/QkEcWEgtCMNNO3LMTTddUUApuP\n"
|
||||
"jnEimyfmUhIThyud/vryzTMNa/eZMwaAqUQWqLf+AwgqjUsBSMenbSHavzJOpsvR\n"
|
||||
"LI0PQ1VvqB+3UGz0JUnBJiKvHs83Fdm4ewPAf3M5fGcIa+Fl2nU5Plzwzskj84f6\n"
|
||||
"73ZlEEi3aW9JieNy7RWsMM+1E8Sj2CGRZC4BM9V1Fgnsh4+VHX8Eu7eHucvfeIYx\n"
|
||||
"3mmLMoK4sCayL/FGhrUDw5AkWb8tKNpRXY+W60Et281yxQSeWLPIbatVzIWI0/M=\n"
|
||||
"-----END CERTIFICATE-----\n"
|
||||
);
|
||||
|
||||
|
||||
CryptoTest::CryptoTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CryptoTest::~CryptoTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::testEncryptDecrypt()
|
||||
{
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
|
||||
|
||||
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
|
||||
{
|
||||
std::string in(n, 'x');
|
||||
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
|
||||
std::string result = pCipher->decryptString(out, Cipher::ENC_NONE);
|
||||
poco_assert (in == result);
|
||||
}
|
||||
|
||||
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
|
||||
{
|
||||
std::string in(n, 'x');
|
||||
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
|
||||
std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64);
|
||||
poco_assert (in == result);
|
||||
}
|
||||
|
||||
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
|
||||
{
|
||||
std::string in(n, 'x');
|
||||
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
|
||||
std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX);
|
||||
poco_assert (in == result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::testEncryptDecryptWithSalt()
|
||||
{
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
|
||||
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
|
||||
|
||||
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
|
||||
{
|
||||
std::string in(n, 'x');
|
||||
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
|
||||
std::string result = pCipher2->decryptString(out, Cipher::ENC_NONE);
|
||||
poco_assert (in == result);
|
||||
}
|
||||
|
||||
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
|
||||
{
|
||||
std::string in(n, 'x');
|
||||
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
|
||||
std::string result = pCipher2->decryptString(out, Cipher::ENC_BASE64);
|
||||
poco_assert (in == result);
|
||||
}
|
||||
|
||||
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
|
||||
{
|
||||
std::string in(n, 'x');
|
||||
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
|
||||
std::string result = pCipher2->decryptString(out, Cipher::ENC_BINHEX);
|
||||
poco_assert (in == result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::testStreams()
|
||||
{
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
|
||||
|
||||
static const std::string SECRET_MESSAGE = "This is a secret message. Don't tell anyone.";
|
||||
|
||||
std::stringstream sstr;
|
||||
EncryptingOutputStream encryptor(sstr, *pCipher);
|
||||
encryptor << SECRET_MESSAGE;
|
||||
encryptor.close();
|
||||
|
||||
DecryptingInputStream decryptor(sstr, *pCipher);
|
||||
std::string result;
|
||||
Poco::StreamCopier::copyToString(decryptor, result);
|
||||
|
||||
assert (result == SECRET_MESSAGE);
|
||||
assert (decryptor.eof());
|
||||
assert (!decryptor.bad());
|
||||
|
||||
|
||||
std::istringstream emptyStream;
|
||||
DecryptingInputStream badDecryptor(emptyStream, *pCipher);
|
||||
Poco::StreamCopier::copyToString(badDecryptor, result);
|
||||
|
||||
assert (badDecryptor.fail());
|
||||
assert (badDecryptor.bad());
|
||||
assert (!badDecryptor.eof());
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::testCertificate()
|
||||
{
|
||||
std::istringstream certStream(APPINF_PEM);
|
||||
X509Certificate cert(certStream);
|
||||
|
||||
std::string subjectName(cert.subjectName());
|
||||
std::string issuerName(cert.issuerName());
|
||||
std::string commonName(cert.commonName());
|
||||
std::string country(cert.subjectName(X509Certificate::NID_COUNTRY));
|
||||
std::string localityName(cert.subjectName(X509Certificate::NID_LOCALITY_NAME));
|
||||
std::string stateOrProvince(cert.subjectName(X509Certificate::NID_STATE_OR_PROVINCE));
|
||||
std::string organizationName(cert.subjectName(X509Certificate::NID_ORGANIZATION_NAME));
|
||||
std::string organizationUnitName(cert.subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME));
|
||||
|
||||
assert (subjectName == "/CN=appinf.com/O=Applied Informatics Software Engineering GmbH/OU=Development/ST=Carinthia/C=AT/L=St. Jakob im Rosental/emailAddress=guenter.obiltschnig@appinf.com");
|
||||
assert (issuerName == subjectName);
|
||||
assert (commonName == "appinf.com");
|
||||
assert (country == "AT");
|
||||
assert (localityName == "St. Jakob im Rosental");
|
||||
assert (stateOrProvince == "Carinthia");
|
||||
assert (organizationName == "Applied Informatics Software Engineering GmbH");
|
||||
assert (organizationUnitName == "Development");
|
||||
|
||||
assert (cert.issuedBy(cert));
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CryptoTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* CryptoTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("CryptoTest");
|
||||
|
||||
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecrypt);
|
||||
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptWithSalt);
|
||||
CppUnit_addTest(pSuite, CryptoTest, testStreams);
|
||||
CppUnit_addTest(pSuite, CryptoTest, testCertificate);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -1,62 +1,68 @@
|
||||
//
|
||||
// CryptoTest.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/testsuite/src/CryptoTest.h#2 $
|
||||
//
|
||||
// Definition of the CryptoTest class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef CryptoTest_INCLUDED
|
||||
#define CryptoTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class CryptoTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
CryptoTest(const std::string& name);
|
||||
~CryptoTest();
|
||||
|
||||
void testEncryptDecrypt();
|
||||
void testEncryptDecryptWithSalt();
|
||||
void testCertificate();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // CryptoTest_INCLUDED
|
||||
//
|
||||
// CryptoTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/testsuite/src/CryptoTest.h#2 $
|
||||
//
|
||||
// Definition of the CryptoTest class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef CryptoTest_INCLUDED
|
||||
#define CryptoTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class CryptoTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
MAX_DATA_SIZE = 10000
|
||||
};
|
||||
|
||||
CryptoTest(const std::string& name);
|
||||
~CryptoTest();
|
||||
|
||||
void testEncryptDecrypt();
|
||||
void testEncryptDecryptWithSalt();
|
||||
void testStreams();
|
||||
void testCertificate();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // CryptoTest_INCLUDED
|
||||
|
@ -1,39 +1,65 @@
|
||||
//
|
||||
// Driver.cpp
|
||||
//
|
||||
//
|
||||
// Driver.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/testsuite/src/Driver.cpp#1 $
|
||||
//
|
||||
// Console-based test driver for Poco Crypto.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include "CryptoTestSuite.h"
|
||||
|
||||
|
||||
CppUnitMain(CryptoTestSuite)
|
||||
//
|
||||
// Console-based test driver for Poco Crypto.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include "CryptoTestSuite.h"
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
|
||||
|
||||
class CryptoInitializer
|
||||
{
|
||||
public:
|
||||
CryptoInitializer()
|
||||
{
|
||||
Poco::Crypto::initializeCrypto();
|
||||
}
|
||||
|
||||
~CryptoInitializer()
|
||||
{
|
||||
Poco::Crypto::uninitializeCrypto();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
CryptoInitializer ci;
|
||||
|
||||
std::vector<std::string> args;
|
||||
for (int i = 0; i < ac; ++i)
|
||||
args.push_back(std::string(av[i]));
|
||||
CppUnit::TestRunner runner;
|
||||
runner.addTest("CryptoTestSuite", CryptoTestSuite::suite());
|
||||
return runner.run(args) ? 0 : 1;
|
||||
}
|
||||
|
@ -1,229 +1,253 @@
|
||||
//
|
||||
// RSATest.cpp
|
||||
//
|
||||
//
|
||||
// RSATest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/testsuite/src/RSATest.cpp#5 $
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "RSATest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Crypto/RSADigestEngine.h"
|
||||
#include "Poco/Crypto/CipherFactory.h"
|
||||
#include "Poco/Crypto/Cipher.h"
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using namespace Poco::Crypto;
|
||||
|
||||
|
||||
static const std::string anyPem(
|
||||
"-----BEGIN CERTIFICATE-----\r\n"
|
||||
"MIICaDCCAdECCQCzfxSsk7yaLjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
|
||||
"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
|
||||
"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
|
||||
"aW5mLmNvbTAeFw0wNjAzMDExMzA3MzFaFw0wNjAzMzExMzA3MzFaMH4xCzAJBgNV\r\n"
|
||||
"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExETAPBgNVBAcTCFN0IEpha29iMRww\r\n"
|
||||
"GgYDVQQKExNBcHBsaWVkIEluZm9ybWF0aWNzMQowCAYDVQQDFAEqMR4wHAYJKoZI\r\n"
|
||||
"hvcNAQkBFg9pbmZvQGFwcGluZi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ\r\n"
|
||||
"AoGBAJHGyXDHyCYoWz+65ltNwwZbhwOGnxr9P1WMATuFJh0bPBZxKbZRdbTm9KhZ\r\n"
|
||||
"OlvsEIsfgiYdsxURYIqXfEgISYLZcZY0pQwGEOmB+0NeC/+ENSfOlNSthx6zSVlc\r\n"
|
||||
"zhJ7+dJOGwepHAiLr1fRuc5jogYLraE+lKTnqAAFfzwvti77AgMBAAEwDQYJKoZI\r\n"
|
||||
"hvcNAQEFBQADgYEAY/ZoeY1ukkEJX7259NeoVM0oahlulWV0rlCqyaeosOiDORPT\r\n"
|
||||
"m6X1w/5MTCf9VyaD1zukoSZ4QqNVjHFXcXidbB7Tgt3yRuZ5PC5LIFCDPv9mgPne\r\n"
|
||||
"mUA70yfctNfza2z3ZiQ6NDkW3mZX+1tmxYIrJQIrkVeYeqf1Gh2nyZrUMcE=\r\n"
|
||||
"-----END CERTIFICATE-----\r\n"
|
||||
"-----BEGIN RSA PRIVATE KEY-----\r\n"
|
||||
"Proc-Type: 4,ENCRYPTED\r\n"
|
||||
"DEK-Info: DES-EDE3-CBC,E7AE93C9E49184EA\r\n"
|
||||
"\r\n"
|
||||
"A2IqzNcWs+I5vzV+i+woDk56+yr58eU0Onw8eEvXkLjnSc58JU4327IF7yUbKWdW\r\n"
|
||||
"Q7BYGGOkVFiZ7ANOwviDg5SUhxRDWCcW8dS6/p1vfdQ1C3qj2OwJjkpg0aDBIzJn\r\n"
|
||||
"FzgguT3MF3ama77vxv0S3kOfmCj62MLqPGpj5pQ0/1hefRFbL8oAX8bXUN7/rmGM\r\n"
|
||||
"Zc0QyzFZv2iQ04dY/6TNclwKPB4H0On4K+8BMs3PRkWA0clCaQaFO2+iwnk3XZfe\r\n"
|
||||
"+MsKUEbLCpAQeYspYv1cw38dCdWq1KTP5aJk+oXgwjfX5cAaPTz74NTqTIsCcaTD\r\n"
|
||||
"3vy7ukJYFlDR9Kyo7z8rMazYrKJslhnuRH0BhK9st9McwL957j5tZmrKyraCcmCx\r\n"
|
||||
"dMAGcsis1va3ayYZpIpFqA4EhYrTM+6N8ZRfUap20+b5IQwHfTQDejUhL6rBwy7j\r\n"
|
||||
"Ti5yD83/itoOMyXq2sV/XWfVD5zk/P5iv22O1EAQMhhnPB9K/I/JhuSGQJfn3cNh\r\n"
|
||||
"ykOUYT0+vDeSeEVa+FVEP1W35G0alTbKbNs5Tb8KxJ3iDJUxokM//SvPXZy9hOVX\r\n"
|
||||
"Y05imB04J15DaGbAHlNzunhuJi7121WV/JRXZRW9diE6hwpD8rwqi3FMuRUmy7U9\r\n"
|
||||
"aFA5poKRAYlo9YtZ3YpFyjGKB6MfCQcB2opuSnQ/gbugV41m67uQ4CDwWLaNRkTb\r\n"
|
||||
"GlsMBNcHnidg15Bsat5HaB7l250ukrI13Uw1MYdDUzaS3gPfw9aC4F2w0p3U+DPH\r\n"
|
||||
"80/zePxtroR7T4/+rI136Rl+aMXDMOEGCX1TVP8rjuZzuRyUSUKC8Q==\r\n"
|
||||
"-----END RSA PRIVATE KEY-----\r\n"
|
||||
"-----BEGIN CERTIFICATE-----\r\n"
|
||||
"MIICXTCCAcYCCQC1Vk/N8qR4AjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
|
||||
"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
|
||||
"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
|
||||
"aW5mLmNvbTAeFw0wNjAyMjcxMzI3MThaFw0wNjAzMjkxMzI3MThaMHMxCzAJBgNV\r\n"
|
||||
"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExEjAQBgNVBAcTCVN0LiBKYWtvYjEP\r\n"
|
||||
"MA0GA1UEChMGQXBwSW5mMQ8wDQYDVQQDEwZBcHBJbmYxGjAYBgkqhkiG9w0BCQEW\r\n"
|
||||
"C2FwcEBpbmYuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsFXiPuicN\r\n"
|
||||
"Im4oJwF8NuaFN+lgYwcZ6dAO3ILIR3kLA2PxF8HSQLfF8J8a4odZhLhctIMAKTxm\r\n"
|
||||
"k0w8TW5qhL8QLdGzY9vzvkgdKOkan2t3sMeXJAfrM1AphTsmgntAQazGZjOj5p4W\r\n"
|
||||
"jDnxQ+VXAylqwjHh49eSBxM3wgoscF4iLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GB\r\n"
|
||||
"AIpfLdXiKchPvFMhQS8xTtXvrw5dVL3yImUMYs4GQi8RrjGmfGB3yMAR7B/b8v4a\r\n"
|
||||
"+ztfusgWAWiUKuSGTk4S8YB0fsFlmOv0WDr+PyZ4Lui/a8opbyzGE7rqpnF/s0GO\r\n"
|
||||
"M7uLCNNwIN7WhmxcWV0KZU1wTppoSWPJda1yTbBzF9XP\r\n"
|
||||
"-----END CERTIFICATE-----\r\n"
|
||||
);
|
||||
|
||||
|
||||
RSATest::RSATest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSATest::~RSATest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testNewKeys()
|
||||
{
|
||||
RSAKey key(RSAKey::KL_1024, RSAKey::EXP_SMALL);
|
||||
std::ostringstream strPub;
|
||||
std::ostringstream strPriv;
|
||||
key.save(&strPub, &strPriv, "testpwd");
|
||||
std::string pubKey = strPub.str();
|
||||
std::string privKey = strPriv.str();
|
||||
|
||||
// now do the round trip
|
||||
std::istringstream iPub(pubKey);
|
||||
std::istringstream iPriv(privKey);
|
||||
RSAKey key2(&iPub, &iPriv, "testpwd");
|
||||
|
||||
std::istringstream iPriv2(privKey);
|
||||
RSAKey key3(0, &iPriv2, "testpwd");
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
std::string pubFromPrivate = strPub3.str();
|
||||
assert (pubFromPrivate == pubKey);
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testSign()
|
||||
{
|
||||
std::string msg("Test this sign message");
|
||||
RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE);
|
||||
RSADigestEngine eng(key);
|
||||
eng.update(msg.c_str(), msg.length());
|
||||
const Poco::DigestEngine::Digest& sig = eng.signature();
|
||||
std::string hexDig = Poco::DigestEngine::digestToHex(sig);
|
||||
|
||||
// verify
|
||||
std::ostringstream strPub;
|
||||
key.save(&strPub);
|
||||
std::string pubKey = strPub.str();
|
||||
std::istringstream iPub(pubKey);
|
||||
RSAKey keyPub(&iPub);
|
||||
RSADigestEngine eng2(key);
|
||||
eng2.update(msg.c_str(), msg.length());
|
||||
assert (eng2.verify(sig));
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testSignManipulated()
|
||||
{
|
||||
std::string msg("Test this sign message");
|
||||
std::string msgManip("Test that sign message");
|
||||
RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE);
|
||||
RSADigestEngine eng(key);
|
||||
eng.update(msg.c_str(), msg.length());
|
||||
const Poco::DigestEngine::Digest& sig = eng.signature();
|
||||
std::string hexDig = Poco::DigestEngine::digestToHex(sig);
|
||||
|
||||
// verify
|
||||
std::ostringstream strPub;
|
||||
key.save(&strPub);
|
||||
std::string pubKey = strPub.str();
|
||||
std::istringstream iPub(pubKey);
|
||||
RSAKey keyPub(&iPub);
|
||||
RSADigestEngine eng2(key);
|
||||
eng2.update(msgManip.c_str(), msgManip.length());
|
||||
assert (!eng2.verify(sig));
|
||||
}
|
||||
|
||||
|
||||
void RSATest::createRSACipher()
|
||||
{
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024,RSAKey::EXP_SMALL));
|
||||
std::string val("lets do some encryption");
|
||||
std::string enc = pCipher->encryptString(val);
|
||||
std::string dec = pCipher->decryptString(enc);
|
||||
assert (dec == val);
|
||||
}
|
||||
|
||||
|
||||
void RSATest::createRSACipherLarge()
|
||||
{
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024,RSAKey::EXP_SMALL));
|
||||
std::string val(16385, 'x');
|
||||
std::string enc = pCipher->encryptString(val);
|
||||
std::string dec = pCipher->decryptString(enc);
|
||||
assert (dec == val);
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testCertificate()
|
||||
{
|
||||
std::istringstream str(anyPem);
|
||||
X509Certificate cert(str);
|
||||
|
||||
RSAKey key(cert);
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(key);
|
||||
std::string val("lets do some encryption");
|
||||
|
||||
std::string enc = pCipher->encryptString(val);
|
||||
}
|
||||
|
||||
|
||||
void RSATest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RSATest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* RSATest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("RSATest");
|
||||
|
||||
CppUnit_addTest(pSuite, RSATest, testNewKeys);
|
||||
CppUnit_addTest(pSuite, RSATest, testSign);
|
||||
CppUnit_addTest(pSuite, RSATest, testSignManipulated);
|
||||
CppUnit_addTest(pSuite, RSATest, createRSACipher);
|
||||
CppUnit_addTest(pSuite, RSATest, createRSACipherLarge);
|
||||
CppUnit_addTest(pSuite, RSATest, testCertificate);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "RSATest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Crypto/RSADigestEngine.h"
|
||||
#include "Poco/Crypto/CipherFactory.h"
|
||||
#include "Poco/Crypto/Cipher.h"
|
||||
#include "Poco/Crypto/X509Certificate.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
using namespace Poco::Crypto;
|
||||
|
||||
|
||||
static const std::string anyPem(
|
||||
"-----BEGIN CERTIFICATE-----\r\n"
|
||||
"MIICaDCCAdECCQCzfxSsk7yaLjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
|
||||
"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
|
||||
"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
|
||||
"aW5mLmNvbTAeFw0wNjAzMDExMzA3MzFaFw0wNjAzMzExMzA3MzFaMH4xCzAJBgNV\r\n"
|
||||
"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExETAPBgNVBAcTCFN0IEpha29iMRww\r\n"
|
||||
"GgYDVQQKExNBcHBsaWVkIEluZm9ybWF0aWNzMQowCAYDVQQDFAEqMR4wHAYJKoZI\r\n"
|
||||
"hvcNAQkBFg9pbmZvQGFwcGluZi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ\r\n"
|
||||
"AoGBAJHGyXDHyCYoWz+65ltNwwZbhwOGnxr9P1WMATuFJh0bPBZxKbZRdbTm9KhZ\r\n"
|
||||
"OlvsEIsfgiYdsxURYIqXfEgISYLZcZY0pQwGEOmB+0NeC/+ENSfOlNSthx6zSVlc\r\n"
|
||||
"zhJ7+dJOGwepHAiLr1fRuc5jogYLraE+lKTnqAAFfzwvti77AgMBAAEwDQYJKoZI\r\n"
|
||||
"hvcNAQEFBQADgYEAY/ZoeY1ukkEJX7259NeoVM0oahlulWV0rlCqyaeosOiDORPT\r\n"
|
||||
"m6X1w/5MTCf9VyaD1zukoSZ4QqNVjHFXcXidbB7Tgt3yRuZ5PC5LIFCDPv9mgPne\r\n"
|
||||
"mUA70yfctNfza2z3ZiQ6NDkW3mZX+1tmxYIrJQIrkVeYeqf1Gh2nyZrUMcE=\r\n"
|
||||
"-----END CERTIFICATE-----\r\n"
|
||||
"-----BEGIN RSA PRIVATE KEY-----\r\n"
|
||||
"Proc-Type: 4,ENCRYPTED\r\n"
|
||||
"DEK-Info: DES-EDE3-CBC,E7AE93C9E49184EA\r\n"
|
||||
"\r\n"
|
||||
"A2IqzNcWs+I5vzV+i+woDk56+yr58eU0Onw8eEvXkLjnSc58JU4327IF7yUbKWdW\r\n"
|
||||
"Q7BYGGOkVFiZ7ANOwviDg5SUhxRDWCcW8dS6/p1vfdQ1C3qj2OwJjkpg0aDBIzJn\r\n"
|
||||
"FzgguT3MF3ama77vxv0S3kOfmCj62MLqPGpj5pQ0/1hefRFbL8oAX8bXUN7/rmGM\r\n"
|
||||
"Zc0QyzFZv2iQ04dY/6TNclwKPB4H0On4K+8BMs3PRkWA0clCaQaFO2+iwnk3XZfe\r\n"
|
||||
"+MsKUEbLCpAQeYspYv1cw38dCdWq1KTP5aJk+oXgwjfX5cAaPTz74NTqTIsCcaTD\r\n"
|
||||
"3vy7ukJYFlDR9Kyo7z8rMazYrKJslhnuRH0BhK9st9McwL957j5tZmrKyraCcmCx\r\n"
|
||||
"dMAGcsis1va3ayYZpIpFqA4EhYrTM+6N8ZRfUap20+b5IQwHfTQDejUhL6rBwy7j\r\n"
|
||||
"Ti5yD83/itoOMyXq2sV/XWfVD5zk/P5iv22O1EAQMhhnPB9K/I/JhuSGQJfn3cNh\r\n"
|
||||
"ykOUYT0+vDeSeEVa+FVEP1W35G0alTbKbNs5Tb8KxJ3iDJUxokM//SvPXZy9hOVX\r\n"
|
||||
"Y05imB04J15DaGbAHlNzunhuJi7121WV/JRXZRW9diE6hwpD8rwqi3FMuRUmy7U9\r\n"
|
||||
"aFA5poKRAYlo9YtZ3YpFyjGKB6MfCQcB2opuSnQ/gbugV41m67uQ4CDwWLaNRkTb\r\n"
|
||||
"GlsMBNcHnidg15Bsat5HaB7l250ukrI13Uw1MYdDUzaS3gPfw9aC4F2w0p3U+DPH\r\n"
|
||||
"80/zePxtroR7T4/+rI136Rl+aMXDMOEGCX1TVP8rjuZzuRyUSUKC8Q==\r\n"
|
||||
"-----END RSA PRIVATE KEY-----\r\n"
|
||||
"-----BEGIN CERTIFICATE-----\r\n"
|
||||
"MIICXTCCAcYCCQC1Vk/N8qR4AjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
|
||||
"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
|
||||
"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
|
||||
"aW5mLmNvbTAeFw0wNjAyMjcxMzI3MThaFw0wNjAzMjkxMzI3MThaMHMxCzAJBgNV\r\n"
|
||||
"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExEjAQBgNVBAcTCVN0LiBKYWtvYjEP\r\n"
|
||||
"MA0GA1UEChMGQXBwSW5mMQ8wDQYDVQQDEwZBcHBJbmYxGjAYBgkqhkiG9w0BCQEW\r\n"
|
||||
"C2FwcEBpbmYuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsFXiPuicN\r\n"
|
||||
"Im4oJwF8NuaFN+lgYwcZ6dAO3ILIR3kLA2PxF8HSQLfF8J8a4odZhLhctIMAKTxm\r\n"
|
||||
"k0w8TW5qhL8QLdGzY9vzvkgdKOkan2t3sMeXJAfrM1AphTsmgntAQazGZjOj5p4W\r\n"
|
||||
"jDnxQ+VXAylqwjHh49eSBxM3wgoscF4iLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GB\r\n"
|
||||
"AIpfLdXiKchPvFMhQS8xTtXvrw5dVL3yImUMYs4GQi8RrjGmfGB3yMAR7B/b8v4a\r\n"
|
||||
"+ztfusgWAWiUKuSGTk4S8YB0fsFlmOv0WDr+PyZ4Lui/a8opbyzGE7rqpnF/s0GO\r\n"
|
||||
"M7uLCNNwIN7WhmxcWV0KZU1wTppoSWPJda1yTbBzF9XP\r\n"
|
||||
"-----END CERTIFICATE-----\r\n"
|
||||
);
|
||||
|
||||
|
||||
RSATest::RSATest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RSATest::~RSATest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testNewKeys()
|
||||
{
|
||||
RSAKey key(RSAKey::KL_1024, RSAKey::EXP_SMALL);
|
||||
std::ostringstream strPub;
|
||||
std::ostringstream strPriv;
|
||||
key.save(&strPub, &strPriv, "testpwd");
|
||||
std::string pubKey = strPub.str();
|
||||
std::string privKey = strPriv.str();
|
||||
|
||||
// now do the round trip
|
||||
std::istringstream iPub(pubKey);
|
||||
std::istringstream iPriv(privKey);
|
||||
RSAKey key2(&iPub, &iPriv, "testpwd");
|
||||
|
||||
std::istringstream iPriv2(privKey);
|
||||
RSAKey key3(0, &iPriv2, "testpwd");
|
||||
std::ostringstream strPub3;
|
||||
key3.save(&strPub3);
|
||||
std::string pubFromPrivate = strPub3.str();
|
||||
assert (pubFromPrivate == pubKey);
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testSign()
|
||||
{
|
||||
std::string msg("Test this sign message");
|
||||
RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE);
|
||||
RSADigestEngine eng(key);
|
||||
eng.update(msg.c_str(), static_cast<unsigned>(msg.length()));
|
||||
const Poco::DigestEngine::Digest& sig = eng.signature();
|
||||
std::string hexDig = Poco::DigestEngine::digestToHex(sig);
|
||||
|
||||
// verify
|
||||
std::ostringstream strPub;
|
||||
key.save(&strPub);
|
||||
std::string pubKey = strPub.str();
|
||||
std::istringstream iPub(pubKey);
|
||||
RSAKey keyPub(&iPub);
|
||||
RSADigestEngine eng2(key);
|
||||
eng2.update(msg.c_str(), static_cast<unsigned>(msg.length()));
|
||||
assert (eng2.verify(sig));
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testSignManipulated()
|
||||
{
|
||||
std::string msg("Test this sign message");
|
||||
std::string msgManip("Test that sign message");
|
||||
RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE);
|
||||
RSADigestEngine eng(key);
|
||||
eng.update(msg.c_str(), static_cast<unsigned>(msg.length()));
|
||||
const Poco::DigestEngine::Digest& sig = eng.signature();
|
||||
std::string hexDig = Poco::DigestEngine::digestToHex(sig);
|
||||
|
||||
// verify
|
||||
std::ostringstream strPub;
|
||||
key.save(&strPub);
|
||||
std::string pubKey = strPub.str();
|
||||
std::istringstream iPub(pubKey);
|
||||
RSAKey keyPub(&iPub);
|
||||
RSADigestEngine eng2(key);
|
||||
eng2.update(msgManip.c_str(), static_cast<unsigned>(msgManip.length()));
|
||||
assert (!eng2.verify(sig));
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testRSACipher()
|
||||
{
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
|
||||
for (std::size_t n = 1; n <= 1200; n++)
|
||||
{
|
||||
std::string val(n, 'x');
|
||||
std::string enc = pCipher->encryptString(val);
|
||||
std::string dec = pCipher->decryptString(enc);
|
||||
assert (dec == val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testRSACipherLarge()
|
||||
{
|
||||
std::vector<std::size_t> sizes;
|
||||
sizes.push_back (2047);
|
||||
sizes.push_back (2048);
|
||||
sizes.push_back (2049);
|
||||
sizes.push_back (4095);
|
||||
sizes.push_back (4096);
|
||||
sizes.push_back (4097);
|
||||
sizes.push_back (8191);
|
||||
sizes.push_back (8192);
|
||||
sizes.push_back (8193);
|
||||
sizes.push_back (16383);
|
||||
sizes.push_back (16384);
|
||||
sizes.push_back (16385);
|
||||
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
|
||||
for (std::vector<std::size_t>::const_iterator it = sizes.begin(); it != sizes.end(); ++it)
|
||||
{
|
||||
std::string val(*it, 'x');
|
||||
std::string enc = pCipher->encryptString(val);
|
||||
std::string dec = pCipher->decryptString(enc);
|
||||
assert (dec == val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RSATest::testCertificate()
|
||||
{
|
||||
std::istringstream str(anyPem);
|
||||
X509Certificate cert(str);
|
||||
RSAKey publicKey(cert);
|
||||
std::istringstream str2(anyPem);
|
||||
RSAKey privateKey(0, &str2, "test");
|
||||
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey);
|
||||
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey);
|
||||
std::string val("lets do some encryption");
|
||||
|
||||
std::string enc = pCipher->encryptString(val);
|
||||
std::string dec = pCipher2->decryptString(enc);
|
||||
assert (dec == val);
|
||||
}
|
||||
|
||||
|
||||
void RSATest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RSATest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* RSATest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("RSATest");
|
||||
|
||||
CppUnit_addTest(pSuite, RSATest, testNewKeys);
|
||||
CppUnit_addTest(pSuite, RSATest, testSign);
|
||||
CppUnit_addTest(pSuite, RSATest, testSignManipulated);
|
||||
CppUnit_addTest(pSuite, RSATest, testRSACipher);
|
||||
CppUnit_addTest(pSuite, RSATest, testRSACipherLarge);
|
||||
CppUnit_addTest(pSuite, RSATest, testCertificate);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -1,65 +1,65 @@
|
||||
//
|
||||
// RSATest.h
|
||||
//
|
||||
//
|
||||
// RSATest.h
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/testsuite/src/RSATest.h#3 $
|
||||
//
|
||||
// Definition of the RSATest class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef RSATest_INCLUDED
|
||||
#define RSATest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class RSATest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
RSATest(const std::string& name);
|
||||
~RSATest();
|
||||
|
||||
void testNewKeys();
|
||||
void testSign();
|
||||
void testSignManipulated();
|
||||
void createRSACipher();
|
||||
void createRSACipherLarge();
|
||||
void testCertificate();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // RSATest_INCLUDED
|
||||
//
|
||||
// Definition of the RSATest class.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef RSATest_INCLUDED
|
||||
#define RSATest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class RSATest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
RSATest(const std::string& name);
|
||||
~RSATest();
|
||||
|
||||
void testNewKeys();
|
||||
void testSign();
|
||||
void testSignManipulated();
|
||||
void testRSACipher();
|
||||
void testRSACipherLarge();
|
||||
void testCertificate();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // RSATest_INCLUDED
|
||||
|
70
Crypto/testsuite/src/WinCEDriver.cpp
Normal file
70
Crypto/testsuite/src/WinCEDriver.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// WinCEDriver.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/Crypto/testsuite/src/WinCEDriver.cpp#1 $
|
||||
//
|
||||
// Console-based test driver for Windows CE.
|
||||
//
|
||||
// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include "CryptoTestSuite.h"
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
class CryptoInitializer
|
||||
{
|
||||
public:
|
||||
CryptoInitializer()
|
||||
{
|
||||
Poco::Crypto::initializeCrypto();
|
||||
}
|
||||
|
||||
~CryptoInitializer()
|
||||
{
|
||||
Poco::Crypto::uninitializeCrypto();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int _tmain(int argc, wchar_t* argv[])
|
||||
{
|
||||
CryptoInitializer ci;
|
||||
|
||||
std::vector<std::string> args;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
char buffer[1024];
|
||||
std::wcstombs(buffer, argv[i], sizeof(buffer));
|
||||
args.push_back(std::string(buffer));
|
||||
}
|
||||
CppUnit::TestRunner runner;
|
||||
runner.addTest("CryptoTestSuite", CryptoTestSuite::suite());
|
||||
return runner.run(args) ? 0 : 1;
|
||||
}
|
@ -1,50 +1,68 @@
|
||||
//
|
||||
// WinDriver.cpp
|
||||
//
|
||||
//
|
||||
// WinDriver.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Crypto/testsuite/src/WinDriver.cpp#1 $
|
||||
//
|
||||
// Windows test driver for Poco Crypto.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "WinTestRunner/WinTestRunner.h"
|
||||
#include "CryptoTestSuite.h"
|
||||
|
||||
|
||||
class TestDriver: public CppUnit::WinTestRunnerApp
|
||||
{
|
||||
void TestMain()
|
||||
{
|
||||
CppUnit::WinTestRunner runner;
|
||||
runner.addTest(CryptoTestSuite::suite());
|
||||
runner.run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TestDriver theDriver;
|
||||
//
|
||||
// Windows test driver for Poco Crypto.
|
||||
//
|
||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "WinTestRunner/WinTestRunner.h"
|
||||
#include "CryptoTestSuite.h"
|
||||
#include "Poco/Crypto/Crypto.h"
|
||||
|
||||
|
||||
class CryptoInitializer
|
||||
{
|
||||
public:
|
||||
CryptoInitializer()
|
||||
{
|
||||
Poco::Crypto::initializeCrypto();
|
||||
}
|
||||
|
||||
~CryptoInitializer()
|
||||
{
|
||||
Poco::Crypto::uninitializeCrypto();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TestDriver: public CppUnit::WinTestRunnerApp
|
||||
{
|
||||
void TestMain()
|
||||
{
|
||||
CryptoInitializer ci;
|
||||
|
||||
CppUnit::WinTestRunner runner;
|
||||
runner.addTest(CryptoTestSuite::suite());
|
||||
runner.run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TestDriver theDriver;
|
||||
|
Loading…
x
Reference in New Issue
Block a user