Crypto: complete merge to 1.4.2

This commit is contained in:
Marian Krivos
2011-09-14 16:41:40 +00:00
parent e0c42bb6f4
commit bcf1d5b6a7
56 changed files with 6736 additions and 3766 deletions

60
Crypto/Crypto_vs100.sln Normal file
View 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
View 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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">..\bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">..\bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">..\lib\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">..\lib\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">..\lib\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">..\lib\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">PocoCryptod</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">PocoCryptomdd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">PocoCryptomtd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">PocoCrypto</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">PocoCryptomd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">PocoCryptomt</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">
<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>

View 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>

View 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>

View 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

View 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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">..\bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">..\bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">..\lib64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">..\lib64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">..\lib64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">..\lib64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">PocoCrypto64d</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">PocoCryptomdd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">PocoCryptomtd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">PocoCrypto64</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">PocoCryptomd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">PocoCryptomt</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">
<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>

View 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>

View 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>

View File

@@ -112,9 +112,12 @@ public:
enum Encoding enum Encoding
/// Transport encoding to use for encryptString() and decryptString(). /// Transport encoding to use for encryptString() and decryptString().
{ {
ENC_NONE, /// Plain binary output ENC_NONE = 0x00, /// Plain binary output
ENC_BASE64, /// Base64-encoded output ENC_BASE64 = 0x01, /// Base64-encoded output
ENC_BINHEX /// BinHex-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(); virtual ~Cipher();

View File

@@ -86,8 +86,6 @@ public:
/// Returns the default CipherFactory. /// Returns the default CipherFactory.
private: private:
static int _instanceCount;
CipherFactory(const CipherFactory&); CipherFactory(const CipherFactory&);
CipherFactory& operator = (const CipherFactory&); CipherFactory& operator = (const CipherFactory&);
}; };

View File

@@ -1,90 +1,91 @@
// //
// CipherImpl.h // CipherImpl.h
// //
// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherImpl.h#3 $ // $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherImpl.h#1 $
// //
// Library: Crypto // Library: Crypto
// Package: Cipher // Package: Cipher
// Module: CipherImpl // Module: CipherImpl
// //
// Definition of the CipherImpl class. // Definition of the CipherImpl class.
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef Crypto_CipherImpl_INCLUDED #ifndef Crypto_CipherImpl_INCLUDED
#define Crypto_CipherImpl_INCLUDED #define Crypto_CipherImpl_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "Poco/Crypto/Cipher.h" #include "Poco/Crypto/Cipher.h"
#include "Poco/Crypto/CipherKey.h" #include "Poco/Crypto/CipherKey.h"
#include "Poco/Crypto/OpenSSLInitializer.h"
#include <openssl/evp.h> #include <openssl/evp.h>
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
class CipherImpl: public Cipher class CipherImpl: public Cipher
/// An implementation of the Cipher class for OpenSSL's crypto library. /// An implementation of the Cipher class for OpenSSL's crypto library.
{ {
public: public:
CipherImpl(const CipherKey& key); CipherImpl(const CipherKey& key);
/// Creates a new CipherImpl object for the given CipherKey. /// Creates a new CipherImpl object for the given CipherKey.
virtual ~CipherImpl(); virtual ~CipherImpl();
/// Destroys the CipherImpl. /// Destroys the CipherImpl.
const std::string& name() const; const std::string& name() const;
/// Returns the name of the cipher. /// Returns the name of the cipher.
CryptoTransform* createEncryptor(); CryptoTransform* createEncryptor();
/// Creates an encrytor object. /// Creates an encrytor object.
CryptoTransform* createDecryptor(); CryptoTransform* createDecryptor();
/// Creates a decrytor object. /// Creates a decrytor object.
private: private:
CipherKey _key; CipherKey _key;
}; OpenSSLInitializer _openSSLInitializer;
};
//
// Inlines //
// // Inlines
inline const std::string& CipherImpl::name() const //
{ inline const std::string& CipherImpl::name() const
return _key.name(); {
} return _key.name();
}
} } // namespace Poco::Crypto
} } // namespace Poco::Crypto
#endif // Crypto_CipherImpl_INCLUDED
#endif // Crypto_CipherImpl_INCLUDED

View File

@@ -1,204 +1,204 @@
// //
// CipherKey.h // CipherKey.h
// //
// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherKey.h#2 $ // $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherKey.h#1 $
// //
// Library: Crypto // Library: Crypto
// Package: Cipher // Package: Cipher
// Module: CipherKey // Module: CipherKey
// //
// Definition of the CipherKey class. // Definition of the CipherKey class.
// //
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. // Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef Crypto_CipherKey_INCLUDED #ifndef Crypto_CipherKey_INCLUDED
#define Crypto_CipherKey_INCLUDED #define Crypto_CipherKey_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "Poco/Crypto/CipherKeyImpl.h" #include "Poco/Crypto/CipherKeyImpl.h"
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
class Crypto_API CipherKey class Crypto_API CipherKey
/// CipherKey stores the key information for decryption/encryption of data. /// CipherKey stores the key information for decryption/encryption of data.
/// To create a random key, using the following code: /// To create a random key, using the following code:
/// ///
/// CipherKey key("aes-256"); /// CipherKey key("aes-256");
/// ///
/// Note that you won't be able to decrypt data encrypted with a random key /// 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. /// 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 /// An example usage for random keys is to encrypt data saved in a temporary
/// file. /// file.
/// ///
/// To create a key using a human-readable password /// To create a key using a human-readable password
/// string, use the following code. We create a AES Cipher and /// string, use the following code. We create a AES Cipher and
/// use a salt value to make the key more robust: /// use a salt value to make the key more robust:
/// ///
/// std::string password = "secret"; /// std::string password = "secret";
/// std::string salt("asdff8723lasdf(**923412"); /// std::string salt("asdff8723lasdf(**923412");
/// CipherKey key("aes-256", password, salt); /// CipherKey key("aes-256", password, salt);
/// ///
{ {
public: public:
typedef CipherKeyImpl::Mode Mode; typedef CipherKeyImpl::Mode Mode;
typedef CipherKeyImpl::ByteVec ByteVec; typedef CipherKeyImpl::ByteVec ByteVec;
enum enum
{ {
DEFAULT_ITERATION_COUNT = 2000 DEFAULT_ITERATION_COUNT = 2000
/// Default iteration count to use with /// Default iteration count to use with
/// generateKey(). RSA security recommends /// generateKey(). RSA security recommends
/// an iteration count of at least 1000. /// an iteration count of at least 1000.
}; };
CipherKey(const std::string& name, CipherKey(const std::string& name,
const std::string& passphrase, const std::string& passphrase,
const std::string& salt = "", const std::string& salt = "",
int iterationCount = DEFAULT_ITERATION_COUNT); int iterationCount = DEFAULT_ITERATION_COUNT);
/// Creates a new CipherKeyImpl object using the given /// Creates a new CipherKeyImpl object using the given
/// cipher name, passphrase, salt value and iteration count. /// cipher name, passphrase, salt value and iteration count.
CipherKey(const std::string& name, CipherKey(const std::string& name,
const ByteVec& key, const ByteVec& key,
const ByteVec& iv); const ByteVec& iv);
/// Creates a new CipherKeyImpl object using the given cipher /// Creates a new CipherKeyImpl object using the given cipher
/// name, key and initialization vector. /// name, key and initialization vector.
CipherKey(const std::string& name); CipherKey(const std::string& name);
/// Creates a new CipherKeyImpl object. Autoinitializes key and /// Creates a new CipherKeyImpl object. Autoinitializes key and
/// initialization vector. /// initialization vector.
~CipherKey(); ~CipherKey();
/// Destroys the CipherKeyImpl. /// Destroys the CipherKeyImpl.
const std::string& name() const; const std::string& name() const;
/// Returns the name of the Cipher. /// Returns the name of the Cipher.
int keySize() const; int keySize() const;
/// Returns the key size of the Cipher. /// Returns the key size of the Cipher.
int blockSize() const; int blockSize() const;
/// Returns the block size of the Cipher. /// Returns the block size of the Cipher.
int ivSize() const; int ivSize() const;
/// Returns the IV size of the Cipher. /// Returns the IV size of the Cipher.
Mode mode() const; Mode mode() const;
/// Returns the Cipher's mode of operation. /// Returns the Cipher's mode of operation.
const ByteVec& getKey() const; const ByteVec& getKey() const;
/// Returns the key for the Cipher. /// Returns the key for the Cipher.
void setKey(const ByteVec& key); void setKey(const ByteVec& key);
/// Sets the key for the Cipher. /// Sets the key for the Cipher.
const ByteVec& getIV() const; const ByteVec& getIV() const;
/// Returns the initialization vector (IV) for the Cipher. /// Returns the initialization vector (IV) for the Cipher.
void setIV(const ByteVec& iv); void setIV(const ByteVec& iv);
/// Sets the initialization vector (IV) for the Cipher. /// Sets the initialization vector (IV) for the Cipher.
CipherKeyImpl::Ptr impl(); CipherKeyImpl::Ptr impl();
/// Returns the impl object /// Returns the impl object
private: private:
CipherKeyImpl::Ptr _pImpl; CipherKeyImpl::Ptr _pImpl;
}; };
// //
// inlines // inlines
// //
inline const std::string& CipherKey::name() const inline const std::string& CipherKey::name() const
{ {
return _pImpl->name(); return _pImpl->name();
} }
inline int CipherKey::keySize() const inline int CipherKey::keySize() const
{ {
return _pImpl->keySize(); return _pImpl->keySize();
} }
inline int CipherKey::blockSize() const inline int CipherKey::blockSize() const
{ {
return _pImpl->blockSize(); return _pImpl->blockSize();
} }
inline int CipherKey::ivSize() const inline int CipherKey::ivSize() const
{ {
return _pImpl->ivSize(); return _pImpl->ivSize();
} }
inline CipherKey::Mode CipherKey::mode() const inline CipherKey::Mode CipherKey::mode() const
{ {
return _pImpl->mode(); return _pImpl->mode();
} }
inline const CipherKey::ByteVec& CipherKey::getKey() const inline const CipherKey::ByteVec& CipherKey::getKey() const
{ {
return _pImpl->getKey(); return _pImpl->getKey();
} }
inline void CipherKey::setKey(const CipherKey::ByteVec& key) inline void CipherKey::setKey(const CipherKey::ByteVec& key)
{ {
_pImpl->setKey(key); _pImpl->setKey(key);
} }
inline const CipherKey::ByteVec& CipherKey::getIV() const inline const CipherKey::ByteVec& CipherKey::getIV() const
{ {
return _pImpl->getIV(); return _pImpl->getIV();
} }
inline void CipherKey::setIV(const CipherKey::ByteVec& iv) inline void CipherKey::setIV(const CipherKey::ByteVec& iv)
{ {
_pImpl->setIV(iv); _pImpl->setIV(iv);
} }
inline CipherKeyImpl::Ptr CipherKey::impl() inline CipherKeyImpl::Ptr CipherKey::impl()
{ {
return _pImpl; return _pImpl;
} }
} } // namespace Poco::Crypto } } // namespace Poco::Crypto
#endif // Crypto_CipherKey_INCLUDED #endif // Crypto_CipherKey_INCLUDED

View File

@@ -1,190 +1,192 @@
// //
// CipherKeyImpl.h // CipherKeyImpl.h
// //
// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherKeyImpl.h#2 $ // $Id: //poco/1.4/Crypto/include/Poco/Crypto/CipherKeyImpl.h#1 $
// //
// Library: Crypto // Library: Crypto
// Package: Cipher // Package: Cipher
// Module: CipherKeyImpl // Module: CipherKeyImpl
// //
// Definition of the CipherKeyImpl class. // Definition of the CipherKeyImpl class.
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef Crypto_CipherKeyImpl_INCLUDED #ifndef Crypto_CipherKeyImpl_INCLUDED
#define Crypto_CipherKeyImpl_INCLUDED #define Crypto_CipherKeyImpl_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "Poco/RefCountedObject.h" #include "Poco/Crypto/OpenSSLInitializer.h"
#include "Poco/AutoPtr.h" #include "Poco/RefCountedObject.h"
#include <vector> #include "Poco/AutoPtr.h"
#include <vector>
struct evp_cipher_st;
typedef struct evp_cipher_st EVP_CIPHER; struct evp_cipher_st;
typedef struct evp_cipher_st EVP_CIPHER;
namespace Poco {
namespace Crypto { namespace Poco {
namespace Crypto {
class CipherKeyImpl: public RefCountedObject
/// An implementation of the CipherKey class for OpenSSL's crypto library. class CipherKeyImpl: public RefCountedObject
{ /// An implementation of the CipherKey class for OpenSSL's crypto library.
public: {
typedef std::vector<unsigned char> ByteVec; public:
typedef Poco::AutoPtr<CipherKeyImpl> Ptr; typedef std::vector<unsigned char> ByteVec;
typedef Poco::AutoPtr<CipherKeyImpl> Ptr;
enum Mode
/// Cipher mode of operation. This mode determines how multiple blocks enum Mode
/// are connected; this is essential to improve security. /// 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_STREAM_CIPHER, /// Stream cipher
MODE_CBC, /// Cipher block chaining (default) MODE_ECB, /// Electronic codebook (plain concatenation)
MODE_CFB, /// Cipher feedback MODE_CBC, /// Cipher block chaining (default)
MODE_OFB /// Output feedback MODE_CFB, /// Cipher feedback
}; MODE_OFB /// Output feedback
};
CipherKeyImpl(const std::string& name,
const std::string& passphrase, CipherKeyImpl(const std::string& name,
const std::string& salt, const std::string& passphrase,
int iterationCount); const std::string& salt,
/// Creates a new CipherKeyImpl object, using int iterationCount);
/// the given cipher name, passphrase, salt value /// Creates a new CipherKeyImpl object, using
/// and iteration count. /// the given cipher name, passphrase, salt value
/// and iteration count.
CipherKeyImpl(const std::string& name,
const ByteVec& key, CipherKeyImpl(const std::string& name,
const ByteVec& iv); const ByteVec& key,
/// Creates a new CipherKeyImpl object, using the const ByteVec& iv);
/// given cipher name, key and initialization vector. /// 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 CipherKeyImpl(const std::string& name);
/// and initialization vector. /// Creates a new CipherKeyImpl object. Autoinitializes key
/// and initialization vector.
virtual ~CipherKeyImpl();
/// Destroys the CipherKeyImpl. virtual ~CipherKeyImpl();
/// Destroys the CipherKeyImpl.
const std::string& name() const;
/// Returns the name of the Cipher. const std::string& name() const;
/// Returns the name of the Cipher.
int keySize() const;
/// Returns the key size of the Cipher. int keySize() const;
/// Returns the key size of the Cipher.
int blockSize() const;
/// Returns the block size of the Cipher. int blockSize() const;
/// Returns the block size of the Cipher.
int ivSize() const;
/// Returns the IV size of the Cipher. int ivSize() const;
/// Returns the IV size of the Cipher.
Mode mode() const;
/// Returns the Cipher's mode of operation. Mode mode() const;
/// Returns the Cipher's mode of operation.
const ByteVec& getKey() const;
/// Returns the key for the Cipher. const ByteVec& getKey() const;
/// Returns the key for the Cipher.
void setKey(const ByteVec& key);
/// Sets 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. 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. void setIV(const ByteVec& iv);
/// Sets the initialization vector (IV) for the Cipher.
const EVP_CIPHER* cipher();
/// Returns the cipher object const EVP_CIPHER* cipher();
/// Returns the cipher object
private:
void generateKey(const std::string& passphrase, private:
const std::string& salt, void generateKey(const std::string& passphrase,
int iterationCount); const std::string& salt,
/// Generates key and IV from a password and optional salt string. int iterationCount);
/// Generates key and IV from a password and optional salt string.
void generateKey();
/// Generates key and IV from random data. void generateKey();
/// Generates key and IV from random data.
void getRandomBytes(ByteVec& vec, std::size_t count);
/// Stores random bytes in vec. void getRandomBytes(ByteVec& vec, std::size_t count);
/// Stores random bytes in vec.
private:
const EVP_CIPHER* _pCipher; private:
std::string _name; const EVP_CIPHER* _pCipher;
ByteVec _key; std::string _name;
ByteVec _iv; ByteVec _key;
}; ByteVec _iv;
OpenSSLInitializer _openSSLInitializer;
};
//
// Inlines
// //
inline const std::string& CipherKeyImpl::name() const // Inlines
{ //
return _name; inline const std::string& CipherKeyImpl::name() const
} {
return _name;
}
inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getKey() const
{
return _key; inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getKey() const
} {
return _key;
}
inline void CipherKeyImpl::setKey(const ByteVec& key)
{
poco_assert(key.size() == keySize()); inline void CipherKeyImpl::setKey(const ByteVec& key)
_key = key; {
} poco_assert(key.size() == keySize());
_key = key;
}
inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getIV() const
{
return _iv; inline const CipherKeyImpl::ByteVec& CipherKeyImpl::getIV() const
} {
return _iv;
}
inline void CipherKeyImpl::setIV(const ByteVec& iv)
{
poco_assert(iv.size() == ivSize()); inline void CipherKeyImpl::setIV(const ByteVec& iv)
_iv = iv; {
} poco_assert(iv.size() == ivSize());
_iv = iv;
}
inline const EVP_CIPHER* CipherKeyImpl::cipher()
{
return _pCipher; inline const EVP_CIPHER* CipherKeyImpl::cipher()
} {
return _pCipher;
}
} } // namespace Poco::Crypto
} } // namespace Poco::Crypto
#endif // Crypto_CipherKeyImpl_INCLUDED
#endif // Crypto_CipherKeyImpl_INCLUDED

View File

@@ -42,6 +42,12 @@
#define Crypto_Crypto_INCLUDED #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" #include "Poco/Foundation.h"
@@ -93,21 +99,37 @@ enum RSAPaddingMode
// //
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(Crypto_EXPORTS) #if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(Crypto_EXPORTS)
#if defined(POCO_DLL) #pragma comment(lib, "PocoCrypto" POCO_LIB_SUFFIX)
#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
#endif #endif
#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 #endif // Crypto_Crypto_INCLUDED

View File

@@ -145,8 +145,66 @@ public:
~CryptoOutputStream(); ~CryptoOutputStream();
/// Destroys the CryptoOutputStream. /// Destroys the CryptoOutputStream.
void close(); void close();
/// Flushes all buffers and finishes the encryption. /// 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.
}; };

View File

@@ -74,13 +74,13 @@ public:
/// Transforms a chunk of data. The inputLength is arbitrary and does not /// 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 /// 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 /// 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. /// Returns the number of bytes written to the output buffer.
virtual std::streamsize finalize(unsigned char* output, std::streamsize length) = 0; virtual std::streamsize finalize(unsigned char* output, std::streamsize length) = 0;
/// Finalizes the transformation. The output buffer must contain enough /// Finalizes the transformation. The output buffer must contain enough
/// space for at least one block, ie. /// space for at least two blocks, ie.
/// length >= bufferSize() /// length >= 2*blockSize()
/// must be true. Returns the number of bytes written to the output /// must be true. Returns the number of bytes written to the output
/// buffer. /// buffer.
}; };

View File

@@ -1,101 +1,133 @@
// //
// OpenSSLInitializer.h // OpenSSLInitializer.h
// //
// $Id: //poco/Main/Crypto/include/Poco/Crypto/OpenSSLInitializer.h#1 $ // $Id: //poco/1.4/Crypto/include/Poco/Crypto/OpenSSLInitializer.h#1 $
// //
// Library: Crypto // Library: Crypto
// Package: CryptoCore // Package: CryptoCore
// Module: OpenSSLInitializer // Module: OpenSSLInitializer
// //
// Definition of the OpenSSLInitializer class. // Definition of the OpenSSLInitializer class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef Crypto_OpenSSLInitializer_INCLUDED #ifndef Crypto_OpenSSLInitializer_INCLUDED
#define Crypto_OpenSSLInitializer_INCLUDED #define Crypto_OpenSSLInitializer_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "Poco/Mutex.h" #include "Poco/Mutex.h"
#include <openssl/opensslconf.h>
#ifdef OPENSSL_FIPS
extern "C" #include <openssl/fips.h>
{ #endif
struct CRYPTO_dynlock_value
{
Poco::FastMutex _mutex; extern "C"
}; {
} struct CRYPTO_dynlock_value
{
Poco::FastMutex _mutex;
namespace Poco { };
namespace Crypto { }
class Crypto_API OpenSSLInitializer namespace Poco {
/// Initalizes the OpenSSL library. namespace Crypto {
///
/// The class ensures the earliest initialization and the
/// latest shutdown of the OpenSSL library. class Crypto_API OpenSSLInitializer
{ /// Initalizes the OpenSSL library.
public: ///
OpenSSLInitializer(); /// The class ensures the earliest initialization and the
/// Automatically initialize OpenSSL on startup. /// latest shutdown of the OpenSSL library.
{
~OpenSSLInitializer(); public:
/// Automatically shut down OpenSSL on exit. OpenSSLInitializer();
/// Automatically initialize OpenSSL on startup.
static void initialize();
/// Initializes the OpenSSL machinery. ~OpenSSLInitializer();
/// Automatically shut down OpenSSL on exit.
static void uninitialize();
/// Shuts down the OpenSSL machinery. static void initialize();
/// Initializes the OpenSSL machinery.
protected:
enum static void uninitialize();
{ /// Shuts down the OpenSSL machinery.
SEEDSIZE = 256
}; static bool isFIPSEnabled();
// Returns true if FIPS mode is enabled, false otherwise.
// OpenSSL multithreading support
static void lock(int mode, int n, const char* file, int line); static void enableFIPSMode(bool enabled);
static unsigned long id(); // Enable or disable FIPS mode. If FIPS is not available, this method doesn't do anything.
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); protected:
static void dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line); enum
{
private: SEEDSIZE = 256
static Poco::FastMutex* _mutexes; };
static int _rc;
}; // OpenSSL multithreading support
static void lock(int mode, int n, const char* file, int line);
static unsigned long id();
} } // namespace Poco::Crypto 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);
#endif // Crypto_OpenSSLInitializer_INCLUDED
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

View File

@@ -1,97 +1,99 @@
// //
// RSACipherImpl.h // RSACipherImpl.h
// //
// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSACipherImpl.h#2 $ // $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSACipherImpl.h#1 $
// //
// Library: Crypto // Library: Crypto
// Package: RSA // Package: RSA
// Module: RSACipherImpl // Module: RSACipherImpl
// //
// Definition of the RSACipherImpl class. // Definition of the RSACipherImpl class.
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef Crypto_RSACipherImpl_INCLUDED #ifndef Crypto_RSACipherImpl_INCLUDED
#define Crypto_RSACipherImpl_INCLUDED #define Crypto_RSACipherImpl_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "Poco/Crypto/Cipher.h" #include "Poco/Crypto/Cipher.h"
#include "Poco/Crypto/RSAKey.h" #include "Poco/Crypto/RSAKey.h"
#include <openssl/evp.h> #include "Poco/Crypto/OpenSSLInitializer.h"
#include <openssl/evp.h>
namespace Poco {
namespace Crypto { namespace Poco {
namespace Crypto {
class RSACipherImpl: public Cipher
/// An implementation of the Cipher class for class RSACipherImpl: public Cipher
/// assymetric (public-private key) encryption /// An implementation of the Cipher class for
/// based on the the RSA algorithm in OpenSSL's /// assymetric (public-private key) encryption
/// crypto library. /// based on the the RSA algorithm in OpenSSL's
/// /// crypto library.
/// Encryption is using the public key, decryption ///
/// requires the private key. /// Encryption is using the public key, decryption
{ /// requires the private key.
public: {
RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode); public:
/// Creates a new RSACipherImpl object for the given RSAKey RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode);
/// and using the given padding mode. /// Creates a new RSACipherImpl object for the given RSAKey
/// and using the given padding mode.
virtual ~RSACipherImpl();
/// Destroys the RSACipherImpl. virtual ~RSACipherImpl();
/// Destroys the RSACipherImpl.
const std::string& name() const;
/// Returns the name of the Cipher. const std::string& name() const;
/// Returns the name of the Cipher.
CryptoTransform* createEncryptor();
/// Creates an encrytor object. CryptoTransform* createEncryptor();
/// Creates an encrytor object.
CryptoTransform* createDecryptor();
/// Creates a decrytor object. CryptoTransform* createDecryptor();
/// Creates a decrytor object.
private:
RSAKey _key; private:
RSAPaddingMode _paddingMode; RSAKey _key;
}; RSAPaddingMode _paddingMode;
OpenSSLInitializer _openSSLInitializer;
};
//
// Inlines
// //
inline const std::string& RSACipherImpl::name() const // Inlines
{ //
return _key.name(); inline const std::string& RSACipherImpl::name() const
} {
return _key.name();
}
} } // namespace Poco::Crypto
} } // namespace Poco::Crypto
#endif // Crypto_RSACipherImpl_INCLUDED
#endif // Crypto_RSACipherImpl_INCLUDED

View File

@@ -1,128 +1,128 @@
// //
// RSADigestEngine.h // RSADigestEngine.h
// //
// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSADigestEngine.h#2 $ // $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSADigestEngine.h#1 $
// //
// Library: Crypto // Library: Crypto
// Package: RSA // Package: RSA
// Module: RSADigestEngine // Module: RSADigestEngine
// //
// Definition of the RSADigestEngine class. // Definition of the RSADigestEngine class.
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef Crypto_RSADigestEngine_INCLUDED #ifndef Crypto_RSADigestEngine_INCLUDED
#define Crypto_RSADigestEngine_INCLUDED #define Crypto_RSADigestEngine_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "Poco/Crypto/RSAKey.h" #include "Poco/Crypto/RSAKey.h"
#include "Poco/DigestEngine.h" #include "Poco/DigestEngine.h"
#include "Poco/MD5Engine.h" #include "Poco/MD5Engine.h"
#include "Poco/SHA1Engine.h" #include "Poco/SHA1Engine.h"
#include <openssl/rsa.h> #include <openssl/rsa.h>
#include <istream> #include <istream>
#include <ostream> #include <ostream>
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
class Crypto_API RSADigestEngine: public Poco::DigestEngine class Crypto_API RSADigestEngine: public Poco::DigestEngine
/// This class implements a Poco::DigestEngine that can be /// This class implements a Poco::DigestEngine that can be
/// used to compute a secure digital signature. /// used to compute a secure digital signature.
/// ///
/// First another Poco::DigestEngine (Poco::MD5Engine /// First another Poco::DigestEngine (Poco::MD5Engine
/// or Poco::SHA1Engine) is used to compute a cryptographic /// or Poco::SHA1Engine) is used to compute a cryptographic
/// hash of the data to be signed. Then, the hash value is /// hash of the data to be signed. Then, the hash value is
/// encrypted, using the RSA private key. /// encrypted, using the RSA private key.
/// ///
/// To verify a signature, pass it to the verify() /// To verify a signature, pass it to the verify()
/// member function. It will decrypt the signature /// member function. It will decrypt the signature
/// using the RSA public key and compare the resulting /// using the RSA public key and compare the resulting
/// hash with the actual hash of the data. /// hash with the actual hash of the data.
{ {
public: public:
enum DigestType enum DigestType
{ {
DIGEST_MD5, DIGEST_MD5,
DIGEST_SHA1 DIGEST_SHA1
}; };
RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1); RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1);
/// Creates the RSADigestEngine with the given RSA key, /// Creates the RSADigestEngine with the given RSA key,
/// using the SHA-1 hash algorithm. /// using the SHA-1 hash algorithm.
~RSADigestEngine(); ~RSADigestEngine();
/// Destroys the RSADigestEngine. /// Destroys the RSADigestEngine.
unsigned digestLength() const; unsigned digestLength() const;
/// Returns the length of the digest in bytes. /// Returns the length of the digest in bytes.
void reset(); void reset();
/// Resets the engine so that a new /// Resets the engine so that a new
/// digest can be computed. /// digest can be computed.
const DigestEngine::Digest& digest(); const DigestEngine::Digest& digest();
/// Finishes the computation of the digest /// Finishes the computation of the digest
/// (the first time it's called) and /// (the first time it's called) and
/// returns the message digest. /// returns the message digest.
/// ///
/// Can be called multiple times. /// Can be called multiple times.
const DigestEngine::Digest& signature(); const DigestEngine::Digest& signature();
/// Signs the digest using the RSA algorithm /// Signs the digest using the RSA algorithm
/// and the private key (teh first time it's /// and the private key (teh first time it's
/// called) and returns the result. /// called) and returns the result.
/// ///
/// Can be called multiple times. /// Can be called multiple times.
bool verify(const DigestEngine::Digest& signature); bool verify(const DigestEngine::Digest& signature);
/// Verifies the data against the signature. /// Verifies the data against the signature.
/// ///
/// Returns true if the signature can be verified, false otherwise. /// Returns true if the signature can be verified, false otherwise.
protected: protected:
void updateImpl(const void* data, unsigned length); void updateImpl(const void* data, unsigned length);
private: private:
RSAKey _key; RSAKey _key;
Poco::DigestEngine& _engine; Poco::DigestEngine& _engine;
int _type; int _type;
Poco::DigestEngine::Digest _digest; Poco::DigestEngine::Digest _digest;
Poco::DigestEngine::Digest _signature; Poco::DigestEngine::Digest _signature;
Poco::MD5Engine _md5Engine; Poco::MD5Engine _md5Engine;
Poco::SHA1Engine _sha1Engine; Poco::SHA1Engine _sha1Engine;
}; };
} } // namespace Poco::Crypto } } // namespace Poco::Crypto
#endif // Crypto_RSADigestEngine_INCLUDED #endif // Crypto_RSADigestEngine_INCLUDED

View File

@@ -1,136 +1,145 @@
// //
// RSAKey.h // RSAKey.h
// //
// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSAKey.h#4 $ // $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSAKey.h#1 $
// //
// Library: Crypto // Library: Crypto
// Package: RSA // Package: RSA
// Module: RSAKey // Module: RSAKey
// //
// Definition of the RSAKey class. // Definition of the RSAKey class.
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef Crypto_RSAKey_INCLUDED #ifndef Crypto_RSAKey_INCLUDED
#define Crypto_RSAKey_INCLUDED #define Crypto_RSAKey_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "Poco/Crypto/RSAKeyImpl.h" #include "Poco/Crypto/RSAKeyImpl.h"
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
class X509Certificate; class X509Certificate;
class Crypto_API RSAKey class Crypto_API RSAKey
/// This class stores an RSA key pair, consisting /// This class stores an RSA key pair, consisting
/// of private and public key. Storage of the private /// of private and public key. Storage of the private
/// key is optional. /// key is optional.
/// ///
/// If a private key is available, the RSAKey can be /// If a private key is available, the RSAKey can be
/// used for decrypting data (encrypted with the public key) /// used for decrypting data (encrypted with the public key)
/// or computing secure digital signatures. /// or computing secure digital signatures.
{ {
public: public:
enum KeyLength enum KeyLength
{ {
KL_512 = 512, KL_512 = 512,
KL_1024 = 1024, KL_1024 = 1024,
KL_2048 = 2048, KL_2048 = 2048,
KL_4096 = 4096 KL_4096 = 4096
}; };
enum Exponent enum Exponent
{ {
EXP_SMALL = 0, EXP_SMALL = 0,
EXP_LARGE EXP_LARGE
}; };
explicit RSAKey(const X509Certificate& cert); explicit RSAKey(const X509Certificate& cert);
/// Extracts the RSA public key from the given certificate. /// Extracts the RSA public key from the given certificate.
RSAKey(KeyLength keyLength, Exponent exp); RSAKey(KeyLength keyLength, Exponent exp);
/// Creates the RSAKey. Creates a new public/private keypair using the given parameters. /// Creates the RSAKey. Creates a new public/private keypair using the given parameters.
/// Can be used to sign data and verify signatures. /// Can be used to sign data and verify signatures.
RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = ""); 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 /// 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 /// using the given passphrase for the private key. Can only by used for signing if
/// a private key is available. /// a private key is available.
RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = ""); RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
/// Creates the RSAKey. Can only by used for signing if pPrivKey /// 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 /// 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. /// specify a public key file. OpenSSL will auto-create it from the private key.
~RSAKey(); ~RSAKey();
/// Destroys the RSAKey. /// Destroys the RSAKey.
int size() const; int size() const;
/// Returns the RSA modulus size. /// Returns the RSA modulus size.
void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = ""); RSAKeyImpl::ByteVec modulus() const;
/// Exports the public and private keys to the given files. /// Returns the RSA modulus.
///
/// If an empty filename is specified, the corresponding key RSAKeyImpl::ByteVec encryptionExponent() const;
/// is not exported. /// Returns the RSA encryption exponent.
void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = ""); RSAKeyImpl::ByteVec decryptionExponent() const;
/// Exports the public and private key to the given streams. /// Returns the RSA decryption exponent.
///
/// If a null pointer is passed for a stream, the corresponding void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
/// key is not exported. /// Exports the public and private keys to the given files.
///
RSAKeyImpl::Ptr impl(); /// If an empty filename is specified, the corresponding key
/// Returns the impl object. /// is not exported.
const std::string& name() const; void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
/// Returns "rsa" /// Exports the public and private key to the given streams.
///
private: /// If a null pointer is passed for a stream, the corresponding
RSAKeyImpl::Ptr _pImpl; /// key is not exported.
};
RSAKeyImpl::Ptr impl() const;
/// Returns the impl object.
//
// inlines const std::string& name() const;
// /// Returns "rsa"
inline RSAKeyImpl::Ptr RSAKey::impl()
{ private:
return _pImpl; RSAKeyImpl::Ptr _pImpl;
} };
} } // namespace Poco::Crypto //
// inlines
//
#endif // Crypto_RSAKey_INCLUDED inline RSAKeyImpl::Ptr RSAKey::impl() const
{
return _pImpl;
}
} } // namespace Poco::Crypto
#endif // Crypto_RSAKey_INCLUDED

View File

@@ -1,134 +1,150 @@
// //
// RSAKeyImpl.h // RSAKeyImpl.h
// //
// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSAKeyImpl.h#3 $ // $Id: //poco/1.4/Crypto/include/Poco/Crypto/RSAKeyImpl.h#1 $
// //
// Library: Crypto // Library: Crypto
// Package: RSA // Package: RSA
// Module: RSAKeyImpl // Module: RSAKeyImpl
// //
// Definition of the RSAKeyImpl class. // Definition of the RSAKeyImpl class.
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef Crypto_RSAKeyImplImpl_INCLUDED #ifndef Crypto_RSAKeyImplImpl_INCLUDED
#define Crypto_RSAKeyImplImpl_INCLUDED #define Crypto_RSAKeyImplImpl_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "Poco/RefCountedObject.h" #include "Poco/Crypto/OpenSSLInitializer.h"
#include "Poco/AutoPtr.h" #include "Poco/RefCountedObject.h"
#include <istream> #include "Poco/AutoPtr.h"
#include <ostream> #include <istream>
#include <ostream>
#include <vector>
struct rsa_st;
typedef struct rsa_st RSA;
struct bignum_st;
struct rsa_st;
namespace Poco { typedef struct bignum_st BIGNUM;
namespace Crypto { typedef struct rsa_st RSA;
class X509Certificate; namespace Poco {
namespace Crypto {
class RSAKeyImpl: public Poco::RefCountedObject
/// class RSAKeyImpl class X509Certificate;
{
public:
typedef Poco::AutoPtr<RSAKeyImpl> Ptr; class RSAKeyImpl: public Poco::RefCountedObject
/// class RSAKeyImpl
explicit RSAKeyImpl(const X509Certificate& cert); {
/// Extracts the RSA public key from the given certificate. public:
typedef Poco::AutoPtr<RSAKeyImpl> Ptr;
RSAKeyImpl(int keyLength, unsigned long exponent); typedef std::vector<unsigned char> ByteVec;
/// Creates the RSAKey. Creates a new public/private keypair using the given parameters.
/// Can be used to sign data and verify signatures. explicit RSAKeyImpl(const X509Certificate& cert);
/// Extracts the RSA public key from the given certificate.
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 RSAKeyImpl(int keyLength, unsigned long exponent);
/// using the given passphrase for the private key. Can only by used for signing if /// Creates the RSAKey. Creates a new public/private keypair using the given parameters.
/// a private key is available. /// Can be used to sign data and verify signatures.
RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase); RSAKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase);
/// Creates the RSAKey. Can only by used for signing if pPrivKey /// Creates the RSAKey, by reading public and private key from the given files and
/// is not null. If a private key file is specified, you don't need to /// using the given passphrase for the private key. Can only by used for signing if
/// specify a public key file. OpenSSL will auto-create it from the private key. /// a private key is available.
~RSAKeyImpl(); RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase);
/// Destroys the RSAKeyImpl. /// 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
RSA* getRSA(); /// specify a public key file. OpenSSL will auto-create it from the private key.
/// Returns the OpenSSL RSA object.
~RSAKeyImpl();
const RSA* getRSA() const; /// Destroys the RSAKeyImpl.
/// Returns the OpenSSL RSA object.
RSA* getRSA();
int size() const; /// Returns the OpenSSL RSA object.
/// Returns the RSA modulus size.
const RSA* getRSA() const;
void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = ""); /// Returns the OpenSSL RSA object.
/// Exports the public and private keys to the given files.
/// int size() const;
/// If an empty filename is specified, the corresponding key /// Returns the RSA modulus size.
/// is not exported.
ByteVec modulus() const;
void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = ""); /// Returns the RSA modulus.
/// Exports the public and private key to the given streams.
/// ByteVec encryptionExponent() const;
/// If a null pointer is passed for a stream, the corresponding /// Returns the RSA encryption exponent.
/// key is not exported.
ByteVec decryptionExponent() const;
private: /// Returns the RSA decryption exponent.
void init(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase);
void freeRSA(); void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
/// Exports the public and private keys to the given files.
private: ///
RSA* _pRSA; /// 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.
// inlines ///
// /// If a null pointer is passed for a stream, the corresponding
inline RSA* RSAKeyImpl::getRSA() /// key is not exported.
{
return _pRSA; private:
} void freeRSA();
static ByteVec convertToByteVec(const BIGNUM* bn);
inline const RSA* RSAKeyImpl::getRSA() const
{ private:
return _pRSA; RSA* _pRSA;
} OpenSSLInitializer _openSSLInitializer;
};
} } // namespace Poco::Crypto
//
#endif // Crypto_RSAKeyImplImpl_INCLUDED // inlines
//
inline RSA* RSAKeyImpl::getRSA()
{
return _pRSA;
}
inline const RSA* RSAKeyImpl::getRSA() const
{
return _pRSA;
}
} } // namespace Poco::Crypto
#endif // Crypto_RSAKeyImplImpl_INCLUDED

View File

@@ -1,197 +1,205 @@
// //
// X509Certificate.h // X509Certificate.h
// //
// $Id: //poco/Main/Crypto/include/Poco/Crypto/X509Certificate.h#1 $ // $Id: //poco/1.4/Crypto/include/Poco/Crypto/X509Certificate.h#1 $
// //
// Library: Crypto // Library: Crypto
// Package: Certificate // Package: Certificate
// Module: X509Certificate // Module: X509Certificate
// //
// Definition of the X509Certificate class. // Definition of the X509Certificate class.
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef Crypto_X509Certificate_INCLUDED #ifndef Crypto_X509Certificate_INCLUDED
#define Crypto_X509Certificate_INCLUDED #define Crypto_X509Certificate_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "Poco/DateTime.h" #include "Poco/Crypto/OpenSSLInitializer.h"
#include "Poco/SharedPtr.h" #include "Poco/DateTime.h"
#include <set> #include "Poco/SharedPtr.h"
#include <istream> #include <set>
#include <openssl/ssl.h> #include <istream>
#include <openssl/ssl.h>
namespace Poco {
namespace Crypto { namespace Poco {
namespace Crypto {
class Crypto_API X509Certificate
/// This class represents a X509 Certificate. class Crypto_API X509Certificate
{ /// This class represents a X509 Certificate.
public: {
enum NID public:
/// Name identifier for extracting information from enum NID
/// a certificate subject's or issuer's distinguished name. /// Name identifier for extracting information from
{ /// a certificate subject's or issuer's distinguished name.
NID_COMMON_NAME = 13, {
NID_COUNTRY = 14, NID_COMMON_NAME = 13,
NID_LOCALITY_NAME = 15, NID_COUNTRY = 14,
NID_STATE_OR_PROVINCE = 16, NID_LOCALITY_NAME = 15,
NID_ORGANIZATION_NAME = 17, NID_STATE_OR_PROVINCE = 16,
NID_ORGANIZATION_UNIT_NAME = 18 NID_ORGANIZATION_NAME = 17,
}; NID_ORGANIZATION_UNIT_NAME = 18
};
explicit X509Certificate(std::istream& istr);
/// Creates the X509Certificate object by reading explicit X509Certificate(std::istream& istr);
/// a certificate in PEM format from a stream. /// 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 explicit X509Certificate(const std::string& path);
/// a certificate in PEM format from a file. /// Creates the X509Certificate object by reading
/// a certificate in PEM format from a file.
explicit X509Certificate(X509* pCert);
/// Creates the X509Certificate from an existing explicit X509Certificate(X509* pCert);
/// OpenSSL certificate. Ownership is taken of /// Creates the X509Certificate from an existing
/// the certificate. /// OpenSSL certificate. Ownership is taken of
/// the certificate.
X509Certificate(const X509Certificate& cert);
/// Creates the certificate by copying another one. X509Certificate(X509* pCert, bool shared);
/// Creates the X509Certificate from an existing
X509Certificate& operator = (const X509Certificate& cert); /// OpenSSL certificate. Ownership is taken of
/// Assigns a certificate. /// the certificate. If shared is true, the
/// certificate's reference count is incremented.
void swap(X509Certificate& cert);
/// Exchanges the certificate with another one. X509Certificate(const X509Certificate& cert);
/// Creates the certificate by copying another one.
~X509Certificate();
/// Destroys the X509Certificate. X509Certificate& operator = (const X509Certificate& cert);
/// Assigns a certificate.
const std::string& issuerName() const;
/// Returns the certificate issuer's distinguished name. void swap(X509Certificate& cert);
/// Exchanges the certificate with another one.
std::string issuerName(NID nid) const;
/// Extracts the information specified by the given ~X509Certificate();
/// NID (name identifier) from the certificate issuer's /// Destroys the X509Certificate.
/// distinguished name.
const std::string& issuerName() const;
const std::string& subjectName() const; /// Returns the certificate issuer's distinguished name.
/// Returns the certificate subject's distinguished name.
std::string issuerName(NID nid) const;
std::string subjectName(NID nid) const; /// Extracts the information specified by the given
/// Extracts the information specified by the given /// NID (name identifier) from the certificate issuer's
/// NID (name identifier) from the certificate subject's /// distinguished name.
/// distinguished name.
const std::string& subjectName() const;
std::string commonName() const; /// Returns the certificate subject's distinguished name.
/// Returns the common name stored in the certificate
/// subject's distinguished name. std::string subjectName(NID nid) const;
/// Extracts the information specified by the given
void extractNames(std::string& commonName, std::set<std::string>& domainNames) const; /// NID (name identifier) from the certificate subject's
/// Extracts the common name and the alias domain names from the /// distinguished name.
/// certificate.
std::string commonName() const;
Poco::DateTime validFrom() const; /// Returns the common name stored in the certificate
/// Returns the date and time the certificate is valid from. /// subject's distinguished name.
Poco::DateTime expiresOn() const; void extractNames(std::string& commonName, std::set<std::string>& domainNames) const;
/// Returns the date and time the certificate expires. /// Extracts the common name and the alias domain names from the
/// certificate.
void save(std::ostream& stream) const;
/// Writes the certificate to the given stream. Poco::DateTime validFrom() const;
/// The certificate is written in PEM format. /// Returns the date and time the certificate is valid from.
void save(const std::string& path) const; Poco::DateTime expiresOn() const;
/// Writes the certificate to the file given by path. /// Returns the date and time the certificate expires.
/// The certificate is written in PEM format.
void save(std::ostream& stream) const;
bool issuedBy(const X509Certificate& issuerCertificate) const; /// Writes the certificate to the given stream.
/// Checks whether the certificate has been issued by /// The certificate is written in PEM format.
/// the issuer given by issuerCertificate. This can be
/// used to validate a certificate chain. void save(const std::string& path) const;
/// /// Writes the certificate to the file given by path.
/// Verifies if the certificate has been signed with the /// The certificate is written in PEM format.
/// issuer's private key, using the public key from the issuer
/// certificate. bool issuedBy(const X509Certificate& issuerCertificate) const;
/// /// Checks whether the certificate has been issued by
/// Returns true if verification against the issuer certificate /// the issuer given by issuerCertificate. This can be
/// was successfull, false otherwise. /// used to validate a certificate chain.
///
const X509* certificate() const; /// Verifies if the certificate has been signed with the
/// Returns the underlying OpenSSL certificate. /// issuer's private key, using the public key from the issuer
/// certificate.
protected: ///
void load(std::istream& stream); /// Returns true if verification against the issuer certificate
/// Loads the certificate from the given stream. The /// was successfull, false otherwise.
/// certificate must be in PEM format.
const X509* certificate() const;
void load(const std::string& path); /// Returns the underlying OpenSSL certificate.
/// Loads the certificate from the given file. The
/// certificate must be in PEM format. protected:
void load(std::istream& stream);
void init(); /// Loads the certificate from the given stream. The
/// Extracts issuer and subject name from the certificate. /// certificate must be in PEM format.
private: void load(const std::string& path);
enum /// Loads the certificate from the given file. The
{ /// certificate must be in PEM format.
NAME_BUFFER_SIZE = 256
}; void init();
/// Extracts issuer and subject name from the certificate.
std::string _issuerName;
std::string _subjectName; private:
X509* _pCert; enum
}; {
NAME_BUFFER_SIZE = 256
};
//
// inlines std::string _issuerName;
// std::string _subjectName;
inline const std::string& X509Certificate::issuerName() const X509* _pCert;
{ OpenSSLInitializer _openSSLInitializer;
return _issuerName; };
}
//
inline const std::string& X509Certificate::subjectName() const // inlines
{ //
return _subjectName; inline const std::string& X509Certificate::issuerName() const
} {
return _issuerName;
}
inline const X509* X509Certificate::certificate() const
{
return _pCert; inline const std::string& X509Certificate::subjectName() const
} {
return _subjectName;
}
} } // namespace Poco::Crypto
inline const X509* X509Certificate::certificate() const
#endif // Crypto_X509Certificate_INCLUDED {
return _pCert;
}
} } // namespace Poco::Crypto
#endif // Crypto_X509Certificate_INCLUDED

View 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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">genrsakeyd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">genrsakeyd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">genrsakeyd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">genrsakey</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">genrsakey</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">genrsakey</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">
<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>

View 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>

View 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>

View 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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">genrsakeyd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">genrsakeyd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">genrsakeyd</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">genrsakey</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">genrsakey</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">genrsakey</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">
<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>

View 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>

View 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>

View File

@@ -1,212 +1,218 @@
// //
// genrsakey.cpp // genrsakey.cpp
// //
// $Id: //poco/Main/Crypto/samples/genrsakey/src/genrsakey.cpp#1 $ // $Id: //poco/Main/Crypto/samples/genrsakey/src/genrsakey.cpp#1 $
// //
// This sample demonstrates the XYZ class. // This sample demonstrates the XYZ class.
// //
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. // Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include "Poco/Util/OptionException.h" #include "Poco/Util/OptionException.h"
#include "Poco/Util/OptionSet.h" #include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h" #include "Poco/Util/HelpFormatter.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
#include "Poco/NumberParser.h" #include "Poco/NumberParser.h"
#include "Poco/String.h" #include "Poco/String.h"
#include "Poco/Crypto/RSAKey.h" #include "Poco/Crypto/RSAKey.h"
#include <iostream> #include <iostream>
using Poco::Util::Application; using Poco::Util::Application;
using Poco::Util::Option; using Poco::Util::Option;
using Poco::Util::OptionSet; using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter; using Poco::Util::HelpFormatter;
using Poco::Util::AbstractConfiguration; using Poco::Util::AbstractConfiguration;
using Poco::Util::OptionCallback; using Poco::Util::OptionCallback;
using Poco::AutoPtr; using Poco::AutoPtr;
using Poco::NumberParser; using Poco::NumberParser;
using Poco::Crypto::RSAKey; using Poco::Crypto::RSAKey;
class RSAApp: public Application class RSAApp: public Application
/// This sample demonstrates some of the features of the Util::Application class, /// This sample demonstrates some of the features of the Util::Application class,
/// such as configuration file handling and command line arguments processing. /// such as configuration file handling and command line arguments processing.
/// ///
/// Try genrsakey --help (on Unix platforms) or genrsakey /help (elsewhere) for /// Try genrsakey --help (on Unix platforms) or genrsakey /help (elsewhere) for
/// more information. /// more information.
{ {
public: public:
RSAApp(): RSAApp():
_helpRequested(false), _helpRequested(false),
_length(RSAKey::KL_1024), _length(RSAKey::KL_1024),
_exp(RSAKey::EXP_LARGE), _exp(RSAKey::EXP_LARGE),
_name(), _name(),
_pwd() _pwd()
{ {
} Poco::Crypto::initializeCrypto();
}
protected:
void initialize(Application& self) ~RSAApp()
{ {
loadConfiguration(); // load default configuration files, if present Poco::Crypto::uninitializeCrypto();
Application::initialize(self); }
}
protected:
void uninitialize() void initialize(Application& self)
{ {
Application::uninitialize(); loadConfiguration(); // load default configuration files, if present
} Application::initialize(self);
}
void reinitialize(Application& self)
{ void uninitialize()
Application::reinitialize(self); {
} Application::uninitialize();
}
void defineOptions(OptionSet& options)
{ void reinitialize(Application& self)
Application::defineOptions(options); {
Application::reinitialize(self);
options.addOption( }
Option("help", "h", "display help information on command line arguments")
.required(false) void defineOptions(OptionSet& options)
.repeatable(false) {
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleHelp))); Application::defineOptions(options);
options.addOption( options.addOption(
Option("?", "?", "display help information on command line arguments") Option("help", "h", "display help information on command line arguments")
.required(false) .required(false)
.repeatable(false) .repeatable(false)
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleHelp))); .callback(OptionCallback<RSAApp>(this, &RSAApp::handleHelp)));
options.addOption( options.addOption(
Option("key", "k", "define the key length") Option("?", "?", "display help information on command line arguments")
.required(false) .required(false)
.repeatable(false) .repeatable(false)
.argument("512|1024|2048|4096") .callback(OptionCallback<RSAApp>(this, &RSAApp::handleHelp)));
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleKeyLength)));
options.addOption(
options.addOption( Option("key", "k", "define the key length")
Option("exponent", "e", "defines the exponent of the key") .required(false)
.required(false) .repeatable(false)
.repeatable(false) .argument("512|1024|2048|4096")
.argument("small|large") .callback(OptionCallback<RSAApp>(this, &RSAApp::handleKeyLength)));
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleExponent)));
options.addOption(
options.addOption( Option("exponent", "e", "defines the exponent of the key")
Option("file", "f", "defines the file base name. creates a file.pub and a file.priv") .required(false)
.required(true) .repeatable(false)
.repeatable(false) .argument("small|large")
.argument("filebasename") .callback(OptionCallback<RSAApp>(this, &RSAApp::handleExponent)));
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleFilePrefix)));
options.addOption(
options.addOption( Option("file", "f", "defines the file base name. creates a file.pub and a file.priv")
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(true)
.required(false) .repeatable(false)
.repeatable(false) .argument("filebasename")
.argument("pwd") .callback(OptionCallback<RSAApp>(this, &RSAApp::handleFilePrefix)));
.callback(OptionCallback<RSAApp>(this, &RSAApp::handlePassword)));
} 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")
void handleHelp(const std::string& name, const std::string& value) .required(false)
{ .repeatable(false)
_helpRequested = true; .argument("pwd")
displayHelp(); .callback(OptionCallback<RSAApp>(this, &RSAApp::handlePassword)));
stopOptionsProcessing(); }
}
void handleHelp(const std::string& name, const std::string& value)
void handleKeyLength(const std::string& name, const std::string& value) {
{ _helpRequested = true;
int keyLen = Poco::NumberParser::parse(value); displayHelp();
if (keyLen == 512 || keyLen == 1024 || keyLen == 2048 || keyLen == 4096) stopOptionsProcessing();
_length = (RSAKey::KeyLength)keyLen; }
else
throw Poco::Util::IncompatibleOptionsException("Illegal key length value"); void handleKeyLength(const std::string& name, const std::string& value)
} {
int keyLen = Poco::NumberParser::parse(value);
void handleExponent(const std::string& name, const std::string& value) if (keyLen == 512 || keyLen == 1024 || keyLen == 2048 || keyLen == 4096)
{ _length = (RSAKey::KeyLength)keyLen;
if (Poco::icompare(value, "small") == 0) else
_exp = RSAKey::EXP_SMALL; throw Poco::Util::IncompatibleOptionsException("Illegal key length value");
else }
_exp = RSAKey::EXP_LARGE;
} void handleExponent(const std::string& name, const std::string& value)
{
void handleFilePrefix(const std::string& name, const std::string& value) if (Poco::icompare(value, "small") == 0)
{ _exp = RSAKey::EXP_SMALL;
if (value.empty()) else
throw Poco::Util::IncompatibleOptionsException("Empty file prefix forbidden"); _exp = RSAKey::EXP_LARGE;
_name = value; }
}
void handleFilePrefix(const std::string& name, const std::string& value)
void handlePassword(const std::string& name, const std::string& value) {
{ if (value.empty())
_pwd = value; throw Poco::Util::IncompatibleOptionsException("Empty file prefix forbidden");
} _name = value;
}
void displayHelp()
{ void handlePassword(const std::string& name, const std::string& value)
HelpFormatter helpFormatter(options()); {
helpFormatter.setCommand(commandName()); _pwd = value;
helpFormatter.setUsage("OPTIONS"); }
helpFormatter.setHeader("Application for generating RSA public/private key pairs.");
helpFormatter.format(std::cout); void displayHelp()
} {
HelpFormatter helpFormatter(options());
int main(const std::vector<std::string>& args) helpFormatter.setCommand(commandName());
{ helpFormatter.setUsage("OPTIONS");
if (!_helpRequested) helpFormatter.setHeader("Application for generating RSA public/private key pairs.");
{ helpFormatter.format(std::cout);
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"); int main(const std::vector<std::string>& args)
RSAKey key(_length, _exp); {
logger().information("Generating key: DONE"); if (!_helpRequested)
std::string pubFile(_name + ".pub"); {
std::string privFile(_name + ".priv"); 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("Saving key to " + pubFile + " and " + privFile); logger().information("Generating key");
key.save(pubFile, privFile, _pwd); RSAKey key(_length, _exp);
logger().information("Key saved"); logger().information("Generating key: DONE");
} std::string pubFile(_name + ".pub");
return Application::EXIT_OK; std::string privFile(_name + ".priv");
}
logger().information("Saving key to " + pubFile + " and " + privFile);
private: key.save(pubFile, privFile, _pwd);
bool _helpRequested; logger().information("Key saved");
RSAKey::KeyLength _length; }
RSAKey::Exponent _exp; return Application::EXIT_OK;
std::string _name; }
std::string _pwd;
}; private:
bool _helpRequested;
RSAKey::KeyLength _length;
POCO_APP_MAIN(RSAApp) RSAKey::Exponent _exp;
std::string _name;
std::string _pwd;
};
POCO_APP_MAIN(RSAApp)

View 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

View 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

View File

@@ -93,16 +93,26 @@ void Cipher::encrypt(std::istream& source, std::ostream& sink, Encoding encoding
break; break;
case ENC_BASE64: case ENC_BASE64:
case ENC_BASE64_NO_LF:
{ {
Poco::Base64Encoder encoder(sink); Poco::Base64Encoder encoder(sink);
if (encoding == ENC_BASE64_NO_LF)
{
encoder.rdbuf()->setLineLength(0);
}
StreamCopier::copyStream(encryptor, encoder); StreamCopier::copyStream(encryptor, encoder);
encoder.close(); encoder.close();
} }
break; break;
case ENC_BINHEX: case ENC_BINHEX:
case ENC_BINHEX_NO_LF:
{ {
Poco::HexBinaryEncoder encoder(sink); Poco::HexBinaryEncoder encoder(sink);
if (encoding == ENC_BINHEX_NO_LF)
{
encoder.rdbuf()->setLineLength(0);
}
StreamCopier::copyStream(encryptor, encoder); StreamCopier::copyStream(encryptor, encoder);
encoder.close(); encoder.close();
} }
@@ -126,6 +136,7 @@ void Cipher::decrypt(std::istream& source, std::ostream& sink, Encoding encoding
break; break;
case ENC_BASE64: case ENC_BASE64:
case ENC_BASE64_NO_LF:
{ {
Poco::Base64Decoder decoder(source); Poco::Base64Decoder decoder(source);
StreamCopier::copyStream(decoder, decryptor); StreamCopier::copyStream(decoder, decryptor);
@@ -134,6 +145,7 @@ void Cipher::decrypt(std::istream& source, std::ostream& sink, Encoding encoding
break; break;
case ENC_BINHEX: case ENC_BINHEX:
case ENC_BINHEX_NO_LF:
{ {
Poco::HexBinaryDecoder decoder(source); Poco::HexBinaryDecoder decoder(source);
StreamCopier::copyStream(decoder, decryptor); StreamCopier::copyStream(decoder, decryptor);

View File

@@ -50,35 +50,25 @@ namespace Poco {
namespace Crypto { namespace Crypto {
int CipherFactory::_instanceCount = 0;
CipherFactory::CipherFactory() CipherFactory::CipherFactory()
{ {
if (_instanceCount == 0)
{
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
}
++_instanceCount;
} }
CipherFactory::~CipherFactory() CipherFactory::~CipherFactory()
{ {
--_instanceCount; }
if (_instanceCount == 0)
{
ERR_free_strings(); namespace
EVP_cleanup(); {
} static Poco::SingletonHolder<CipherFactory> holder;
} }
CipherFactory& CipherFactory::defaultFactory() CipherFactory& CipherFactory::defaultFactory()
{ {
static Poco::SingletonHolder<CipherFactory> holder; return *holder.get();
return *holder.get();
} }

View File

@@ -176,7 +176,7 @@ namespace
CipherImpl::CipherImpl(const CipherKey& key): CipherImpl::CipherImpl(const CipherKey& key):
_key(key) _key(key)
{ {
} }

View File

@@ -1,72 +1,67 @@
// //
// CipherKey.cpp // CipherKey.cpp
// //
// $Id: //poco/Main/Crypto/src/CipherKey.cpp#2 $ // $Id: //poco/1.4/Crypto/src/CipherKey.cpp#1 $
// //
// Library: Crypto // Library: Crypto
// Package: Cipher // Package: Cipher
// Module: CipherKey // Module: CipherKey
// //
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. // Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Crypto/CipherKey.h" #include "Poco/Crypto/CipherKey.h"
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
CipherKey::CipherKey(const std::string& name, CipherKey::CipherKey(const std::string& name, const std::string& passphrase, const std::string& salt, int iterationCount):
const std::string& passphrase, _pImpl(new CipherKeyImpl(name, passphrase, salt, iterationCount))
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, }
const ByteVec& key,
const ByteVec& iv):
_pImpl(new CipherKeyImpl(name, key, iv)) CipherKey::CipherKey(const std::string& name):
{ _pImpl(new CipherKeyImpl(name))
} {
}
CipherKey::CipherKey(const std::string& name):
_pImpl(new CipherKeyImpl(name)) CipherKey::~CipherKey()
{ {
} }
CipherKey::~CipherKey() } } // namespace Poco::Crypto
{
}
} } // namespace Poco::Crypto

View File

@@ -1,218 +1,218 @@
// //
// CipherKeyImpl.cpp // CipherKeyImpl.cpp
// //
// $Id: //poco/Main/Crypto/src/CipherKeyImpl.cpp#3 $ // $Id: //poco/1.4/Crypto/src/CipherKeyImpl.cpp#1 $
// //
// Library: Crypto // Library: Crypto
// Package: Cipher // Package: Cipher
// Module: CipherKeyImpl // Module: CipherKeyImpl
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Crypto/CipherKeyImpl.h" #include "Poco/Crypto/CipherKeyImpl.h"
#include "Poco/Crypto/CryptoTransform.h" #include "Poco/Crypto/CryptoTransform.h"
#include "Poco/Crypto/CipherFactory.h" #include "Poco/Crypto/CipherFactory.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/RandomStream.h" #include "Poco/RandomStream.h"
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/evp.h> #include <openssl/evp.h>
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
CipherKeyImpl::CipherKeyImpl(const std::string& name, CipherKeyImpl::CipherKeyImpl(const std::string& name,
const std::string& passphrase, const std::string& passphrase,
const std::string& salt, const std::string& salt,
int iterationCount): int iterationCount):
_pCipher(0), _pCipher(0),
_name(name), _name(name),
_key(), _key(),
_iv() _iv()
{ {
// dummy access to Cipherfactory so that the EVP lib is initilaized // dummy access to Cipherfactory so that the EVP lib is initilaized
CipherFactory::defaultFactory(); CipherFactory::defaultFactory();
_pCipher = EVP_get_cipherbyname(name.c_str()); _pCipher = EVP_get_cipherbyname(name.c_str());
if (!_pCipher) if (!_pCipher)
throw Poco::NotFoundException("Cipher " + name + " was not found"); throw Poco::NotFoundException("Cipher " + name + " was not found");
_key = ByteVec(keySize()); _key = ByteVec(keySize());
_iv = ByteVec(ivSize()); _iv = ByteVec(ivSize());
generateKey(passphrase, salt, iterationCount); generateKey(passphrase, salt, iterationCount);
} }
CipherKeyImpl::CipherKeyImpl(const std::string& name, CipherKeyImpl::CipherKeyImpl(const std::string& name,
const ByteVec& key, const ByteVec& key,
const ByteVec& iv): const ByteVec& iv):
_pCipher(0), _pCipher(0),
_name(name), _name(name),
_key(key), _key(key),
_iv(iv) _iv(iv)
{ {
// dummy access to Cipherfactory so that the EVP lib is initilaized // dummy access to Cipherfactory so that the EVP lib is initilaized
CipherFactory::defaultFactory(); CipherFactory::defaultFactory();
_pCipher = EVP_get_cipherbyname(name.c_str()); _pCipher = EVP_get_cipherbyname(name.c_str());
if (!_pCipher) if (!_pCipher)
throw Poco::NotFoundException("Cipher " + name + " was not found"); throw Poco::NotFoundException("Cipher " + name + " was not found");
} }
CipherKeyImpl::CipherKeyImpl(const std::string& name): CipherKeyImpl::CipherKeyImpl(const std::string& name):
_pCipher(0), _pCipher(0),
_name(name), _name(name),
_key(), _key(),
_iv() _iv()
{ {
// dummy access to Cipherfactory so that the EVP lib is initilaized // dummy access to Cipherfactory so that the EVP lib is initilaized
CipherFactory::defaultFactory(); CipherFactory::defaultFactory();
_pCipher = EVP_get_cipherbyname(name.c_str()); _pCipher = EVP_get_cipherbyname(name.c_str());
if (!_pCipher) if (!_pCipher)
throw Poco::NotFoundException("Cipher " + name + " was not found"); throw Poco::NotFoundException("Cipher " + name + " was not found");
_key = ByteVec(keySize()); _key = ByteVec(keySize());
_iv = ByteVec(ivSize()); _iv = ByteVec(ivSize());
generateKey(); generateKey();
} }
CipherKeyImpl::~CipherKeyImpl() CipherKeyImpl::~CipherKeyImpl()
{ {
} }
CipherKeyImpl::Mode CipherKeyImpl::mode() const CipherKeyImpl::Mode CipherKeyImpl::mode() const
{ {
switch (EVP_CIPHER_mode(_pCipher)) switch (EVP_CIPHER_mode(_pCipher))
{ {
case EVP_CIPH_STREAM_CIPHER: case EVP_CIPH_STREAM_CIPHER:
return MODE_STREAM_CIPHER; return MODE_STREAM_CIPHER;
case EVP_CIPH_ECB_MODE: case EVP_CIPH_ECB_MODE:
return MODE_ECB; return MODE_ECB;
case EVP_CIPH_CBC_MODE: case EVP_CIPH_CBC_MODE:
return MODE_CBC; return MODE_CBC;
case EVP_CIPH_CFB_MODE: case EVP_CIPH_CFB_MODE:
return MODE_CFB; return MODE_CFB;
case EVP_CIPH_OFB_MODE: case EVP_CIPH_OFB_MODE:
return MODE_OFB; return MODE_OFB;
} }
throw Poco::IllegalStateException("Unexpected value of EVP_CIPHER_mode()"); throw Poco::IllegalStateException("Unexpected value of EVP_CIPHER_mode()");
} }
void CipherKeyImpl::generateKey() void CipherKeyImpl::generateKey()
{ {
ByteVec vec; ByteVec vec;
getRandomBytes(vec, keySize()); getRandomBytes(vec, keySize());
setKey(vec); setKey(vec);
getRandomBytes(vec, ivSize()); getRandomBytes(vec, ivSize());
setIV(vec); setIV(vec);
} }
void CipherKeyImpl::getRandomBytes(ByteVec& vec, std::size_t count) void CipherKeyImpl::getRandomBytes(ByteVec& vec, std::size_t count)
{ {
Poco::RandomInputStream random; Poco::RandomInputStream random;
vec.clear(); vec.clear();
vec.reserve(count); vec.reserve(count);
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
vec.push_back(static_cast<unsigned char>(random.get())); vec.push_back(static_cast<unsigned char>(random.get()));
} }
void CipherKeyImpl::generateKey( void CipherKeyImpl::generateKey(
const std::string& password, const std::string& password,
const std::string& salt, const std::string& salt,
int iterationCount) int iterationCount)
{ {
unsigned char keyBytes[EVP_MAX_KEY_LENGTH]; unsigned char keyBytes[EVP_MAX_KEY_LENGTH];
unsigned char ivBytes[EVP_MAX_IV_LENGTH]; unsigned char ivBytes[EVP_MAX_IV_LENGTH];
// OpenSSL documentation specifies that the salt must be an 8-byte array. // OpenSSL documentation specifies that the salt must be an 8-byte array.
unsigned char saltBytes[8]; unsigned char saltBytes[8];
if (!salt.empty()) if (!salt.empty())
{ {
int len = static_cast<int>(salt.size()); int len = static_cast<int>(salt.size());
// Create the salt array from the salt string // Create the salt array from the salt string
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
saltBytes[i] = salt.at(i % len); saltBytes[i] = salt.at(i % len);
for (int i = 8; i < len; ++i) for (int i = 8; i < len; ++i)
saltBytes[i % 8] ^= salt.at(i); saltBytes[i % 8] ^= salt.at(i);
} }
// Now create the key and IV, using the MD5 digest algorithm. // Now create the key and IV, using the MD5 digest algorithm.
int keySize = EVP_BytesToKey( int keySize = EVP_BytesToKey(
_pCipher, _pCipher,
EVP_md5(), EVP_md5(),
(salt.empty() ? 0 : saltBytes), (salt.empty() ? 0 : saltBytes),
reinterpret_cast<const unsigned char*>(password.data()), reinterpret_cast<const unsigned char*>(password.data()),
static_cast<int>(password.size()), static_cast<int>(password.size()),
iterationCount, iterationCount,
keyBytes, keyBytes,
ivBytes); ivBytes);
// Copy the buffers to our member byte vectors. // Copy the buffers to our member byte vectors.
_key.assign(keyBytes, keyBytes + keySize); _key.assign(keyBytes, keyBytes + keySize);
if (ivSize() == 0) if (ivSize() == 0)
_iv.clear(); _iv.clear();
else else
_iv.assign(ivBytes, ivBytes + ivSize()); _iv.assign(ivBytes, ivBytes + ivSize());
} }
int CipherKeyImpl::keySize() const int CipherKeyImpl::keySize() const
{ {
return EVP_CIPHER_key_length(_pCipher); return EVP_CIPHER_key_length(_pCipher);
} }
int CipherKeyImpl::blockSize() const int CipherKeyImpl::blockSize() const
{ {
return EVP_CIPHER_block_size(_pCipher); return EVP_CIPHER_block_size(_pCipher);
} }
int CipherKeyImpl::ivSize() const int CipherKeyImpl::ivSize() const
{ {
return EVP_CIPHER_iv_length(_pCipher); return EVP_CIPHER_iv_length(_pCipher);
} }
} } // namespace Poco::Crypto } } // namespace Poco::Crypto

View File

@@ -54,35 +54,29 @@ namespace Crypto {
// //
CryptoStreamBuf::CryptoStreamBuf( CryptoStreamBuf::CryptoStreamBuf(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize):
std::istream& istr, Poco::BufferedStreamBuf(bufferSize, std::ios::in),
CryptoTransform* pTransform, _pTransform(pTransform),
std::streamsize bufferSize) : _pIstr(&istr),
Poco::BufferedStreamBuf(bufferSize, std::ios::in), _pOstr(0),
_pTransform(pTransform), _eof(false),
_pIstr(&istr), _buffer(static_cast<std::size_t>(bufferSize))
_pOstr(0),
_eof(false),
_buffer(bufferSize)
{ {
poco_check_ptr(pTransform); poco_check_ptr (pTransform);
poco_assert(bufferSize >= 2 * pTransform->blockSize()); poco_assert (bufferSize > 2 * pTransform->blockSize());
} }
CryptoStreamBuf::CryptoStreamBuf( CryptoStreamBuf::CryptoStreamBuf(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize):
std::ostream& ostr, Poco::BufferedStreamBuf(bufferSize, std::ios::out),
CryptoTransform* pTransform, _pTransform(pTransform),
std::streamsize bufferSize) : _pIstr(0),
Poco::BufferedStreamBuf(bufferSize, std::ios::out), _pOstr(&ostr),
_pTransform(pTransform), _eof(false),
_pIstr(0), _buffer(static_cast<std::size_t>(bufferSize))
_pOstr(&ostr),
_eof(false),
_buffer(bufferSize)
{ {
poco_check_ptr(pTransform); poco_check_ptr (pTransform);
poco_assert(bufferSize >= 2 * pTransform->blockSize()); poco_assert (bufferSize > 2 * pTransform->blockSize());
} }
@@ -116,7 +110,7 @@ void CryptoStreamBuf::close()
_pOstr = 0; _pOstr = 0;
// Finalize transformation. // 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) if (n > 0)
{ {
@@ -137,12 +131,12 @@ int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length)
while (!_eof) 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 // Make sure we can read at least one more block. Explicitely check
// for m < 0 since blockSize() returns an unsigned int and the // for m < 0 since blockSize() returns an unsigned int and the
// comparison might give fals results for m < 0. // comparison might give false results for m < 0.
if (m < 0 || m < _pTransform->blockSize()) if (m <= 0)
break; break;
int n = 0; int n = 0;
@@ -158,18 +152,18 @@ int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length)
_eof = true; _eof = true;
// No more data, finalize transformation // No more data, finalize transformation
count += _pTransform->finalize( count += static_cast<int>(_pTransform->finalize(
reinterpret_cast<unsigned char*>(buffer + count), reinterpret_cast<unsigned char*>(buffer + count),
length - count); static_cast<int>(length) - count));
} }
else else
{ {
// Transform next chunk of data // Transform next chunk of data
count += _pTransform->transform( count += static_cast<int>(_pTransform->transform(
_buffer.begin(), _buffer.begin(),
n, n,
reinterpret_cast<unsigned char*>(buffer + count), 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) if (!_pOstr)
return 0; return 0;
std::size_t maxChunkSize = _buffer.size() - (_pTransform->blockSize() - 1); std::size_t maxChunkSize = _buffer.size()/2;
std::size_t count = 0; std::size_t count = 0;
while (count < length) while (count < length)
{ {
// Truncate chunk size so that the maximum output fits into _buffer. // 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) if (n > maxChunkSize)
n = maxChunkSize; n = maxChunkSize;
// Transform next chunk of data // Transform next chunk of data
int k = _pTransform->transform( std::streamsize k = _pTransform->transform(
reinterpret_cast<const unsigned char*>(buffer + count), reinterpret_cast<const unsigned char*>(buffer + count),
static_cast<std::streamsize>(n), static_cast<std::streamsize>(n),
_buffer.begin(), _buffer.begin(),
@@ -221,21 +215,15 @@ int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
// //
CryptoIOS::CryptoIOS( CryptoIOS::CryptoIOS(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize):
std::istream& istr, _buf(istr, pTransform, bufferSize)
CryptoTransform* pTransform,
std::streamsize bufferSize) :
_buf(istr, pTransform, bufferSize)
{ {
poco_ios_init(&_buf); poco_ios_init(&_buf);
} }
CryptoIOS::CryptoIOS( CryptoIOS::CryptoIOS(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize):
std::ostream& ostr, _buf(ostr, pTransform, bufferSize)
CryptoTransform* pTransform,
std::streamsize bufferSize) :
_buf(ostr, pTransform, bufferSize)
{ {
poco_ios_init(&_buf); poco_ios_init(&_buf);
} }
@@ -257,22 +245,16 @@ CryptoStreamBuf* CryptoIOS::rdbuf()
// //
CryptoInputStream::CryptoInputStream( CryptoInputStream::CryptoInputStream(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize):
std::istream& istr, CryptoIOS(istr, pTransform, bufferSize),
CryptoTransform* pTransform, std::istream(&_buf)
std::streamsize bufferSize) :
CryptoIOS(istr, pTransform, bufferSize),
std::istream(&_buf)
{ {
} }
CryptoInputStream::CryptoInputStream( CryptoInputStream::CryptoInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize):
std::istream& istr, CryptoIOS(istr, cipher.createEncryptor(), bufferSize),
Cipher& cipher, std::istream(&_buf)
std::streamsize bufferSize) :
CryptoIOS(istr, cipher.createEncryptor(), bufferSize),
std::istream(&_buf)
{ {
} }
@@ -287,22 +269,16 @@ CryptoInputStream::~CryptoInputStream()
// //
CryptoOutputStream::CryptoOutputStream( CryptoOutputStream::CryptoOutputStream(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize):
std::ostream& ostr, CryptoIOS(ostr, pTransform, bufferSize),
CryptoTransform* pTransform, std::ostream(&_buf)
std::streamsize bufferSize) :
CryptoIOS(ostr, pTransform, bufferSize),
std::ostream(&_buf)
{ {
} }
CryptoOutputStream::CryptoOutputStream( CryptoOutputStream::CryptoOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize):
std::ostream& ostr, CryptoIOS(ostr, cipher.createDecryptor(), bufferSize),
Cipher& cipher, std::ostream(&_buf)
std::streamsize bufferSize):
CryptoIOS(ostr, cipher.createDecryptor(), bufferSize),
std::ostream(&_buf)
{ {
} }
@@ -314,7 +290,87 @@ CryptoOutputStream::~CryptoOutputStream()
void CryptoOutputStream::close() 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();
} }

View File

@@ -1,150 +1,172 @@
// //
// OpenSSLInitializer.cpp // OpenSSLInitializer.cpp
// //
// $Id: //poco/Main/Crypto/src/OpenSSLInitializer.cpp#1 $ // $Id: //poco/1.4/Crypto/src/OpenSSLInitializer.cpp#1 $
// //
// Library: Crypto // Library: Crypto
// Package: CryotpCore // Package: CryotpCore
// Module: OpenSSLInitializer // Module: OpenSSLInitializer
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Crypto/OpenSSLInitializer.h" #include "Poco/Crypto/OpenSSLInitializer.h"
#include "Poco/RandomStream.h" #include "Poco/RandomStream.h"
#include "Poco/Thread.h" #include "Poco/Thread.h"
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/err.h> #include <openssl/err.h>
#if SSLEAY_VERSION_NUMBER >= 0x0907000L
#include <openssl/conf.h>
using Poco::RandomInputStream; #endif
using Poco::Thread;
using Poco::FastMutex;
using Poco::RandomInputStream;
using Poco::Thread;
namespace Poco {
namespace Crypto {
namespace Poco {
namespace Crypto {
FastMutex* OpenSSLInitializer::_mutexes(0);
int OpenSSLInitializer::_rc(0);
Poco::FastMutex* OpenSSLInitializer::_mutexes(0);
Poco::FastMutex OpenSSLInitializer::_mutex;
static OpenSSLInitializer initializer; int OpenSSLInitializer::_rc(0);
OpenSSLInitializer::OpenSSLInitializer() OpenSSLInitializer::OpenSSLInitializer()
{ {
initialize(); initialize();
} }
OpenSSLInitializer::~OpenSSLInitializer() OpenSSLInitializer::~OpenSSLInitializer()
{ {
uninitialize(); uninitialize();
} }
void OpenSSLInitializer::initialize() void OpenSSLInitializer::initialize()
{ {
if (++_rc == 1) Poco::FastMutex::ScopedLock lock(_mutex);
{
poco_assert (1 == SSL_library_init()); // always returns 1 if (++_rc == 1)
SSL_load_error_strings(); {
#if OPENSSL_VERSION_NUMBER >= 0x0907000L
char seed[SEEDSIZE]; OPENSSL_config(NULL);
RandomInputStream rnd; #endif
rnd.read(seed, sizeof(seed)); SSL_library_init();
RAND_seed(seed, SEEDSIZE); SSL_load_error_strings();
OpenSSL_add_all_algorithms();
int nMutexes = CRYPTO_num_locks();
_mutexes = new FastMutex[nMutexes]; char seed[SEEDSIZE];
CRYPTO_set_locking_callback(&OpenSSLInitializer::lock); RandomInputStream rnd;
#ifndef POCO_OS_FAMILY_WINDOWS // SF# 1828231: random unhandled exceptions when linking with ssl rnd.read(seed, sizeof(seed));
CRYPTO_set_id_callback(&OpenSSLInitializer::id); RAND_seed(seed, SEEDSIZE);
#endif
CRYPTO_set_dynlock_create_callback(&OpenSSLInitializer::dynlockCreate); int nMutexes = CRYPTO_num_locks();
CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock); _mutexes = new Poco::FastMutex[nMutexes];
CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy); 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);
void OpenSSLInitializer::uninitialize() CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock);
{ CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy);
if (--_rc == 0) }
{ }
EVP_cleanup();
ERR_free_strings();
CRYPTO_set_locking_callback(0); void OpenSSLInitializer::uninitialize()
delete [] _mutexes; {
} Poco::FastMutex::ScopedLock lock(_mutex);
}
if (--_rc == 0)
{
void OpenSSLInitializer::lock(int mode, int n, const char* file, int line) EVP_cleanup();
{ ERR_free_strings();
if (mode & CRYPTO_LOCK) CRYPTO_set_locking_callback(0);
_mutexes[n].lock(); delete [] _mutexes;
else }
_mutexes[n].unlock(); }
}
void OpenSSLInitializer::lock(int mode, int n, const char* file, int line)
unsigned long OpenSSLInitializer::id() {
{ if (mode & CRYPTO_LOCK)
Thread* pThread = Thread::current(); _mutexes[n].lock();
return pThread ? pThread->id() : 0; else
} _mutexes[n].unlock();
}
struct CRYPTO_dynlock_value* OpenSSLInitializer::dynlockCreate(const char* file, int line)
{ unsigned long OpenSSLInitializer::id()
return new CRYPTO_dynlock_value; {
} // Note: we use an old-style C cast here because
// neither static_cast<> nor reinterpret_cast<>
// work uniformly across all platforms.
void OpenSSLInitializer::dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line) return (unsigned long) Poco::Thread::currentTid();
{ }
poco_check_ptr (lock);
if (mode & CRYPTO_LOCK) struct CRYPTO_dynlock_value* OpenSSLInitializer::dynlockCreate(const char* file, int line)
lock->_mutex.lock(); {
else return new CRYPTO_dynlock_value;
lock->_mutex.unlock(); }
}
void OpenSSLInitializer::dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line)
void OpenSSLInitializer::dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line) {
{ poco_check_ptr (lock);
delete lock;
} if (mode & CRYPTO_LOCK)
lock->_mutex.lock();
else
} } // namespace Poco::Crypto 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

View File

@@ -1,333 +1,340 @@
// //
// RSACipherImpl.cpp // RSACipherImpl.cpp
// //
// $Id: //poco/Main/Crypto/src/RSACipherImpl.cpp#2 $ // $Id: //poco/1.4/Crypto/src/RSACipherImpl.cpp#1 $
// //
// Library: Crypto // Library: Crypto
// Package: RSA // Package: RSA
// Module: RSACipherImpl // Module: RSACipherImpl
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Crypto/RSACipherImpl.h" #include "Poco/Crypto/RSACipherImpl.h"
#include "Poco/Crypto/CryptoTransform.h" #include "Poco/Crypto/CryptoTransform.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/rsa.h> #include <openssl/rsa.h>
#include <cstring> #include <cstring>
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
namespace namespace
{ {
void throwError() void throwError()
{ {
unsigned long err; unsigned long err;
std::string msg; std::string msg;
while ((err = ERR_get_error())) while ((err = ERR_get_error()))
{ {
if (!msg.empty()) if (!msg.empty())
msg.append("; "); msg.append("; ");
msg.append(ERR_error_string(err, 0)); msg.append(ERR_error_string(err, 0));
} }
throw Poco::IOException(msg); throw Poco::IOException(msg);
} }
int mapPaddingMode(RSAPaddingMode paddingMode) int mapPaddingMode(RSAPaddingMode paddingMode)
{ {
switch (paddingMode) switch (paddingMode)
{ {
case RSA_PADDING_PKCS1: case RSA_PADDING_PKCS1:
return RSA_PKCS1_PADDING; return RSA_PKCS1_PADDING;
case RSA_PADDING_PKCS1_OAEP: case RSA_PADDING_PKCS1_OAEP:
return RSA_PKCS1_OAEP_PADDING; return RSA_PKCS1_OAEP_PADDING;
case RSA_PADDING_SSLV23: case RSA_PADDING_SSLV23:
return RSA_SSLV23_PADDING; return RSA_SSLV23_PADDING;
case RSA_PADDING_NONE: case RSA_PADDING_NONE:
return RSA_NO_PADDING; return RSA_NO_PADDING;
default: default:
poco_bugcheck(); poco_bugcheck();
return RSA_NO_PADDING; return RSA_NO_PADDING;
} }
} }
class RSAEncryptImpl: public CryptoTransform class RSAEncryptImpl: public CryptoTransform
{ {
public: public:
enum RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode);
{ ~RSAEncryptImpl();
OVERFLOW = 11
}; std::size_t blockSize() const;
std::size_t maxDataSize() const;
RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode);
~RSAEncryptImpl(); std::streamsize transform(
const unsigned char* input,
std::size_t blockSize() const; std::streamsize inputLength,
unsigned char* output,
std::streamsize transform( std::streamsize outputLength);
const unsigned char* input,
std::streamsize inputLength, std::streamsize finalize(unsigned char* output, std::streamsize length);
unsigned char* output,
std::streamsize outputLength); private:
const RSA* _pRSA;
std::streamsize finalize(unsigned char* output, std::streamsize length); RSAPaddingMode _paddingMode;
std::streamsize _pos;
private: unsigned char* _pBuf;
const RSA* _pRSA; };
RSAPaddingMode _paddingMode;
std::streamsize _pos;
unsigned char* _pBuf; RSAEncryptImpl::RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode):
}; _pRSA(pRSA),
_paddingMode(paddingMode),
_pos(0),
RSAEncryptImpl::RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode): _pBuf(0)
_pRSA(pRSA), {
_paddingMode(paddingMode), _pBuf = new unsigned char[blockSize()];
_pos(0), }
_pBuf(0)
{
_pBuf = new unsigned char[blockSize()]; RSAEncryptImpl::~RSAEncryptImpl()
} {
delete [] _pBuf;
}
RSAEncryptImpl::~RSAEncryptImpl()
{
delete _pBuf; std::size_t RSAEncryptImpl::blockSize() const
} {
return RSA_size(_pRSA);
}
std::size_t RSAEncryptImpl::blockSize() const
{
return RSA_size(_pRSA); std::size_t RSAEncryptImpl::maxDataSize() const
} {
std::size_t size = blockSize();
switch (_paddingMode)
std::streamsize RSAEncryptImpl::transform( {
const unsigned char* input, case RSA_PADDING_PKCS1:
std::streamsize inputLength, case RSA_PADDING_SSLV23:
unsigned char* output, size -= 11;
std::streamsize outputLength) break;
{ case RSA_PADDING_PKCS1_OAEP:
// always fill up the buffer before writing! size -= 41;
std::streamsize rsaSize = static_cast<std::streamsize>(blockSize()); break;
poco_assert_dbg(_pos <= rsaSize); default:
poco_assert (outputLength >= rsaSize); break;
int rc = 0; }
while (inputLength > 0) return size;
{ }
// check how many data bytes we are missing to get the buffer full
poco_assert_dbg (rsaSize >= _pos);
std::streamsize missing = rsaSize - _pos; std::streamsize RSAEncryptImpl::transform(
if (missing == 0) const unsigned char* input,
{ std::streamsize inputLength,
poco_assert (outputLength >= rsaSize); unsigned char* output,
int tmp = RSA_public_encrypt(rsaSize, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_NO_PADDING); std::streamsize outputLength)
if (tmp == -1) {
throwError(); // always fill up the buffer before writing!
rc += tmp; std::streamsize maxSize = static_cast<std::streamsize>(maxDataSize());
output += tmp; std::streamsize rsaSize = static_cast<std::streamsize>(blockSize());
outputLength -= tmp; poco_assert_dbg(_pos <= maxSize);
_pos = 0; poco_assert (outputLength >= rsaSize);
int rc = 0;
} while (inputLength > 0)
else {
{ // check how many data bytes we are missing to get the buffer full
if (missing > inputLength) poco_assert_dbg (maxSize >= _pos);
missing = inputLength; std::streamsize missing = maxSize - _pos;
if (missing == 0)
std::memcpy(_pBuf+_pos, input, missing); {
input += missing; poco_assert (outputLength >= rsaSize);
_pos += missing; int n = RSA_public_encrypt(static_cast<int>(maxSize), _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
inputLength -= missing; if (n == -1)
} throwError();
} rc += n;
output += n;
return rc; outputLength -= n;
} _pos = 0;
}
std::streamsize RSAEncryptImpl::finalize(unsigned char* output, std::streamsize length) else
{ {
poco_assert (length >= blockSize()); if (missing > inputLength)
int rc = 0; missing = inputLength;
if (_pos > 0)
{ std::memcpy(_pBuf + _pos, input, static_cast<std::size_t>(missing));
rc = RSA_public_encrypt(_pos, _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode)); input += missing;
if (rc == -1) _pos += missing;
throwError(); inputLength -= missing;
} }
}
return rc; return rc;
} }
class RSADecryptImpl: public CryptoTransform std::streamsize RSAEncryptImpl::finalize(unsigned char* output, std::streamsize length)
{ {
public: poco_assert (length >= blockSize());
enum poco_assert (_pos <= maxDataSize());
{ int rc = 0;
OVERFLOW = 11 if (_pos > 0)
}; {
rc = RSA_public_encrypt(static_cast<int>(_pos), _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode); if (rc == -1) throwError();
~RSADecryptImpl(); }
return rc;
std::size_t blockSize() const; }
std::streamsize transform(
const unsigned char* input, class RSADecryptImpl: public CryptoTransform
std::streamsize inputLength, {
unsigned char* output, public:
std::streamsize outputLength); RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode);
~RSADecryptImpl();
std::streamsize finalize(
unsigned char* output, std::size_t blockSize() const;
std::streamsize length);
std::streamsize transform(
private: const unsigned char* input,
const RSA* _pRSA; std::streamsize inputLength,
RSAPaddingMode _paddingMode; unsigned char* output,
std::streamsize _pos; std::streamsize outputLength);
unsigned char* _pBuf;
}; std::streamsize finalize(
unsigned char* output,
std::streamsize length);
RSADecryptImpl::RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode):
_pRSA(pRSA), private:
_paddingMode(paddingMode), const RSA* _pRSA;
_pos(0), RSAPaddingMode _paddingMode;
_pBuf(0) std::streamsize _pos;
{ unsigned char* _pBuf;
_pBuf = new unsigned char[blockSize()]; };
}
RSADecryptImpl::RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode):
RSADecryptImpl::~RSADecryptImpl() _pRSA(pRSA),
{ _paddingMode(paddingMode),
delete _pBuf; _pos(0),
} _pBuf(0)
{
_pBuf = new unsigned char[blockSize()];
std::size_t RSADecryptImpl::blockSize() const }
{
return RSA_size(_pRSA);
} RSADecryptImpl::~RSADecryptImpl()
{
delete [] _pBuf;
std::streamsize RSADecryptImpl::transform( }
const unsigned char* input,
std::streamsize inputLength,
unsigned char* output, std::size_t RSADecryptImpl::blockSize() const
std::streamsize outputLength) {
{ return RSA_size(_pRSA);
}
// always fill up the buffer before decrypting!
std::streamsize rsaSize = static_cast<std::streamsize>(blockSize());
poco_assert_dbg(_pos <= rsaSize); std::streamsize RSADecryptImpl::transform(
poco_assert (outputLength >= rsaSize); const unsigned char* input,
int rc = 0; std::streamsize inputLength,
while (inputLength > 0) unsigned char* output,
{ std::streamsize outputLength)
// check how many data bytes we are missing to get the buffer full {
poco_assert_dbg (rsaSize >= _pos);
std::streamsize missing = rsaSize - _pos; // always fill up the buffer before decrypting!
if (missing == 0) std::streamsize rsaSize = static_cast<std::streamsize>(blockSize());
{ poco_assert_dbg(_pos <= rsaSize);
int tmp = RSA_private_decrypt(rsaSize, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_NO_PADDING); poco_assert (outputLength >= rsaSize);
if (tmp == -1) int rc = 0;
throwError(); while (inputLength > 0)
rc += tmp; {
output += tmp; // check how many data bytes we are missing to get the buffer full
outputLength -= tmp; poco_assert_dbg (rsaSize >= _pos);
_pos = 0; std::streamsize missing = rsaSize - _pos;
if (missing == 0)
} {
else int tmp = RSA_private_decrypt(static_cast<int>(rsaSize), _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
{ if (tmp == -1)
if (missing > inputLength) throwError();
missing = inputLength; rc += tmp;
output += tmp;
std::memcpy(_pBuf+_pos, input, missing); outputLength -= tmp;
input += missing; _pos = 0;
_pos += missing;
inputLength -= missing; }
} else
} {
if (missing > inputLength)
return rc; missing = inputLength;
}
std::memcpy(_pBuf + _pos, input, static_cast<std::size_t>(missing));
input += missing;
std::streamsize RSADecryptImpl::finalize(unsigned char* output, std::streamsize length) _pos += missing;
{ inputLength -= missing;
poco_assert (length >= blockSize()); }
int rc = 0; }
if (_pos > 0) return rc;
{ }
rc = RSA_private_decrypt(_pos, _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
if (rc == -1)
throwError(); std::streamsize RSADecryptImpl::finalize(unsigned char* output, std::streamsize length)
} {
poco_assert (length >= blockSize());
return rc; 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)
RSACipherImpl::RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode): throwError();
_key(key), }
_paddingMode(paddingMode) return rc;
{ }
} }
RSACipherImpl::~RSACipherImpl() RSACipherImpl::RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode):
{ _key(key),
} _paddingMode(paddingMode)
{
}
CryptoTransform* RSACipherImpl::createEncryptor()
{
return new RSAEncryptImpl(_key.impl()->getRSA(), _paddingMode); RSACipherImpl::~RSACipherImpl()
} {
}
CryptoTransform* RSACipherImpl::createDecryptor()
{ CryptoTransform* RSACipherImpl::createEncryptor()
return new RSADecryptImpl(_key.impl()->getRSA(), _paddingMode); {
} return new RSAEncryptImpl(_key.impl()->getRSA(), _paddingMode);
}
} } // namespace Poco::Crypto
CryptoTransform* RSACipherImpl::createDecryptor()
{
return new RSADecryptImpl(_key.impl()->getRSA(), _paddingMode);
}
} } // namespace Poco::Crypto

View File

@@ -1,113 +1,113 @@
// //
// RSADigestEngine.cpp // RSADigestEngine.cpp
// //
// $Id: //poco/Main/Crypto/src/RSADigestEngine.cpp#3 $ // $Id: //poco/1.4/Crypto/src/RSADigestEngine.cpp#1 $
// //
// Library: Crypto // Library: Crypto
// Package: RSA // Package: RSA
// Module: RSADigestEngine // Module: RSADigestEngine
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Crypto/RSADigestEngine.h" #include "Poco/Crypto/RSADigestEngine.h"
#include <openssl/pem.h> #include <openssl/pem.h>
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
RSADigestEngine::RSADigestEngine(const RSAKey& key, DigestType digestType): RSADigestEngine::RSADigestEngine(const RSAKey& key, DigestType digestType):
_key(key), _key(key),
_engine(digestType == DIGEST_MD5 ? static_cast<Poco::DigestEngine&>(_md5Engine) : static_cast<Poco::DigestEngine&>(_sha1Engine)), _engine(digestType == DIGEST_MD5 ? static_cast<Poco::DigestEngine&>(_md5Engine) : static_cast<Poco::DigestEngine&>(_sha1Engine)),
_type(digestType == DIGEST_MD5 ? NID_md5 : NID_sha1) _type(digestType == DIGEST_MD5 ? NID_md5 : NID_sha1)
{ {
} }
RSADigestEngine::~RSADigestEngine() RSADigestEngine::~RSADigestEngine()
{ {
} }
unsigned RSADigestEngine::digestLength() const unsigned RSADigestEngine::digestLength() const
{ {
return _engine.digestLength(); return _engine.digestLength();
} }
void RSADigestEngine::reset() void RSADigestEngine::reset()
{ {
_engine.reset(); _engine.reset();
_digest.clear(); _digest.clear();
_signature.clear(); _signature.clear();
} }
const DigestEngine::Digest& RSADigestEngine::digest() const DigestEngine::Digest& RSADigestEngine::digest()
{ {
if (_digest.empty()) if (_digest.empty())
{ {
_digest = _engine.digest(); _digest = _engine.digest();
} }
return _digest; return _digest;
} }
const DigestEngine::Digest& RSADigestEngine::signature() const DigestEngine::Digest& RSADigestEngine::signature()
{ {
if (_signature.empty()) if (_signature.empty())
{ {
digest(); digest();
_signature.resize(_key.size()); _signature.resize(_key.size());
unsigned sigLen = static_cast<unsigned>(_signature.size()); unsigned sigLen = static_cast<unsigned>(_signature.size());
RSA_sign(_type, &_digest[0], static_cast<unsigned>(_digest.size()), &_signature[0], &sigLen, _key.impl()->getRSA()); RSA_sign(_type, &_digest[0], static_cast<unsigned>(_digest.size()), &_signature[0], &sigLen, _key.impl()->getRSA());
// truncate _sig to sigLen // truncate _sig to sigLen
if (sigLen < _signature.size()) if (sigLen < _signature.size())
_signature.resize(sigLen); _signature.resize(sigLen);
} }
return _signature; return _signature;
} }
bool RSADigestEngine::verify(const DigestEngine::Digest& sig) bool RSADigestEngine::verify(const DigestEngine::Digest& sig)
{ {
digest(); digest();
DigestEngine::Digest sigCpy = sig; // copy becausse RSA_verify can modify sigCpy 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()); 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; return ret != 0;
} }
void RSADigestEngine::updateImpl(const void* data, unsigned length) void RSADigestEngine::updateImpl(const void* data, unsigned length)
{ {
_engine.update(data, length); _engine.update(data, length);
} }
} } // namespace Poco::Crypto } } // namespace Poco::Crypto

View File

@@ -1,104 +1,127 @@
// //
// RSAKey.cpp // RSAKey.cpp
// //
// $Id: //poco/Main/Crypto/src/RSAKey.cpp#4 $ // $Id: //poco/1.4/Crypto/src/RSAKey.cpp#1 $
// //
// Library: Crypto // Library: Crypto
// Package: RSA // Package: RSA
// Module: RSAKey // Module: RSAKey
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Crypto/RSAKey.h" #include "Poco/Crypto/RSAKey.h"
#include <openssl/rsa.h> #include <openssl/rsa.h>
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
RSAKey::RSAKey(const X509Certificate& cert): RSAKey::RSAKey(const X509Certificate& cert):
_pImpl(new RSAKeyImpl(cert)) _pImpl(new RSAKeyImpl(cert))
{ {
} }
RSAKey::RSAKey(KeyLength keyLength, Exponent exp): RSAKey::RSAKey(KeyLength keyLength, Exponent exp):
_pImpl(0) _pImpl(0)
{ {
int keyLen = keyLength; int keyLen = keyLength;
unsigned long expVal = RSA_3; unsigned long expVal = RSA_3;
if (expVal == EXP_LARGE) if (exp == EXP_LARGE)
expVal = RSA_F4; expVal = RSA_F4;
_pImpl = new RSAKeyImpl(keyLen, expVal); _pImpl = new RSAKeyImpl(keyLen, expVal);
} }
RSAKey::RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase): RSAKey::RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase):
_pImpl(new RSAKeyImpl(publicKeyFile, privateKeyFile, privateKeyPassphrase)) _pImpl(new RSAKeyImpl(publicKeyFile, privateKeyFile, privateKeyPassphrase))
{ {
} }
RSAKey::RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase): RSAKey::RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
_pImpl(new RSAKeyImpl(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase)) _pImpl(new RSAKeyImpl(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase))
{ {
} }
RSAKey::~RSAKey() RSAKey::~RSAKey()
{ {
} }
int RSAKey::size() const int RSAKey::size() const
{ {
return _pImpl->size(); return _pImpl->size();
} }
void RSAKey::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase) RSAKeyImpl::ByteVec RSAKey::modulus() const
{ {
_pImpl->save(publicKeyFile, privateKeyFile, privateKeyPassphrase); return _pImpl->modulus();
} }
void RSAKey::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase) RSAKeyImpl::ByteVec RSAKey::encryptionExponent() const
{ {
_pImpl->save(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase); return _pImpl->encryptionExponent();
} }
const std::string& RSAKey::name() const RSAKeyImpl::ByteVec RSAKey::decryptionExponent() const
{ {
static const std::string n("rsa"); return _pImpl->decryptionExponent();
return n; }
}
void RSAKey::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
} } // namespace Poco::Crypto {
_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

View File

@@ -1,291 +1,339 @@
// //
// RSAKeyImpl.cpp // RSAKeyImpl.cpp
// //
// $Id: //poco/Main/Crypto/src/RSAKeyImpl.cpp#3 $ // $Id: //poco/1.4/Crypto/src/RSAKeyImpl.cpp#1 $
// //
// Library: Crypto // Library: Crypto
// Package: RSA // Package: RSA
// Module: RSAKeyImpl // Module: RSAKeyImpl
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Crypto/RSAKeyImpl.h" #include "Poco/Crypto/RSAKeyImpl.h"
#include "Poco/Crypto/X509Certificate.h" #include "Poco/Crypto/X509Certificate.h"
#include "Poco/FileStream.h" #include "Poco/FileStream.h"
#include "Poco/StreamCopier.h" #include "Poco/StreamCopier.h"
#include "Poco/TemporaryFile.h" #include <sstream>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/rsa.h> #include <openssl/rsa.h>
#include <openssl/evp.h>
#if OPENSSL_VERSION_NUMBER >= 0x00908000L
namespace Poco { #include <openssl/bn.h>
namespace Crypto { #endif
RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert): namespace Poco {
_pRSA(0) namespace Crypto {
{
const X509* pCert = cert.certificate();
EVP_PKEY* pKey = X509_get_pubkey(const_cast<X509*>(pCert)); RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert):
_pRSA(0)
RSA* pRSA = pKey->pkey.rsa; {
_pRSA = RSAPublicKey_dup(pRSA); 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)
{ RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent):
#if OPENSSL_VERSION_NUMBER >= 0x00908000L _pRSA(0)
_pRSA = RSA_new(); {
int ret = 0; #if OPENSSL_VERSION_NUMBER >= 0x00908000L
BIGNUM* bn = 0; _pRSA = RSA_new();
try int ret = 0;
{ BIGNUM* bn = 0;
bn = BN_new(); try
BN_set_word(bn, exponent); {
ret = RSA_generate_key_ex(_pRSA, keyLength, bn, 0); bn = BN_new();
BN_free(bn); BN_set_word(bn, exponent);
} ret = RSA_generate_key_ex(_pRSA, keyLength, bn, 0);
catch (...) BN_free(bn);
{ }
BN_free(bn); catch (...)
throw; {
} BN_free(bn);
if (!ret) throw Poco::InvalidArgumentException("Failed to create RSA context"); throw;
#else }
_pRSA = RSA_generate_key(keyLength, exponent, 0, 0); if (!ret) throw Poco::InvalidArgumentException("Failed to create RSA context");
if (!_pRSA) throw Poco::InvalidArgumentException("Failed to create RSA context"); #else
#endif _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, RSAKeyImpl::RSAKeyImpl(
const std::string& privateKeyPassphrase): const std::string& publicKeyFile,
_pRSA(0) const std::string& privateKeyFile,
{ const std::string& privateKeyPassphrase):
init(publicKeyFile, privateKeyFile, privateKeyPassphrase); _pRSA(0)
} {
poco_assert_dbg(_pRSA == 0);
RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase): _pRSA = RSA_new();
_pRSA(0) if (!publicKeyFile.empty())
{ {
// due to C lib not supporting streams, we create two temporary files BIO* bio = BIO_new(BIO_s_file());
std::string publicKeyFile; if (!bio) throw Poco::IOException("Cannot create BIO for reading public key", publicKeyFile);
Poco::TemporaryFile pubFile; int rc = BIO_read_filename(bio, publicKeyFile.c_str());
if (pPublicKeyStream) if (rc)
{ {
if (!pubFile.createFile()) RSA* pubKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0);
throw Poco::CreateFileException("Cannot create temporary file for writing public key"); BIO_free(bio);
publicKeyFile = pubFile.path(); if (!pubKey)
Poco::FileOutputStream fout(publicKeyFile); {
Poco::StreamCopier::copyStream(*pPublicKeyStream, fout); freeRSA();
} throw Poco::FileException("Failed to load public key", publicKeyFile);
std::string privateKeyFile; }
Poco::TemporaryFile privFile; }
if (pPrivateKeyStream) else
{ {
if (!privFile.createFile()) freeRSA();
throw Poco::CreateFileException("Cannot create temporary file for writing private key"); throw Poco::FileNotFoundException("Public key file", publicKeyFile);
privateKeyFile = privFile.path(); }
Poco::FileOutputStream fout(privateKeyFile); }
Poco::StreamCopier::copyStream(*pPrivateKeyStream, fout);
if (!privateKeyFile.empty())
} {
init(publicKeyFile, privateKeyFile, privateKeyPassphrase); 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)
void RSAKeyImpl::init(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase) {
{ RSA* privKey = 0;
poco_assert_dbg(_pRSA == 0); if (privateKeyPassphrase.empty())
privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, 0);
_pRSA = RSA_new(); else
if (!publicKeyFile.empty()) privKey = PEM_read_bio_RSAPrivateKey(bio, &_pRSA, 0, const_cast<char*>(privateKeyPassphrase.c_str()));
{ BIO_free(bio);
BIO* out = BIO_new(BIO_s_file()); if (!privKey)
if (!out) throw Poco::IOException("Cannot create BIO for reading public key", publicKeyFile); {
int rc = BIO_read_filename(out, publicKeyFile.c_str()); freeRSA();
if (rc) throw Poco::FileException("Failed to load private key", privateKeyFile);
{ }
RSA* pubKey = PEM_read_bio_RSAPublicKey(out, &_pRSA, 0, 0); }
BIO_free(out); else
if (!pubKey) {
{ freeRSA();
freeRSA(); throw Poco::FileNotFoundException("Private key file", privateKeyFile);
throw Poco::FileException("Failed to load public key", publicKeyFile); }
} }
} }
else
{
freeRSA(); RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
throw Poco::FileNotFoundException("Public key file", publicKeyFile); _pRSA(0)
} {
} poco_assert_dbg(_pRSA == 0);
if (!privateKeyFile.empty()) _pRSA = RSA_new();
{ if (pPublicKeyStream)
BIO* out = BIO_new(BIO_s_file()); {
if (!out) throw Poco::IOException("Cannot create BIO for reading private key", privateKeyFile); std::string publicKeyData;
int rc = BIO_read_filename(out, privateKeyFile.c_str()); Poco::StreamCopier::copyToString(*pPublicKeyStream, publicKeyData);
if (rc) 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* privKey = 0; RSA* publicKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0);
if (privateKeyPassphrase.empty()) BIO_free(bio);
privKey = PEM_read_bio_RSAPrivateKey(out, &_pRSA, 0, 0); if (!publicKey)
else {
privKey = PEM_read_bio_RSAPrivateKey(out, &_pRSA, 0, const_cast<char*>(privateKeyPassphrase.c_str())); freeRSA();
BIO_free(out); throw Poco::FileException("Failed to load public key");
if (!privKey) }
{ }
freeRSA();
throw Poco::FileException("Failed to load private key", privateKeyFile); if (pPrivateKeyStream)
} {
} std::string privateKeyData;
else Poco::StreamCopier::copyToString(*pPrivateKeyStream, privateKeyData);
{ BIO* bio = BIO_new_mem_buf(const_cast<char*>(privateKeyData.data()), static_cast<int>(privateKeyData.size()));
freeRSA(); if (!bio) throw Poco::IOException("Cannot create BIO for reading private key");
throw Poco::FileNotFoundException("Private key file", privateKeyFile); 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);
RSAKeyImpl::~RSAKeyImpl() if (!privateKey)
{ {
freeRSA(); freeRSA();
} throw Poco::FileException("Failed to load private key");
}
}
void RSAKeyImpl::freeRSA() }
{
if (_pRSA)
RSA_free(_pRSA); RSAKeyImpl::~RSAKeyImpl()
_pRSA = 0; {
} freeRSA();
}
int RSAKeyImpl::size() const
{ void RSAKeyImpl::freeRSA()
return RSA_size(_pRSA); {
} if (_pRSA)
RSA_free(_pRSA);
_pRSA = 0;
void RSAKeyImpl::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase) }
{
if (!publicKeyFile.empty())
{ int RSAKeyImpl::size() const
BIO* out = BIO_new(BIO_s_file()); {
if (!out) throw Poco::IOException("Cannot create BIO for writing public key file", publicKeyFile); return RSA_size(_pRSA);
try }
{
if (BIO_write_filename(out, const_cast<char*>(publicKeyFile.c_str())))
{ RSAKeyImpl::ByteVec RSAKeyImpl::modulus() const
if (!PEM_write_bio_RSAPublicKey(out, _pRSA)) {
throw Poco::WriteFileException("Failed to write public key to file", publicKeyFile); return convertToByteVec(_pRSA->n);
} }
else throw Poco::CreateFileException("Cannot create public key file");
}
catch (...) RSAKeyImpl::ByteVec RSAKeyImpl::encryptionExponent() const
{ {
BIO_free(out); return convertToByteVec(_pRSA->e);
throw; }
}
BIO_free(out);
} RSAKeyImpl::ByteVec RSAKeyImpl::decryptionExponent() const
{
if (!privateKeyFile.empty()) return convertToByteVec(_pRSA->d);
{ }
BIO* out = BIO_new(BIO_s_file());
if (!out) throw Poco::IOException("Cannot create BIO for writing private key file", privateKeyFile);
try void RSAKeyImpl::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
{ {
if (BIO_write_filename(out, const_cast<char*>(privateKeyFile.c_str()))) if (!publicKeyFile.empty())
{ {
int rc = 0; BIO* bio = BIO_new(BIO_s_file());
if (privateKeyPassphrase.empty()) if (!bio) throw Poco::IOException("Cannot create BIO for writing public key file", publicKeyFile);
rc = PEM_write_bio_RSAPrivateKey(out, _pRSA, EVP_des_ede3_cbc(), 0, 0, 0, 0); try
else {
rc = PEM_write_bio_RSAPrivateKey(out, _pRSA, EVP_des_ede3_cbc(), if (BIO_write_filename(bio, const_cast<char*>(publicKeyFile.c_str())))
reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())), {
static_cast<int>(privateKeyPassphrase.length()), 0, 0); if (!PEM_write_bio_RSAPublicKey(bio, _pRSA))
if (!rc) throw Poco::FileException("Failed to write private key to file", privateKeyFile); throw Poco::WriteFileException("Failed to write public key to file", publicKeyFile);
} }
else throw Poco::CreateFileException("Cannot create private key file", privateKeyFile); else throw Poco::CreateFileException("Cannot create public key file");
} }
catch (...) catch (...)
{ {
BIO_free(out); BIO_free(bio);
throw; throw;
} }
BIO_free(out); BIO_free(bio);
} }
}
if (!privateKeyFile.empty())
{
void RSAKeyImpl::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase) BIO* bio = BIO_new(BIO_s_file());
{ if (!bio) throw Poco::IOException("Cannot create BIO for writing private key file", privateKeyFile);
if (!pPublicKeyStream && !pPrivateKeyStream) return; try
{
// due to C lib not supporting streams, we create two temporary files if (BIO_write_filename(bio, const_cast<char*>(privateKeyFile.c_str())))
std::string publicKeyFile; {
Poco::TemporaryFile pubFile; int rc = 0;
if (pPublicKeyStream) if (privateKeyPassphrase.empty())
{ rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(), 0, 0, 0, 0);
publicKeyFile = pubFile.path(); else
if (!pubFile.createFile()) rc = PEM_write_bio_RSAPrivateKey(bio, _pRSA, EVP_des_ede3_cbc(),
throw Poco::CreateFileException("Cannot create temporary public file"); reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())),
} static_cast<int>(privateKeyPassphrase.length()), 0, 0);
std::string privateKeyFile; if (!rc) throw Poco::FileException("Failed to write private key to file", privateKeyFile);
Poco::TemporaryFile privFile; }
if (pPrivateKeyStream) else throw Poco::CreateFileException("Cannot create private key file", privateKeyFile);
{ }
privateKeyFile = privFile.path(); catch (...)
if (!privFile.createFile()) {
throw Poco::FileException("Cannot crate temporary private key file"); BIO_free(bio);
} throw;
save(publicKeyFile, privateKeyFile, privateKeyPassphrase); }
BIO_free(bio);
// now copy everything from the temp files to the original streams }
if (pPublicKeyStream) }
{
Poco::FileInputStream istr(publicKeyFile);
Poco::StreamCopier::copyStream(istr, *pPublicKeyStream); void RSAKeyImpl::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase)
} {
if (pPrivateKeyStream) if (pPublicKeyStream)
{ {
Poco::FileInputStream istr(privateKeyFile); BIO* bio = BIO_new(BIO_s_mem());
Poco::StreamCopier::copyStream(istr, *pPrivateKeyStream); 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");
} } // namespace Poco::Crypto }
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

View File

@@ -1,290 +1,303 @@
// //
// X509Certificate.cpp // X509Certificate.cpp
// //
// $Id: //poco/Main/Crypto/src/X509Certificate.cpp#1 $ // $Id: //poco/1.4/Crypto/src/X509Certificate.cpp#1 $
// //
// Library: Crypto // Library: Crypto
// Package: Certificate // Package: Certificate
// Module: X509Certificate // Module: X509Certificate
// //
// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Crypto/X509Certificate.h" #include "Poco/Crypto/X509Certificate.h"
#include "Poco/StreamCopier.h" #include "Poco/StreamCopier.h"
#include "Poco/String.h" #include "Poco/String.h"
#include "Poco/DateTimeParser.h" #include "Poco/DateTimeParser.h"
#include <sstream> #include <sstream>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/evp.h> #include <openssl/evp.h>
namespace Poco { namespace Poco {
namespace Crypto { namespace Crypto {
X509Certificate::X509Certificate(std::istream& istr): X509Certificate::X509Certificate(std::istream& istr):
_pCert(0) _pCert(0)
{ {
load(istr); load(istr);
} }
X509Certificate::X509Certificate(const std::string& path): X509Certificate::X509Certificate(const std::string& path):
_pCert(0) _pCert(0)
{ {
load(path); load(path);
} }
X509Certificate::X509Certificate(X509* pCert): X509Certificate::X509Certificate(X509* pCert):
_pCert(pCert) _pCert(pCert)
{ {
poco_check_ptr(_pCert); poco_check_ptr(_pCert);
_pCert = X509_dup(_pCert); init();
init(); }
}
X509Certificate::X509Certificate(X509* pCert, bool shared):
X509Certificate::X509Certificate(const X509Certificate& cert): _pCert(pCert)
_issuerName(cert._issuerName), {
_subjectName(cert._subjectName), poco_check_ptr(_pCert);
_pCert(cert._pCert)
{ if (shared)
_pCert = X509_dup(_pCert); {
} _pCert->references++;
}
X509Certificate& X509Certificate::operator = (const X509Certificate& cert) init();
{ }
X509Certificate tmp(cert);
swap(tmp);
return *this; X509Certificate::X509Certificate(const X509Certificate& cert):
} _issuerName(cert._issuerName),
_subjectName(cert._subjectName),
_pCert(cert._pCert)
void X509Certificate::swap(X509Certificate& cert) {
{ _pCert = X509_dup(_pCert);
using std::swap; }
swap(cert._issuerName, _issuerName);
swap(cert._subjectName, _subjectName);
swap(cert._pCert, _pCert); X509Certificate& X509Certificate::operator = (const X509Certificate& cert)
} {
X509Certificate tmp(cert);
swap(tmp);
X509Certificate::~X509Certificate() return *this;
{ }
X509_free(_pCert);
}
void X509Certificate::swap(X509Certificate& cert)
{
void X509Certificate::load(std::istream& istr) using std::swap;
{ swap(cert._issuerName, _issuerName);
poco_assert (!_pCert); swap(cert._subjectName, _subjectName);
swap(cert._pCert, _pCert);
std::stringstream certStream; }
Poco::StreamCopier::copyStream(istr, certStream);
std::string cert = certStream.str();
X509Certificate::~X509Certificate()
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"); X509_free(_pCert);
_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0); }
BIO_free(pBIO);
if (!_pCert) throw Poco::IOException("Faild to load certificate from stream"); void X509Certificate::load(std::istream& istr)
{
init(); poco_assert (!_pCert);
}
std::stringstream certStream;
Poco::StreamCopier::copyStream(istr, certStream);
void X509Certificate::load(const std::string& path) std::string cert = certStream.str();
{
poco_assert (!_pCert); 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");
BIO *pBIO = BIO_new(BIO_s_file()); _pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate file", path); BIO_free(pBIO);
if (!BIO_read_filename(pBIO, path.c_str()))
{ if (!_pCert) throw Poco::IOException("Faild to load certificate from stream");
BIO_free(pBIO);
throw Poco::OpenFileException("Cannot open certificate file for reading", path); init();
} }
_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
BIO_free(pBIO); void X509Certificate::load(const std::string& path)
{
if (!_pCert) throw Poco::ReadFileException("Faild to load certificate from", path); poco_assert (!_pCert);
init(); 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()))
{
void X509Certificate::save(std::ostream& stream) const BIO_free(pBIO);
{ throw Poco::OpenFileException("Cannot open certificate file for reading", path);
BIO *pBIO = BIO_new(BIO_s_mem()); }
if (!pBIO) throw Poco::IOException("Cannot create BIO for writing certificate");
try _pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
{ BIO_free(pBIO);
if (!PEM_write_bio_X509(pBIO, _pCert))
throw Poco::IOException("Failed to write certificate to stream"); if (!_pCert) throw Poco::ReadFileException("Faild to load certificate from", path);
char *pData; init();
long size; }
size = BIO_get_mem_data(pBIO, &pData);
stream.write(pData, size);
} void X509Certificate::save(std::ostream& stream) const
catch (...) {
{ BIO *pBIO = BIO_new(BIO_s_mem());
BIO_free(pBIO); if (!pBIO) throw Poco::IOException("Cannot create BIO for writing certificate");
throw; try
} {
BIO_free(pBIO); if (!PEM_write_bio_X509(pBIO, _pCert))
} throw Poco::IOException("Failed to write certificate to stream");
char *pData;
void X509Certificate::save(const std::string& path) const long size;
{ size = BIO_get_mem_data(pBIO, &pData);
BIO *pBIO = BIO_new(BIO_s_file()); stream.write(pData, size);
if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate file", path); }
if (!BIO_write_filename(pBIO, const_cast<char*>(path.c_str()))) catch (...)
{ {
BIO_free(pBIO); BIO_free(pBIO);
throw Poco::CreateFileException("Cannot create certificate file", path); throw;
} }
try BIO_free(pBIO);
{ }
if (!PEM_write_bio_X509(pBIO, _pCert))
throw Poco::WriteFileException("Failed to write certificate to file", path);
} void X509Certificate::save(const std::string& path) const
catch (...) {
{ BIO *pBIO = BIO_new(BIO_s_file());
BIO_free(pBIO); if (!pBIO) throw Poco::IOException("Cannot create BIO for reading certificate file", path);
throw; if (!BIO_write_filename(pBIO, const_cast<char*>(path.c_str())))
} {
BIO_free(pBIO); BIO_free(pBIO);
} throw Poco::CreateFileException("Cannot create certificate file", path);
}
try
void X509Certificate::init() {
{ if (!PEM_write_bio_X509(pBIO, _pCert))
char buffer[NAME_BUFFER_SIZE]; throw Poco::WriteFileException("Failed to write certificate to file", path);
X509_NAME_oneline(X509_get_issuer_name(_pCert), buffer, sizeof(buffer)); }
_issuerName = buffer; catch (...)
X509_NAME_oneline(X509_get_subject_name(_pCert), buffer, sizeof(buffer)); {
_subjectName = buffer; BIO_free(pBIO);
} throw;
}
BIO_free(pBIO);
std::string X509Certificate::commonName() const }
{
return subjectName(NID_COMMON_NAME);
} void X509Certificate::init()
{
char buffer[NAME_BUFFER_SIZE];
std::string X509Certificate::issuerName(NID nid) const X509_NAME_oneline(X509_get_issuer_name(_pCert), buffer, sizeof(buffer));
{ _issuerName = buffer;
if (X509_NAME* issuer = X509_get_issuer_name(_pCert)) X509_NAME_oneline(X509_get_subject_name(_pCert), buffer, sizeof(buffer));
{ _subjectName = buffer;
char buffer[NAME_BUFFER_SIZE]; }
X509_NAME_get_text_by_NID(issuer, nid, buffer, sizeof(buffer));
return std::string(buffer);
} std::string X509Certificate::commonName() const
else return std::string(); {
} return subjectName(NID_COMMON_NAME);
}
std::string X509Certificate::subjectName(NID nid) const
{ std::string X509Certificate::issuerName(NID nid) const
if (X509_NAME* subj = X509_get_subject_name(_pCert)) {
{ if (X509_NAME* issuer = X509_get_issuer_name(_pCert))
char buffer[NAME_BUFFER_SIZE]; {
X509_NAME_get_text_by_NID(subj, nid, buffer, sizeof(buffer)); char buffer[NAME_BUFFER_SIZE];
return std::string(buffer); X509_NAME_get_text_by_NID(issuer, nid, buffer, sizeof(buffer));
} return std::string(buffer);
else return std::string(); }
} else return std::string();
}
void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>& domainNames) const
{ std::string X509Certificate::subjectName(NID nid) 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))) if (X509_NAME* subj = X509_get_subject_name(_pCert))
{ {
for (int i = 0; i < sk_GENERAL_NAME_num(names); ++i) char buffer[NAME_BUFFER_SIZE];
{ X509_NAME_get_text_by_NID(subj, nid, buffer, sizeof(buffer));
const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i); return std::string(buffer);
if (name->type == GEN_DNS) }
{ else return std::string();
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));
} void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>& domainNames) const
} {
GENERAL_NAMES_free(names); 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)))
{
cmnName = commonName(); for (int i = 0; i < sk_GENERAL_NAME_num(names); ++i)
if (!cmnName.empty() && domainNames.empty()) {
{ const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i);
domainNames.insert(cmnName); 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));
Poco::DateTime X509Certificate::validFrom() const }
{ }
ASN1_TIME* certTime = X509_get_notBefore(_pCert); GENERAL_NAMES_free(names);
std::string dateTime(reinterpret_cast<char*>(certTime->data)); }
int tzd;
return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd); cmnName = commonName();
} if (!cmnName.empty() && domainNames.empty())
{
domainNames.insert(cmnName);
Poco::DateTime X509Certificate::expiresOn() const }
{ }
ASN1_TIME* certTime = X509_get_notAfter(_pCert);
std::string dateTime(reinterpret_cast<char*>(certTime->data));
int tzd; Poco::DateTime X509Certificate::validFrom() const
return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd); {
} ASN1_TIME* certTime = X509_get_notBefore(_pCert);
std::string dateTime(reinterpret_cast<char*>(certTime->data));
int tzd;
bool X509Certificate::issuedBy(const X509Certificate& issuerCertificate) const return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
{ }
X509* pCert = const_cast<X509*>(_pCert);
X509* pIssuerCert = const_cast<X509*>(issuerCertificate.certificate());
EVP_PKEY* pIssuerPublicKey = X509_get_pubkey(pIssuerCert); Poco::DateTime X509Certificate::expiresOn() const
if (!pIssuerPublicKey) throw Poco::InvalidArgumentException("Issuer certificate has no public key"); {
int rc = X509_verify(pCert, pIssuerPublicKey); ASN1_TIME* certTime = X509_get_notAfter(_pCert);
EVP_PKEY_free(pIssuerPublicKey); std::string dateTime(reinterpret_cast<char*>(certTime->data));
return rc != 0; int tzd;
} return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
}
} } // namespace Poco::Crypto
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

View 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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">bin\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">bin\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">bin\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">obj\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">TestSuite</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">TestSuite</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">TestSuite</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|Win32&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|Win32&apos;">
<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>

View 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>

View 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>

View 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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<ImportGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;" Label="PropertySheets">
<Import Condition="exists(&apos;$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props&apos;)" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">bin64\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">bin64\static_mt\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">false</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">true</LinkIncremental>
<OutDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">bin64\static_md\</OutDir>
<IntDir Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">obj64\$(Configuration)\</IntDir>
<LinkIncremental Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">false</LinkIncremental>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">TestSuited</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">TestSuite</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">TestSuite</TargetName>
<TargetName Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">TestSuite</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_shared|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_shared|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_mt|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_mt|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;debug_static_md|x64&apos;">
<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="&apos;$(Configuration)|$(Platform)&apos;==&apos;release_static_md|x64&apos;">
<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>

View 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>

View 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>

View File

@@ -1,156 +1,225 @@
// //
// CryptoTest.cpp // CryptoTest.cpp
// //
// $Id: //poco/Main/Crypto/testsuite/src/CryptoTest.cpp#3 $ // $Id: //poco/Main/Crypto/testsuite/src/CryptoTest.cpp#3 $
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "CryptoTest.h" #include "CryptoTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Crypto/CipherFactory.h" #include "Poco/Crypto/CipherFactory.h"
#include "Poco/Crypto/Cipher.h" #include "Poco/Crypto/Cipher.h"
#include "Poco/Crypto/CipherKey.h" #include "Poco/Crypto/CipherKey.h"
#include "Poco/Crypto/X509Certificate.h" #include "Poco/Crypto/X509Certificate.h"
#include <sstream> #include "Poco/Crypto/CryptoStream.h"
#include "Poco/StreamCopier.h"
#include <sstream>
using namespace Poco::Crypto;
using namespace Poco::Crypto;
static const std::string APPINF_PEM(
"-----BEGIN CERTIFICATE-----\n"
"MIIESzCCAzOgAwIBAgIBATALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu\n" static const std::string APPINF_PEM(
"Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n\n" "-----BEGIN CERTIFICATE-----\n"
"aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh\n" "MIIESzCCAzOgAwIBAgIBATALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu\n"
"cmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl\n" "Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n\n"
"bnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu\n" "aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh\n"
"Y29tMB4XDTA5MDUwNzE0NTY1NloXDTI5MDUwMjE0NTY1NlowgdMxEzARBgNVBAMM\n" "cmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl\n"
"CmFwcGluZi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdh\n" "bnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu\n"
"cmUgRW5naW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNV\n" "Y29tMB4XDTA5MDUwNzE0NTY1NloXDTI5MDUwMjE0NTY1NlowgdMxEzARBgNVBAMM\n"
"BAgMCUNhcmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBp\n" "CmFwcGluZi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdh\n"
"bSBSb3NlbnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0Bh\n" "cmUgRW5naW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNV\n"
"cHBpbmYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA89GolWCR\n" "BAgMCUNhcmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBp\n"
"KtLQclJ2M2QtpFqzNC54hUQdR6n8+DAeruH9WFwLSdWW2fEi+jrtd/WEWCdt4PxX\n" "bSBSb3NlbnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0Bh\n"
"F2/eBYeURus7Hg2ZtJGDd3je0+Ygsv7+we4cMN/knaBY7rATqhmnZWk+yBpkf5F2\n" "cHBpbmYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA89GolWCR\n"
"IHp9gBxUaJWmt/bq3XrvTtzrDXpCd4zg4zPXZ8IC8ket5o3K2vnkAOsIsgN+Ffqd\n" "KtLQclJ2M2QtpFqzNC54hUQdR6n8+DAeruH9WFwLSdWW2fEi+jrtd/WEWCdt4PxX\n"
"4GjF4dsblG6u6E3VarGRLwGtgB8BAZOA/33mV4FHSMkc4OXpAChaK3tM8YhrLw+m\n" "F2/eBYeURus7Hg2ZtJGDd3je0+Ygsv7+we4cMN/knaBY7rATqhmnZWk+yBpkf5F2\n"
"XtsfqDiv1825S6OWFCKGj/iX8X2QAkrdB63vXCSpb3de/ByIUfp31PpMlMh6dKo1\n" "IHp9gBxUaJWmt/bq3XrvTtzrDXpCd4zg4zPXZ8IC8ket5o3K2vnkAOsIsgN+Ffqd\n"
"vf7yj0nb2w0utQIDAQABoyowKDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAww\n" "4GjF4dsblG6u6E3VarGRLwGtgB8BAZOA/33mV4FHSMkc4OXpAChaK3tM8YhrLw+m\n"
"CgYIKwYBBQUHAwMwDQYJKoZIhvcNAQEFBQADggEBAM0cpfb4BgiU/rkYe121P581\n" "XtsfqDiv1825S6OWFCKGj/iX8X2QAkrdB63vXCSpb3de/ByIUfp31PpMlMh6dKo1\n"
"ftg5Ck1PYYda1Fy/FgzbgJh2AwVo/6sn6GF79/QkEcWEgtCMNNO3LMTTddUUApuP\n" "vf7yj0nb2w0utQIDAQABoyowKDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAww\n"
"jnEimyfmUhIThyud/vryzTMNa/eZMwaAqUQWqLf+AwgqjUsBSMenbSHavzJOpsvR\n" "CgYIKwYBBQUHAwMwDQYJKoZIhvcNAQEFBQADggEBAM0cpfb4BgiU/rkYe121P581\n"
"LI0PQ1VvqB+3UGz0JUnBJiKvHs83Fdm4ewPAf3M5fGcIa+Fl2nU5Plzwzskj84f6\n" "ftg5Ck1PYYda1Fy/FgzbgJh2AwVo/6sn6GF79/QkEcWEgtCMNNO3LMTTddUUApuP\n"
"73ZlEEi3aW9JieNy7RWsMM+1E8Sj2CGRZC4BM9V1Fgnsh4+VHX8Eu7eHucvfeIYx\n" "jnEimyfmUhIThyud/vryzTMNa/eZMwaAqUQWqLf+AwgqjUsBSMenbSHavzJOpsvR\n"
"3mmLMoK4sCayL/FGhrUDw5AkWb8tKNpRXY+W60Et281yxQSeWLPIbatVzIWI0/M=\n" "LI0PQ1VvqB+3UGz0JUnBJiKvHs83Fdm4ewPAf3M5fGcIa+Fl2nU5Plzwzskj84f6\n"
"-----END CERTIFICATE-----\n" "73ZlEEi3aW9JieNy7RWsMM+1E8Sj2CGRZC4BM9V1Fgnsh4+VHX8Eu7eHucvfeIYx\n"
); "3mmLMoK4sCayL/FGhrUDw5AkWb8tKNpRXY+W60Et281yxQSeWLPIbatVzIWI0/M=\n"
"-----END CERTIFICATE-----\n"
);
CryptoTest::CryptoTest(const std::string& name): CppUnit::TestCase(name)
{
} CryptoTest::CryptoTest(const std::string& name): CppUnit::TestCase(name)
{
}
CryptoTest::~CryptoTest()
{
} CryptoTest::~CryptoTest()
{
}
void CryptoTest::testEncryptDecrypt()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256")); void CryptoTest::testEncryptDecrypt()
{
std::string in("1234567890"); Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64); for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
poco_assert (in == result); {
} std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher->decryptString(out, Cipher::ENC_NONE);
void CryptoTest::testEncryptDecryptWithSalt() poco_assert (in == result);
{ }
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
std::string in("1234567890"); {
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64); std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt")); std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64);
poco_assert (in == result);
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');
void CryptoTest::testCertificate() std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
{ std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX);
std::istringstream certStream(APPINF_PEM); poco_assert (in == result);
X509Certificate cert(certStream); }
}
std::string subjectName(cert.subjectName());
std::string issuerName(cert.issuerName());
std::string commonName(cert.commonName()); void CryptoTest::testEncryptDecryptWithSalt()
std::string country(cert.subjectName(X509Certificate::NID_COUNTRY)); {
std::string localityName(cert.subjectName(X509Certificate::NID_LOCALITY_NAME)); Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
std::string stateOrProvince(cert.subjectName(X509Certificate::NID_STATE_OR_PROVINCE)); Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
std::string organizationName(cert.subjectName(X509Certificate::NID_ORGANIZATION_NAME));
std::string organizationUnitName(cert.subjectName(X509Certificate::NID_ORGANIZATION_UNIT_NAME)); for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
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"); std::string in(n, 'x');
assert (issuerName == subjectName); std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
assert (commonName == "appinf.com"); std::string result = pCipher2->decryptString(out, Cipher::ENC_NONE);
assert (country == "AT"); poco_assert (in == result);
assert (localityName == "St. Jakob im Rosental"); }
assert (stateOrProvince == "Carinthia");
assert (organizationName == "Applied Informatics Software Engineering GmbH"); for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
assert (organizationUnitName == "Development"); {
std::string in(n, 'x');
assert (cert.issuedBy(cert)); std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
} std::string result = pCipher2->decryptString(out, Cipher::ENC_BASE64);
poco_assert (in == result);
}
void CryptoTest::setUp()
{ 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);
void CryptoTest::tearDown() std::string result = pCipher2->decryptString(out, Cipher::ENC_BINHEX);
{ poco_assert (in == result);
} }
}
CppUnit::Test* CryptoTest::suite()
{ void CryptoTest::testStreams()
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("CryptoTest"); {
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecrypt);
CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptWithSalt); static const std::string SECRET_MESSAGE = "This is a secret message. Don't tell anyone.";
CppUnit_addTest(pSuite, CryptoTest, testCertificate);
std::stringstream sstr;
return pSuite; 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;
}

View File

@@ -1,62 +1,68 @@
// //
// CryptoTest.h // CryptoTest.h
// //
// $Id: //poco/Main/Crypto/testsuite/src/CryptoTest.h#2 $ // $Id: //poco/1.4/Crypto/testsuite/src/CryptoTest.h#2 $
// //
// Definition of the CryptoTest class. // Definition of the CryptoTest class.
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef CryptoTest_INCLUDED #ifndef CryptoTest_INCLUDED
#define CryptoTest_INCLUDED #define CryptoTest_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
class CryptoTest: public CppUnit::TestCase class CryptoTest: public CppUnit::TestCase
{ {
public: public:
CryptoTest(const std::string& name); enum
~CryptoTest(); {
MAX_DATA_SIZE = 10000
void testEncryptDecrypt(); };
void testEncryptDecryptWithSalt();
void testCertificate(); CryptoTest(const std::string& name);
~CryptoTest();
void setUp();
void tearDown(); void testEncryptDecrypt();
void testEncryptDecryptWithSalt();
static CppUnit::Test* suite(); void testStreams();
void testCertificate();
private:
}; void setUp();
void tearDown();
#endif // CryptoTest_INCLUDED static CppUnit::Test* suite();
private:
};
#endif // CryptoTest_INCLUDED

View File

@@ -1,39 +1,65 @@
// //
// Driver.cpp // Driver.cpp
// //
// $Id: //poco/Main/Crypto/testsuite/src/Driver.cpp#1 $ // $Id: //poco/Main/Crypto/testsuite/src/Driver.cpp#1 $
// //
// Console-based test driver for Poco Crypto. // Console-based test driver for Poco Crypto.
// //
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. // Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "CppUnit/TestRunner.h" #include "CppUnit/TestRunner.h"
#include "CryptoTestSuite.h" #include "CryptoTestSuite.h"
#include "Poco/Crypto/Crypto.h"
CppUnitMain(CryptoTestSuite)
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;
}

View File

@@ -1,229 +1,253 @@
// //
// RSATest.cpp // RSATest.cpp
// //
// $Id: //poco/Main/Crypto/testsuite/src/RSATest.cpp#5 $ // $Id: //poco/Main/Crypto/testsuite/src/RSATest.cpp#5 $
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "RSATest.h" #include "RSATest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Crypto/RSADigestEngine.h" #include "Poco/Crypto/RSADigestEngine.h"
#include "Poco/Crypto/CipherFactory.h" #include "Poco/Crypto/CipherFactory.h"
#include "Poco/Crypto/Cipher.h" #include "Poco/Crypto/Cipher.h"
#include "Poco/Crypto/X509Certificate.h" #include "Poco/Crypto/X509Certificate.h"
#include <sstream> #include <sstream>
using namespace Poco::Crypto; using namespace Poco::Crypto;
static const std::string anyPem( static const std::string anyPem(
"-----BEGIN CERTIFICATE-----\r\n" "-----BEGIN CERTIFICATE-----\r\n"
"MIICaDCCAdECCQCzfxSsk7yaLjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n" "MIICaDCCAdECCQCzfxSsk7yaLjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n" "VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n" "BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
"aW5mLmNvbTAeFw0wNjAzMDExMzA3MzFaFw0wNjAzMzExMzA3MzFaMH4xCzAJBgNV\r\n" "aW5mLmNvbTAeFw0wNjAzMDExMzA3MzFaFw0wNjAzMzExMzA3MzFaMH4xCzAJBgNV\r\n"
"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExETAPBgNVBAcTCFN0IEpha29iMRww\r\n" "BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExETAPBgNVBAcTCFN0IEpha29iMRww\r\n"
"GgYDVQQKExNBcHBsaWVkIEluZm9ybWF0aWNzMQowCAYDVQQDFAEqMR4wHAYJKoZI\r\n" "GgYDVQQKExNBcHBsaWVkIEluZm9ybWF0aWNzMQowCAYDVQQDFAEqMR4wHAYJKoZI\r\n"
"hvcNAQkBFg9pbmZvQGFwcGluZi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ\r\n" "hvcNAQkBFg9pbmZvQGFwcGluZi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ\r\n"
"AoGBAJHGyXDHyCYoWz+65ltNwwZbhwOGnxr9P1WMATuFJh0bPBZxKbZRdbTm9KhZ\r\n" "AoGBAJHGyXDHyCYoWz+65ltNwwZbhwOGnxr9P1WMATuFJh0bPBZxKbZRdbTm9KhZ\r\n"
"OlvsEIsfgiYdsxURYIqXfEgISYLZcZY0pQwGEOmB+0NeC/+ENSfOlNSthx6zSVlc\r\n" "OlvsEIsfgiYdsxURYIqXfEgISYLZcZY0pQwGEOmB+0NeC/+ENSfOlNSthx6zSVlc\r\n"
"zhJ7+dJOGwepHAiLr1fRuc5jogYLraE+lKTnqAAFfzwvti77AgMBAAEwDQYJKoZI\r\n" "zhJ7+dJOGwepHAiLr1fRuc5jogYLraE+lKTnqAAFfzwvti77AgMBAAEwDQYJKoZI\r\n"
"hvcNAQEFBQADgYEAY/ZoeY1ukkEJX7259NeoVM0oahlulWV0rlCqyaeosOiDORPT\r\n" "hvcNAQEFBQADgYEAY/ZoeY1ukkEJX7259NeoVM0oahlulWV0rlCqyaeosOiDORPT\r\n"
"m6X1w/5MTCf9VyaD1zukoSZ4QqNVjHFXcXidbB7Tgt3yRuZ5PC5LIFCDPv9mgPne\r\n" "m6X1w/5MTCf9VyaD1zukoSZ4QqNVjHFXcXidbB7Tgt3yRuZ5PC5LIFCDPv9mgPne\r\n"
"mUA70yfctNfza2z3ZiQ6NDkW3mZX+1tmxYIrJQIrkVeYeqf1Gh2nyZrUMcE=\r\n" "mUA70yfctNfza2z3ZiQ6NDkW3mZX+1tmxYIrJQIrkVeYeqf1Gh2nyZrUMcE=\r\n"
"-----END CERTIFICATE-----\r\n" "-----END CERTIFICATE-----\r\n"
"-----BEGIN RSA PRIVATE KEY-----\r\n" "-----BEGIN RSA PRIVATE KEY-----\r\n"
"Proc-Type: 4,ENCRYPTED\r\n" "Proc-Type: 4,ENCRYPTED\r\n"
"DEK-Info: DES-EDE3-CBC,E7AE93C9E49184EA\r\n" "DEK-Info: DES-EDE3-CBC,E7AE93C9E49184EA\r\n"
"\r\n" "\r\n"
"A2IqzNcWs+I5vzV+i+woDk56+yr58eU0Onw8eEvXkLjnSc58JU4327IF7yUbKWdW\r\n" "A2IqzNcWs+I5vzV+i+woDk56+yr58eU0Onw8eEvXkLjnSc58JU4327IF7yUbKWdW\r\n"
"Q7BYGGOkVFiZ7ANOwviDg5SUhxRDWCcW8dS6/p1vfdQ1C3qj2OwJjkpg0aDBIzJn\r\n" "Q7BYGGOkVFiZ7ANOwviDg5SUhxRDWCcW8dS6/p1vfdQ1C3qj2OwJjkpg0aDBIzJn\r\n"
"FzgguT3MF3ama77vxv0S3kOfmCj62MLqPGpj5pQ0/1hefRFbL8oAX8bXUN7/rmGM\r\n" "FzgguT3MF3ama77vxv0S3kOfmCj62MLqPGpj5pQ0/1hefRFbL8oAX8bXUN7/rmGM\r\n"
"Zc0QyzFZv2iQ04dY/6TNclwKPB4H0On4K+8BMs3PRkWA0clCaQaFO2+iwnk3XZfe\r\n" "Zc0QyzFZv2iQ04dY/6TNclwKPB4H0On4K+8BMs3PRkWA0clCaQaFO2+iwnk3XZfe\r\n"
"+MsKUEbLCpAQeYspYv1cw38dCdWq1KTP5aJk+oXgwjfX5cAaPTz74NTqTIsCcaTD\r\n" "+MsKUEbLCpAQeYspYv1cw38dCdWq1KTP5aJk+oXgwjfX5cAaPTz74NTqTIsCcaTD\r\n"
"3vy7ukJYFlDR9Kyo7z8rMazYrKJslhnuRH0BhK9st9McwL957j5tZmrKyraCcmCx\r\n" "3vy7ukJYFlDR9Kyo7z8rMazYrKJslhnuRH0BhK9st9McwL957j5tZmrKyraCcmCx\r\n"
"dMAGcsis1va3ayYZpIpFqA4EhYrTM+6N8ZRfUap20+b5IQwHfTQDejUhL6rBwy7j\r\n" "dMAGcsis1va3ayYZpIpFqA4EhYrTM+6N8ZRfUap20+b5IQwHfTQDejUhL6rBwy7j\r\n"
"Ti5yD83/itoOMyXq2sV/XWfVD5zk/P5iv22O1EAQMhhnPB9K/I/JhuSGQJfn3cNh\r\n" "Ti5yD83/itoOMyXq2sV/XWfVD5zk/P5iv22O1EAQMhhnPB9K/I/JhuSGQJfn3cNh\r\n"
"ykOUYT0+vDeSeEVa+FVEP1W35G0alTbKbNs5Tb8KxJ3iDJUxokM//SvPXZy9hOVX\r\n" "ykOUYT0+vDeSeEVa+FVEP1W35G0alTbKbNs5Tb8KxJ3iDJUxokM//SvPXZy9hOVX\r\n"
"Y05imB04J15DaGbAHlNzunhuJi7121WV/JRXZRW9diE6hwpD8rwqi3FMuRUmy7U9\r\n" "Y05imB04J15DaGbAHlNzunhuJi7121WV/JRXZRW9diE6hwpD8rwqi3FMuRUmy7U9\r\n"
"aFA5poKRAYlo9YtZ3YpFyjGKB6MfCQcB2opuSnQ/gbugV41m67uQ4CDwWLaNRkTb\r\n" "aFA5poKRAYlo9YtZ3YpFyjGKB6MfCQcB2opuSnQ/gbugV41m67uQ4CDwWLaNRkTb\r\n"
"GlsMBNcHnidg15Bsat5HaB7l250ukrI13Uw1MYdDUzaS3gPfw9aC4F2w0p3U+DPH\r\n" "GlsMBNcHnidg15Bsat5HaB7l250ukrI13Uw1MYdDUzaS3gPfw9aC4F2w0p3U+DPH\r\n"
"80/zePxtroR7T4/+rI136Rl+aMXDMOEGCX1TVP8rjuZzuRyUSUKC8Q==\r\n" "80/zePxtroR7T4/+rI136Rl+aMXDMOEGCX1TVP8rjuZzuRyUSUKC8Q==\r\n"
"-----END RSA PRIVATE KEY-----\r\n" "-----END RSA PRIVATE KEY-----\r\n"
"-----BEGIN CERTIFICATE-----\r\n" "-----BEGIN CERTIFICATE-----\r\n"
"MIICXTCCAcYCCQC1Vk/N8qR4AjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n" "MIICXTCCAcYCCQC1Vk/N8qR4AjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n" "VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n" "BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
"aW5mLmNvbTAeFw0wNjAyMjcxMzI3MThaFw0wNjAzMjkxMzI3MThaMHMxCzAJBgNV\r\n" "aW5mLmNvbTAeFw0wNjAyMjcxMzI3MThaFw0wNjAzMjkxMzI3MThaMHMxCzAJBgNV\r\n"
"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExEjAQBgNVBAcTCVN0LiBKYWtvYjEP\r\n" "BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExEjAQBgNVBAcTCVN0LiBKYWtvYjEP\r\n"
"MA0GA1UEChMGQXBwSW5mMQ8wDQYDVQQDEwZBcHBJbmYxGjAYBgkqhkiG9w0BCQEW\r\n" "MA0GA1UEChMGQXBwSW5mMQ8wDQYDVQQDEwZBcHBJbmYxGjAYBgkqhkiG9w0BCQEW\r\n"
"C2FwcEBpbmYuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsFXiPuicN\r\n" "C2FwcEBpbmYuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsFXiPuicN\r\n"
"Im4oJwF8NuaFN+lgYwcZ6dAO3ILIR3kLA2PxF8HSQLfF8J8a4odZhLhctIMAKTxm\r\n" "Im4oJwF8NuaFN+lgYwcZ6dAO3ILIR3kLA2PxF8HSQLfF8J8a4odZhLhctIMAKTxm\r\n"
"k0w8TW5qhL8QLdGzY9vzvkgdKOkan2t3sMeXJAfrM1AphTsmgntAQazGZjOj5p4W\r\n" "k0w8TW5qhL8QLdGzY9vzvkgdKOkan2t3sMeXJAfrM1AphTsmgntAQazGZjOj5p4W\r\n"
"jDnxQ+VXAylqwjHh49eSBxM3wgoscF4iLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GB\r\n" "jDnxQ+VXAylqwjHh49eSBxM3wgoscF4iLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GB\r\n"
"AIpfLdXiKchPvFMhQS8xTtXvrw5dVL3yImUMYs4GQi8RrjGmfGB3yMAR7B/b8v4a\r\n" "AIpfLdXiKchPvFMhQS8xTtXvrw5dVL3yImUMYs4GQi8RrjGmfGB3yMAR7B/b8v4a\r\n"
"+ztfusgWAWiUKuSGTk4S8YB0fsFlmOv0WDr+PyZ4Lui/a8opbyzGE7rqpnF/s0GO\r\n" "+ztfusgWAWiUKuSGTk4S8YB0fsFlmOv0WDr+PyZ4Lui/a8opbyzGE7rqpnF/s0GO\r\n"
"M7uLCNNwIN7WhmxcWV0KZU1wTppoSWPJda1yTbBzF9XP\r\n" "M7uLCNNwIN7WhmxcWV0KZU1wTppoSWPJda1yTbBzF9XP\r\n"
"-----END CERTIFICATE-----\r\n" "-----END CERTIFICATE-----\r\n"
); );
RSATest::RSATest(const std::string& name): CppUnit::TestCase(name) RSATest::RSATest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
RSATest::~RSATest() RSATest::~RSATest()
{ {
} }
void RSATest::testNewKeys() void RSATest::testNewKeys()
{ {
RSAKey key(RSAKey::KL_1024, RSAKey::EXP_SMALL); RSAKey key(RSAKey::KL_1024, RSAKey::EXP_SMALL);
std::ostringstream strPub; std::ostringstream strPub;
std::ostringstream strPriv; std::ostringstream strPriv;
key.save(&strPub, &strPriv, "testpwd"); key.save(&strPub, &strPriv, "testpwd");
std::string pubKey = strPub.str(); std::string pubKey = strPub.str();
std::string privKey = strPriv.str(); std::string privKey = strPriv.str();
// now do the round trip // now do the round trip
std::istringstream iPub(pubKey); std::istringstream iPub(pubKey);
std::istringstream iPriv(privKey); std::istringstream iPriv(privKey);
RSAKey key2(&iPub, &iPriv, "testpwd"); RSAKey key2(&iPub, &iPriv, "testpwd");
std::istringstream iPriv2(privKey); std::istringstream iPriv2(privKey);
RSAKey key3(0, &iPriv2, "testpwd"); RSAKey key3(0, &iPriv2, "testpwd");
std::ostringstream strPub3; std::ostringstream strPub3;
key3.save(&strPub3); key3.save(&strPub3);
std::string pubFromPrivate = strPub3.str(); std::string pubFromPrivate = strPub3.str();
assert (pubFromPrivate == pubKey); assert (pubFromPrivate == pubKey);
} }
void RSATest::testSign() void RSATest::testSign()
{ {
std::string msg("Test this sign message"); std::string msg("Test this sign message");
RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE); RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE);
RSADigestEngine eng(key); RSADigestEngine eng(key);
eng.update(msg.c_str(), msg.length()); eng.update(msg.c_str(), static_cast<unsigned>(msg.length()));
const Poco::DigestEngine::Digest& sig = eng.signature(); const Poco::DigestEngine::Digest& sig = eng.signature();
std::string hexDig = Poco::DigestEngine::digestToHex(sig); std::string hexDig = Poco::DigestEngine::digestToHex(sig);
// verify // verify
std::ostringstream strPub; std::ostringstream strPub;
key.save(&strPub); key.save(&strPub);
std::string pubKey = strPub.str(); std::string pubKey = strPub.str();
std::istringstream iPub(pubKey); std::istringstream iPub(pubKey);
RSAKey keyPub(&iPub); RSAKey keyPub(&iPub);
RSADigestEngine eng2(key); RSADigestEngine eng2(key);
eng2.update(msg.c_str(), msg.length()); eng2.update(msg.c_str(), static_cast<unsigned>(msg.length()));
assert (eng2.verify(sig)); assert (eng2.verify(sig));
} }
void RSATest::testSignManipulated() void RSATest::testSignManipulated()
{ {
std::string msg("Test this sign message"); std::string msg("Test this sign message");
std::string msgManip("Test that sign message"); std::string msgManip("Test that sign message");
RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE); RSAKey key(RSAKey::KL_2048, RSAKey::EXP_LARGE);
RSADigestEngine eng(key); RSADigestEngine eng(key);
eng.update(msg.c_str(), msg.length()); eng.update(msg.c_str(), static_cast<unsigned>(msg.length()));
const Poco::DigestEngine::Digest& sig = eng.signature(); const Poco::DigestEngine::Digest& sig = eng.signature();
std::string hexDig = Poco::DigestEngine::digestToHex(sig); std::string hexDig = Poco::DigestEngine::digestToHex(sig);
// verify // verify
std::ostringstream strPub; std::ostringstream strPub;
key.save(&strPub); key.save(&strPub);
std::string pubKey = strPub.str(); std::string pubKey = strPub.str();
std::istringstream iPub(pubKey); std::istringstream iPub(pubKey);
RSAKey keyPub(&iPub); RSAKey keyPub(&iPub);
RSADigestEngine eng2(key); RSADigestEngine eng2(key);
eng2.update(msgManip.c_str(), msgManip.length()); eng2.update(msgManip.c_str(), static_cast<unsigned>(msgManip.length()));
assert (!eng2.verify(sig)); assert (!eng2.verify(sig));
} }
void RSATest::createRSACipher() void RSATest::testRSACipher()
{ {
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024,RSAKey::EXP_SMALL)); Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
std::string val("lets do some encryption"); for (std::size_t n = 1; n <= 1200; n++)
std::string enc = pCipher->encryptString(val); {
std::string dec = pCipher->decryptString(enc); std::string val(n, 'x');
assert (dec == val); 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'); void RSATest::testRSACipherLarge()
std::string enc = pCipher->encryptString(val); {
std::string dec = pCipher->decryptString(enc); std::vector<std::size_t> sizes;
assert (dec == val); sizes.push_back (2047);
} sizes.push_back (2048);
sizes.push_back (2049);
sizes.push_back (4095);
void RSATest::testCertificate() sizes.push_back (4096);
{ sizes.push_back (4097);
std::istringstream str(anyPem); sizes.push_back (8191);
X509Certificate cert(str); sizes.push_back (8192);
sizes.push_back (8193);
RSAKey key(cert); sizes.push_back (16383);
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(key); sizes.push_back (16384);
std::string val("lets do some encryption"); sizes.push_back (16385);
std::string enc = pCipher->encryptString(val); 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');
void RSATest::setUp() std::string enc = pCipher->encryptString(val);
{ std::string dec = pCipher->decryptString(enc);
} assert (dec == val);
}
}
void RSATest::tearDown()
{
} void RSATest::testCertificate()
{
std::istringstream str(anyPem);
CppUnit::Test* RSATest::suite() X509Certificate cert(str);
{ RSAKey publicKey(cert);
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("RSATest"); std::istringstream str2(anyPem);
RSAKey privateKey(0, &str2, "test");
CppUnit_addTest(pSuite, RSATest, testNewKeys); Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey);
CppUnit_addTest(pSuite, RSATest, testSign); Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey);
CppUnit_addTest(pSuite, RSATest, testSignManipulated); std::string val("lets do some encryption");
CppUnit_addTest(pSuite, RSATest, createRSACipher);
CppUnit_addTest(pSuite, RSATest, createRSACipherLarge); std::string enc = pCipher->encryptString(val);
CppUnit_addTest(pSuite, RSATest, testCertificate); std::string dec = pCipher2->decryptString(enc);
assert (dec == val);
return pSuite; }
}
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;
}

View File

@@ -1,65 +1,65 @@
// //
// RSATest.h // RSATest.h
// //
// $Id: //poco/Main/Crypto/testsuite/src/RSATest.h#3 $ // $Id: //poco/Main/Crypto/testsuite/src/RSATest.h#3 $
// //
// Definition of the RSATest class. // Definition of the RSATest class.
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#ifndef RSATest_INCLUDED #ifndef RSATest_INCLUDED
#define RSATest_INCLUDED #define RSATest_INCLUDED
#include "Poco/Crypto/Crypto.h" #include "Poco/Crypto/Crypto.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
class RSATest: public CppUnit::TestCase class RSATest: public CppUnit::TestCase
{ {
public: public:
RSATest(const std::string& name); RSATest(const std::string& name);
~RSATest(); ~RSATest();
void testNewKeys(); void testNewKeys();
void testSign(); void testSign();
void testSignManipulated(); void testSignManipulated();
void createRSACipher(); void testRSACipher();
void createRSACipherLarge(); void testRSACipherLarge();
void testCertificate(); void testCertificate();
void setUp(); void setUp();
void tearDown(); void tearDown();
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
}; };
#endif // RSATest_INCLUDED #endif // RSATest_INCLUDED

View 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;
}

View File

@@ -1,50 +1,68 @@
// //
// WinDriver.cpp // WinDriver.cpp
// //
// $Id: //poco/Main/Crypto/testsuite/src/WinDriver.cpp#1 $ // $Id: //poco/Main/Crypto/testsuite/src/WinDriver.cpp#1 $
// //
// Windows test driver for Poco Crypto. // Windows test driver for Poco Crypto.
// //
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // 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 // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // 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 // 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 // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // 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 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "WinTestRunner/WinTestRunner.h" #include "WinTestRunner/WinTestRunner.h"
#include "CryptoTestSuite.h" #include "CryptoTestSuite.h"
#include "Poco/Crypto/Crypto.h"
class TestDriver: public CppUnit::WinTestRunnerApp
{ class CryptoInitializer
void TestMain() {
{ public:
CppUnit::WinTestRunner runner; CryptoInitializer()
runner.addTest(CryptoTestSuite::suite()); {
runner.run(); Poco::Crypto::initializeCrypto();
} }
};
~CryptoInitializer()
{
TestDriver theDriver; Poco::Crypto::uninitializeCrypto();
}
};
class TestDriver: public CppUnit::WinTestRunnerApp
{
void TestMain()
{
CryptoInitializer ci;
CppUnit::WinTestRunner runner;
runner.addTest(CryptoTestSuite::suite());
runner.run();
}
};
TestDriver theDriver;