2
0
Эх сурвалжийг харах

integrated changes from 1.3.5

Guenter Obiltschnig 16 жил өмнө
parent
commit
99c48cff49
66 өөрчлөгдсөн 2796 нэмэгдсэн , 2051 устгасан
  1. 40 30
      Crypto/Crypto_VS71.sln
  2. 168 19
      Crypto/Crypto_VS71.vcproj
  3. 13 0
      Crypto/Crypto_VS80.sln
  4. 226 26
      Crypto/Crypto_VS80.vcproj
  5. 10 0
      Crypto/Crypto_VS90.sln
  6. 224 24
      Crypto/Crypto_VS90.vcproj
  7. 3 2
      Crypto/Makefile
  8. 3 2
      Crypto/include/Poco/Crypto/Cipher.h
  9. 7 8
      Crypto/include/Poco/Crypto/CipherFactory.h
  10. 4 4
      Crypto/include/Poco/Crypto/CipherImpl.h
  11. 17 9
      Crypto/include/Poco/Crypto/CipherKey.h
  12. 13 9
      Crypto/include/Poco/Crypto/CipherKeyImpl.h
  13. 21 0
      Crypto/include/Poco/Crypto/Crypto.h
  14. 17 16
      Crypto/include/Poco/Crypto/CryptoStream.h
  15. 2 2
      Crypto/include/Poco/Crypto/CryptoTransform.h
  16. 15 15
      Crypto/include/Poco/Crypto/OpenSSLInitializer.h
  17. 14 7
      Crypto/include/Poco/Crypto/RSACipherImpl.h
  18. 44 12
      Crypto/include/Poco/Crypto/RSADigestEngine.h
  19. 36 24
      Crypto/include/Poco/Crypto/RSAKey.h
  20. 37 23
      Crypto/include/Poco/Crypto/RSAKeyImpl.h
  21. 197 0
      Crypto/include/Poco/Crypto/X509Certificate.h
  22. 17 17
      Crypto/samples/genrsakey/Makefile
  23. 21 23
      Crypto/src/Cipher.cpp
  24. 3 5
      Crypto/src/CipherFactory.cpp
  25. 109 106
      Crypto/src/CipherImpl.cpp
  26. 2 2
      Crypto/src/CipherKey.cpp
  27. 8 7
      Crypto/src/CipherKeyImpl.cpp
  28. 17 17
      Crypto/src/CryptoStream.cpp
  29. 1 1
      Crypto/src/CryptoTransform.cpp
  30. 29 27
      Crypto/src/OpenSSLInitializer.cpp
  31. 217 203
      Crypto/src/RSACipherImpl.cpp
  32. 30 23
      Crypto/src/RSADigestEngine.cpp
  33. 13 14
      Crypto/src/RSAKey.cpp
  34. 109 90
      Crypto/src/RSAKeyImpl.cpp
  35. 290 0
      Crypto/src/X509Certificate.cpp
  36. 1 1
      Crypto/testsuite/Makefile
  37. 120 2
      Crypto/testsuite/TestSuite_VS71.vcproj
  38. 179 2
      Crypto/testsuite/TestSuite_VS80.vcproj
  39. 173 2
      Crypto/testsuite/TestSuite_VS90.vcproj
  40. 64 5
      Crypto/testsuite/src/CryptoTest.cpp
  41. 4 3
      Crypto/testsuite/src/CryptoTest.h
  42. 65 22
      Crypto/testsuite/src/RSATest.cpp
  43. 2 2
      NetSSL_OpenSSL/Makefile
  44. 8 14
      NetSSL_OpenSSL/NetSSL_OpenSSL_vs71.vcproj
  45. 16 24
      NetSSL_OpenSSL/NetSSL_OpenSSL_vs80.vcproj
  46. 6 8
      NetSSL_OpenSSL/NetSSL_OpenSSL_vs90.vcproj
  47. 15 56
      NetSSL_OpenSSL/include/Poco/Net/X509Certificate.h
  48. 4 4
      NetSSL_OpenSSL/samples/HTTPSTimeServer/HTTPSTimeServer_vs71.vcproj
  49. 5 182
      NetSSL_OpenSSL/samples/HTTPSTimeServer/HTTPSTimeServer_vs80.vcproj
  50. 2 173
      NetSSL_OpenSSL/samples/HTTPSTimeServer/HTTPSTimeServer_vs90.vcproj
  51. 1 1
      NetSSL_OpenSSL/samples/HTTPSTimeServer/Makefile
  52. 54 54
      NetSSL_OpenSSL/samples/HTTPSTimeServer/any.pem
  53. 25 25
      NetSSL_OpenSSL/samples/HTTPSTimeServer/rootcert.pem
  54. 1 1
      NetSSL_OpenSSL/samples/HTTPSTimeServer/src/HTTPSTimeServer.cpp
  55. 1 1
      NetSSL_OpenSSL/samples/download/Makefile
  56. 4 4
      NetSSL_OpenSSL/samples/download/download_vs71.vcproj
  57. 8 185
      NetSSL_OpenSSL/samples/download/download_vs80.vcproj
  58. 2 173
      NetSSL_OpenSSL/samples/download/download_vs90.vcproj
  59. 6 2
      NetSSL_OpenSSL/src/Context.cpp
  60. 6 4
      NetSSL_OpenSSL/src/SSLManager.cpp
  61. 10 13
      NetSSL_OpenSSL/src/SecureSocketImpl.cpp
  62. 12 125
      NetSSL_OpenSSL/src/X509Certificate.cpp
  63. 1 1
      NetSSL_OpenSSL/testsuite/Makefile
  64. 8 8
      NetSSL_OpenSSL/testsuite/TestSuite_vs71.vcproj
  65. 14 14
      NetSSL_OpenSSL/testsuite/TestSuite_vs80.vcproj
  66. 2 173
      NetSSL_OpenSSL/testsuite/TestSuite_vs90.vcproj

+ 40 - 30
Crypto/Crypto_VS71.sln

@@ -1,30 +1,40 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crypto", "Crypto_VS71.vcproj", "{eeee7259-32e9-4d56-b023-c733940ab2a0}"
-	ProjectSection(ProjectDependencies) = postProject
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_VS71.vcproj", "{c1b1bb96-5198-48eb-ab48-9a0a0b54fb15}"
-	ProjectSection(ProjectDependencies) = postProject
-		{eeee7259-32e9-4d56-b023-c733940ab2a0} = {eeee7259-32e9-4d56-b023-c733940ab2a0}
-	EndProjectSection
-EndProject
-Global
-	GlobalSection(SolutionConfiguration) = preSolution
-		debug_shared = debug_shared
-		release_shared = release_shared
-	EndGlobalSection
-	GlobalSection(ProjectConfiguration) = postSolution
-		{eeee7259-32e9-4d56-b023-c733940ab2a0}.debug_shared.ActiveCfg = debug_shared|Win32
-		{eeee7259-32e9-4d56-b023-c733940ab2a0}.debug_shared.Build.0 = debug_shared|Win32
-		{eeee7259-32e9-4d56-b023-c733940ab2a0}.release_shared.ActiveCfg = release_shared|Win32
-		{eeee7259-32e9-4d56-b023-c733940ab2a0}.release_shared.Build.0 = release_shared|Win32
-		{c1b1bb96-5198-48eb-ab48-9a0a0b54fb15}.debug_shared.ActiveCfg = debug_shared|Win32
-		{c1b1bb96-5198-48eb-ab48-9a0a0b54fb15}.debug_shared.Build.0 = debug_shared|Win32
-		{c1b1bb96-5198-48eb-ab48-9a0a0b54fb15}.release_shared.ActiveCfg = release_shared|Win32
-		{c1b1bb96-5198-48eb-ab48-9a0a0b54fb15}.release_shared.Build.0 = release_shared|Win32
-	EndGlobalSection
-	GlobalSection(ExtensibilityGlobals) = postSolution
-	EndGlobalSection
-	GlobalSection(ExtensibilityAddIns) = postSolution
-	EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crypto", "Crypto_VS71.vcproj", "{EEEE7259-32E9-4D56-B023-C733940AB2A0}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_VS71.vcproj", "{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}"
+	ProjectSection(ProjectDependencies) = postProject
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0} = {EEEE7259-32E9-4D56-B023-C733940AB2A0}
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfiguration) = preSolution
+		debug_shared = debug_shared
+		release_shared = release_shared
+		debug_static = debug_static
+		release_static = release_static
+	EndGlobalSection
+	GlobalSection(ProjectConfiguration) = postSolution
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_shared.ActiveCfg = debug_shared|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_shared.Build.0 = debug_shared|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_shared.ActiveCfg = release_shared|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_shared.Build.0 = release_shared|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static.ActiveCfg = debug_static|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static.Build.0 = debug_static|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static.ActiveCfg = release_static|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static.Build.0 = release_static|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_shared.ActiveCfg = debug_shared|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_shared.Build.0 = debug_shared|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_shared.ActiveCfg = release_shared|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_shared.Build.0 = release_shared|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static.ActiveCfg = debug_static|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static.Build.0 = debug_static|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static.ActiveCfg = release_static|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static.Build.0 = release_static|Win32
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+	EndGlobalSection
+	GlobalSection(ExtensibilityAddIns) = postSolution
+	EndGlobalSection
+EndGlobal

+ 168 - 19
Crypto/Crypto_VS71.vcproj

@@ -20,7 +20,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\NetSSL_OpenSSL\include;..\Net\include"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;Crypto_EXPORTS;OPENSSL_NO_DEPRECATED"
 				StringPooling="TRUE"
 				MinimalRebuild="TRUE"
@@ -39,7 +39,7 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationd.lib"
+				AdditionalDependencies="PocoFoundationd.lib libeay32mtd.lib ssleay32mtd.lib"
 				OutputFile="..\bin\PocoCryptod.dll"
 				LinkIncremental="2"
 				SuppressStartupBanner="TRUE"
@@ -85,7 +85,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\NetSSL_OpenSSL\include;..\Net\include"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;Crypto_EXPORTS;OPENSSL_NO_DEPRECATED"
 				GeneratePreprocessedFile="0"
 				KeepComments="FALSE"
@@ -104,7 +104,7 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundation.lib"
+				AdditionalDependencies="PocoFoundation.lib libeay32mt.lib ssleay32mt.lib"
 				OutputFile="..\bin\PocoCrypto.dll"
 				LinkIncremental="1"
 				SuppressStartupBanner="TRUE"
@@ -138,6 +138,107 @@
 			<Tool
 				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
+		<Configuration
+			Name="debug_static|Win32"
+			OutputDirectory="obj\debug_static"
+			IntermediateDirectory="obj\debug_static"
+			ConfigurationType="4"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;Crypto_EXPORTS;POCO_STATIC"
+				StringPooling="TRUE"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				BufferSecurityCheck="TRUE"
+				TreatWChar_tAsBuiltInType="TRUE"
+				ForceConformanceInForLoopScope="TRUE"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"
+				CompileAs="0"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="..\lib\PocoCryptomtd.lib"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="release_static|Win32"
+			OutputDirectory="obj\release_static"
+			IntermediateDirectory="obj\release_static"
+			ConfigurationType="4"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="4"
+				InlineFunctionExpansion="1"
+				EnableIntrinsicFunctions="TRUE"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="TRUE"
+				OptimizeForProcessor="3"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;Crypto_EXPORTS;POCO_STATIC"
+				GeneratePreprocessedFile="0"
+				KeepComments="FALSE"
+				StringPooling="TRUE"
+				RuntimeLibrary="2"
+				BufferSecurityCheck="FALSE"
+				TreatWChar_tAsBuiltInType="TRUE"
+				ForceConformanceInForLoopScope="TRUE"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="0"
+				CompileAs="0"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="..\lib\PocoCryptomt.lib"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>
@@ -145,6 +246,27 @@
 		<Filter
 			Name="CryptoCore"
 			Filter="">
+			<Filter
+				Name="Header Files"
+				Filter="">
+				<File
+					RelativePath=".\include\Poco\Crypto\Crypto.h">
+				</File>
+				<File
+					RelativePath=".\include\Poco\Crypto\OpenSSLInitializer.h">
+				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				Filter="">
+				<File
+					RelativePath=".\src\OpenSSLInitializer.cpp">
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Cipher"
+			Filter="">
 			<Filter
 				Name="Header Files"
 				Filter="">
@@ -163,27 +285,12 @@
 				<File
 					RelativePath=".\include\Poco\Crypto\CipherKeyImpl.h">
 				</File>
-				<File
-					RelativePath=".\include\Poco\Crypto\Crypto.h">
-				</File>
 				<File
 					RelativePath=".\include\Poco\Crypto\CryptoStream.h">
 				</File>
 				<File
 					RelativePath=".\include\Poco\Crypto\CryptoTransform.h">
 				</File>
-				<File
-					RelativePath=".\include\Poco\Crypto\RSACipherImpl.h">
-				</File>
-				<File
-					RelativePath=".\include\Poco\Crypto\RSADigestEngine.h">
-				</File>
-				<File
-					RelativePath=".\include\Poco\Crypto\RSAKey.h">
-				</File>
-				<File
-					RelativePath=".\include\Poco\Crypto\RSAKeyImpl.h">
-				</File>
 			</Filter>
 			<Filter
 				Name="Source Files"
@@ -209,6 +316,48 @@
 				<File
 					RelativePath=".\src\CryptoTransform.cpp">
 				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Certificate"
+			Filter="">
+			<Filter
+				Name="Header Files"
+				Filter="">
+				<File
+					RelativePath=".\include\Poco\Crypto\X509Certificate.h">
+				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				Filter="">
+				<File
+					RelativePath=".\src\X509Certificate.cpp">
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="RSA"
+			Filter="">
+			<Filter
+				Name="Header Files"
+				Filter="">
+				<File
+					RelativePath=".\include\Poco\Crypto\RSACipherImpl.h">
+				</File>
+				<File
+					RelativePath=".\include\Poco\Crypto\RSADigestEngine.h">
+				</File>
+				<File
+					RelativePath=".\include\Poco\Crypto\RSAKey.h">
+				</File>
+				<File
+					RelativePath=".\include\Poco\Crypto\RSAKeyImpl.h">
+				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				Filter="">
 				<File
 					RelativePath=".\src\RSACipherImpl.cpp">
 				</File>

+ 13 - 0
Crypto/Crypto_VS80.sln

@@ -4,21 +4,34 @@ Microsoft Visual Studio Solution File, Format Version 9.00
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crypto_VS80", "Crypto_VS80.vcproj", "{EEEE7259-32E9-4D56-B023-C733940AB2A0}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_VS80.vcproj", "{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
+		debug_static|Win32 = debug_static|Win32
 		release_shared|Win32 = release_shared|Win32
+		release_static|Win32 = release_static|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_static|Win32.ActiveCfg = debug_static|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static|Win32.Build.0 = debug_static|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_static|Win32.ActiveCfg = release_static|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static|Win32.Build.0 = release_static|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_static|Win32.ActiveCfg = debug_static|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static|Win32.Build.0 = debug_static|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_static|Win32.ActiveCfg = release_static|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static|Win32.Build.0 = release_static|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 226 - 26
Crypto/Crypto_VS80.vcproj

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8,00"
+	Version="8.00"
 	Name="Crypto_VS80"
 	ProjectGUID="{EEEE7259-32E9-4D56-B023-C733940AB2A0}"
 	RootNamespace="Crypto"
@@ -40,7 +40,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\NetSSL_OpenSSL\include;..\Net\include"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;Crypto_EXPORTS;OPENSSL_NO_DEPRECATED"
 				StringPooling="true"
 				MinimalRebuild="true"
@@ -133,7 +133,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\NetSSL_OpenSSL\include;..\Net\include"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;Crypto_EXPORTS;OPENSSL_NO_DEPRECATED"
 				GeneratePreprocessedFile="0"
 				KeepComments="false"
@@ -199,6 +199,154 @@
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
+		<Configuration
+			Name="release_static|Win32"
+			OutputDirectory="obj\release_static"
+			IntermediateDirectory="obj\release_static"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="4"
+				InlineFunctionExpansion="1"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;Crypto_EXPORTS;POCO_STATIC"
+				GeneratePreprocessedFile="0"
+				KeepComments="false"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				BufferSecurityCheck="false"
+				TreatWChar_tAsBuiltInType="true"
+				ForceConformanceInForLoopScope="true"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="0"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="..\lib\PocoCryptomt.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="debug_static|Win32"
+			OutputDirectory="obj\debug_static"
+			IntermediateDirectory="obj\debug_static"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;Crypto_EXPORTS;POCO_STATIC"
+				StringPooling="true"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				BufferSecurityCheck="true"
+				TreatWChar_tAsBuiltInType="true"
+				ForceConformanceInForLoopScope="true"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="..\lib\PocoCryptomtd.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>
@@ -210,85 +358,117 @@
 				Name="Header Files"
 				>
 				<File
-					RelativePath=".\include\Poco\Crypto\Cipher.h"
+					RelativePath=".\include\Poco\Crypto\Crypto.h"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\CipherFactory.h"
+					RelativePath=".\include\Poco\Crypto\OpenSSLInitializer.h"
 					>
 				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				>
 				<File
-					RelativePath=".\include\Poco\Crypto\CipherImpl.h"
+					RelativePath=".\src\OpenSSLInitializer.cpp"
 					>
 				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Cipher"
+			>
+			<Filter
+				Name="Source Files"
+				>
 				<File
-					RelativePath=".\include\Poco\Crypto\CipherKey.h"
+					RelativePath=".\src\Cipher.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\CipherKeyImpl.h"
+					RelativePath=".\src\CipherFactory.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\Crypto.h"
+					RelativePath=".\src\CipherImpl.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\CryptoStream.h"
+					RelativePath=".\src\CipherKey.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\CryptoTransform.h"
+					RelativePath=".\src\CipherKeyImpl.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\RSACipherImpl.h"
+					RelativePath=".\src\CryptoStream.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\RSADigestEngine.h"
+					RelativePath=".\src\CryptoTransform.cpp"
 					>
 				</File>
+			</Filter>
+			<Filter
+				Name="Header Files"
+				>
 				<File
-					RelativePath=".\include\Poco\Crypto\RSAKey.h"
+					RelativePath=".\include\Poco\Crypto\Cipher.h"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\RSAKeyImpl.h"
+					RelativePath=".\include\Poco\Crypto\CipherFactory.h"
 					>
 				</File>
-			</Filter>
-			<Filter
-				Name="Source Files"
-				>
 				<File
-					RelativePath=".\src\Cipher.cpp"
+					RelativePath=".\include\Poco\Crypto\CipherImpl.h"
 					>
 				</File>
 				<File
-					RelativePath=".\src\CipherFactory.cpp"
+					RelativePath=".\include\Poco\Crypto\CipherKey.h"
 					>
 				</File>
 				<File
-					RelativePath=".\src\CipherImpl.cpp"
+					RelativePath=".\include\Poco\Crypto\CipherKeyImpl.h"
 					>
 				</File>
 				<File
-					RelativePath=".\src\CipherKey.cpp"
+					RelativePath=".\include\Poco\Crypto\CryptoStream.h"
 					>
 				</File>
 				<File
-					RelativePath=".\src\CipherKeyImpl.cpp"
+					RelativePath=".\include\Poco\Crypto\CryptoTransform.h"
 					>
 				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Certificate"
+			>
+			<Filter
+				Name="Source Files"
+				>
 				<File
-					RelativePath=".\src\CryptoStream.cpp"
+					RelativePath=".\src\X509Certificate.cpp"
 					>
 				</File>
+			</Filter>
+			<Filter
+				Name="Header Files"
+				>
 				<File
-					RelativePath=".\src\CryptoTransform.cpp"
+					RelativePath=".\include\Poco\Crypto\X509Certificate.h"
 					>
 				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="RSA"
+			>
+			<Filter
+				Name="Source Files"
+				>
 				<File
 					RelativePath=".\src\RSACipherImpl.cpp"
 					>
@@ -306,6 +486,26 @@
 					>
 				</File>
 			</Filter>
+			<Filter
+				Name="Header Files"
+				>
+				<File
+					RelativePath=".\include\Poco\Crypto\RSACipherImpl.h"
+					>
+				</File>
+				<File
+					RelativePath=".\include\Poco\Crypto\RSADigestEngine.h"
+					>
+				</File>
+				<File
+					RelativePath=".\include\Poco\Crypto\RSAKey.h"
+					>
+				</File>
+				<File
+					RelativePath=".\include\Poco\Crypto\RSAKeyImpl.h"
+					>
+				</File>
+			</Filter>
 		</Filter>
 	</Files>
 	<Globals>

+ 10 - 0
Crypto/Crypto_VS90.sln

@@ -11,16 +11,26 @@ Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		debug_shared|Win32 = debug_shared|Win32
 		release_shared|Win32 = release_shared|Win32
+		debug_static|Win32 = debug_static|Win32
+		release_static|Win32 = release_static|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}.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}.debug_static|Win32.ActiveCfg = debug_static|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.debug_static|Win32.Build.0 = debug_static|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static|Win32.ActiveCfg = release_static|Win32
+		{EEEE7259-32E9-4D56-B023-C733940AB2A0}.release_static|Win32.Build.0 = release_static|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}.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}.debug_static|Win32.ActiveCfg = debug_static|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.debug_static|Win32.Build.0 = debug_static|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static|Win32.ActiveCfg = release_static|Win32
+		{C1B1BB96-5198-48EB-AB48-9A0A0B54FB15}.release_static|Win32.Build.0 = release_static|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 224 - 24
Crypto/Crypto_VS90.vcproj

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9,00"
+	Version="9.00"
 	Name="Crypto"
 	ProjectGUID="{eeee7259-32e9-4d56-b023-c733940ab2a0}"
 	RootNamespace="Crypto"
@@ -41,7 +41,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\NetSSL_OpenSSL\include;..\Net\include"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;Crypto_EXPORTS;OPENSSL_NO_DEPRECATED"
 				StringPooling="true"
 				MinimalRebuild="true"
@@ -68,7 +68,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationd.lib libeay32mdd.lib ssleay32mdd.lib"
+				AdditionalDependencies="PocoFoundationd.lib libeay32mtd.lib ssleay32mtd.lib"
 				ShowProgress="0"
 				OutputFile="..\bin\PocoCryptod.dll"
 				LinkIncremental="2"
@@ -134,7 +134,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\NetSSL_OpenSSL\include;..\Net\include"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;Crypto_EXPORTS"
 				GeneratePreprocessedFile="0"
 				KeepComments="false"
@@ -199,12 +199,160 @@
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
+		<Configuration
+			Name="release_static|Win32"
+			OutputDirectory="obj\release_static"
+			IntermediateDirectory="obj\release_static"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="4"
+				InlineFunctionExpansion="1"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;Crypto_EXPORTS;POCO_STATIC"
+				GeneratePreprocessedFile="0"
+				KeepComments="false"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				BufferSecurityCheck="false"
+				TreatWChar_tAsBuiltInType="true"
+				ForceConformanceInForLoopScope="true"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="false"
+				DebugInformationFormat="0"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="..\lib\PocoCryptomt.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="debug_static|Win32"
+			OutputDirectory="obj\debug_static"
+			IntermediateDirectory="obj\debug_static"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".\include;..\Foundation\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;Crypto_EXPORTS;POCO_STATIC"
+				StringPooling="true"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				BufferSecurityCheck="true"
+				TreatWChar_tAsBuiltInType="true"
+				ForceConformanceInForLoopScope="true"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="false"
+				DebugInformationFormat="4"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="..\lib\PocoCryptomtd.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>
 	<Files>
 		<Filter
-			Name="CryptoCore"
+			Name="Cipher"
 			>
 			<Filter
 				Name="Header Files"
@@ -229,10 +377,6 @@
 					RelativePath=".\include\Poco\Crypto\CipherKeyImpl.h"
 					>
 				</File>
-				<File
-					RelativePath=".\include\Poco\Crypto\Crypto.h"
-					>
-				</File>
 				<File
 					RelativePath=".\include\Poco\Crypto\CryptoStream.h"
 					>
@@ -241,54 +385,66 @@
 					RelativePath=".\include\Poco\Crypto\CryptoTransform.h"
 					>
 				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				>
 				<File
-					RelativePath=".\include\Poco\Crypto\RSACipherImpl.h"
+					RelativePath=".\src\Cipher.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\RSADigestEngine.h"
+					RelativePath=".\src\CipherFactory.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\RSAKey.h"
+					RelativePath=".\src\CipherImpl.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\include\Poco\Crypto\RSAKeyImpl.h"
+					RelativePath=".\src\CipherKey.cpp"
 					>
 				</File>
-			</Filter>
-			<Filter
-				Name="Source Files"
-				>
 				<File
-					RelativePath=".\src\Cipher.cpp"
+					RelativePath=".\src\CipherKeyImpl.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\src\CipherFactory.cpp"
+					RelativePath=".\src\CryptoStream.cpp"
 					>
 				</File>
 				<File
-					RelativePath=".\src\CipherImpl.cpp"
+					RelativePath=".\src\CryptoTransform.cpp"
 					>
 				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="RSA"
+			>
+			<Filter
+				Name="Header Files"
+				>
 				<File
-					RelativePath=".\src\CipherKey.cpp"
+					RelativePath=".\include\Poco\Crypto\RSACipherImpl.h"
 					>
 				</File>
 				<File
-					RelativePath=".\src\CipherKeyImpl.cpp"
+					RelativePath=".\include\Poco\Crypto\RSADigestEngine.h"
 					>
 				</File>
 				<File
-					RelativePath=".\src\CryptoStream.cpp"
+					RelativePath=".\include\Poco\Crypto\RSAKey.h"
 					>
 				</File>
 				<File
-					RelativePath=".\src\CryptoTransform.cpp"
+					RelativePath=".\include\Poco\Crypto\RSAKeyImpl.h"
 					>
 				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				>
 				<File
 					RelativePath=".\src\RSACipherImpl.cpp"
 					>
@@ -307,6 +463,50 @@
 				</File>
 			</Filter>
 		</Filter>
+		<Filter
+			Name="Certificate"
+			>
+			<Filter
+				Name="Header Files"
+				>
+				<File
+					RelativePath=".\include\Poco\Crypto\X509Certificate.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				>
+				<File
+					RelativePath=".\src\X509Certificate.cpp"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="CryptoCore"
+			>
+			<Filter
+				Name="Header Files"
+				>
+				<File
+					RelativePath=".\include\Poco\Crypto\Crypto.h"
+					>
+				</File>
+				<File
+					RelativePath=".\include\Poco\Crypto\OpenSSLInitializer.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Source Files"
+				>
+				<File
+					RelativePath=".\src\OpenSSLInitializer.cpp"
+					>
+				</File>
+			</Filter>
+		</Filter>
 	</Files>
 	<Globals>
 	</Globals>

+ 3 - 2
Crypto/Makefile

@@ -11,10 +11,11 @@ include $(POCO_BASE)/build/rules/global
 SYSLIBS += -lssl -lcrypto
 
 objects = Cipher CipherFactory CipherImpl CipherKey CipherKeyImpl CryptoStream CryptoTransform \
-	RSACipherImpl RSAKey RSAKeyImpl RSADigestEngine
+	RSACipherImpl RSAKey RSAKeyImpl RSADigestEngine \
+	X509Certificate OpenSSLInitializer
 
 target         = PocoCrypto
 target_version = $(LIBVERSION)
-target_libs    = PocoNetSSL PocoNet PocoFoundation
+target_libs    = PocoFoundation
 
 include $(POCO_BASE)/build/rules/lib

+ 3 - 2
Crypto/include/Poco/Crypto/Cipher.h

@@ -4,7 +4,7 @@
 // $Id$
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  Cipher
 //
 // Definition of the Cipher class.
@@ -43,7 +43,8 @@
 #include "Poco/Crypto/Crypto.h"
 #include "Poco/RefCountedObject.h"
 #include "Poco/AutoPtr.h"
-
+#include <istream>
+#include <ostream>
 #include <vector>
 
 

+ 7 - 8
Crypto/include/Poco/Crypto/CipherFactory.h

@@ -4,7 +4,7 @@
 // $Id$
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CipherFactory
 //
 // Definition of the CipherFactory class.
@@ -63,11 +63,10 @@ public:
 	virtual ~CipherFactory();
 		/// Destroys the CipherFactory.
 
-	
 	Cipher* createCipher(const CipherKey& key);
-		/// Creates a Cipher object for the given Cipher name. Valid cipher names
-		/// depend on the OpenSSL version the library is linked with; see the output
-		/// of
+		/// Creates a Cipher object for the given Cipher name. Valid cipher 
+		/// names depend on the OpenSSL version the library is linked with;  
+		/// see the output of
 		///
 		///     openssl enc --help
 		///
@@ -79,10 +78,10 @@ public:
 		///   * DES: "des", "des3"
 		///   * Blowfish: "bf"
 
-	Cipher* createCipher(const RSAKey& key);
-		/// Creates a RSACipher
+	Cipher* createCipher(const RSAKey& key, RSAPaddingMode paddingMode = RSA_PADDING_PKCS1);
+		/// Creates a RSACipher using the given RSA key and padding mode
+		/// for public key encryption/private key decryption.
 	
-
 	static CipherFactory& defaultFactory();
 		/// Returns the default CipherFactory.
 

+ 4 - 4
Crypto/include/Poco/Crypto/CipherImpl.h

@@ -1,10 +1,10 @@
 //
 // CipherImpl.h
 //
-// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherImpl.h#2 $
+// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherImpl.h#3 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CipherImpl
 //
 // Definition of the CipherImpl class.
@@ -51,7 +51,7 @@ namespace Poco {
 namespace Crypto {
 
 
-class CipherImpl : public Cipher
+class CipherImpl: public Cipher
 	/// An implementation of the Cipher class for OpenSSL's crypto library.
 {
 public:
@@ -62,7 +62,7 @@ public:
 		/// Destroys the CipherImpl.
 
 	const std::string& name() const;
-		/// Returns the name of the Cipher.
+		/// Returns the name of the cipher.
 
 	CryptoTransform* createEncryptor();
 		/// Creates an encrytor object.

+ 17 - 9
Crypto/include/Poco/Crypto/CipherKey.h

@@ -1,10 +1,10 @@
 //
 // CipherKey.h
 //
-// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherKey.h#1 $
+// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherKey.h#2 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CipherKey
 //
 // Definition of the CipherKey class.
@@ -49,7 +49,7 @@ namespace Crypto {
 
 
 class Crypto_API CipherKey
-	/// class 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:
 	///
 	///     CipherKey key("aes-256");
@@ -64,6 +64,7 @@ class Crypto_API CipherKey
 	/// use a salt value to make the key more robust:
 	///
 	///     std::string password = "secret";
+	///     std::string salt("asdff8723lasdf(**923412");
 	///		CipherKey key("aes-256", password, salt);
 	///
 {
@@ -73,24 +74,28 @@ public:
 
 	enum
 	{
-		DEFAULT_ITERATION_COUNT = 2000	/// Default iteration count to use with
-										/// generateKey().  RSA security recommends
-										/// an iteration count of at least 1000.
+		DEFAULT_ITERATION_COUNT = 2000
+			/// Default iteration count to use with
+			/// generateKey(). RSA security recommends
+			/// an iteration count of at least 1000.
 	};
 
 	CipherKey(const std::string& name, 
 		const std::string& passphrase, 
 		const std::string& salt = "",
 		int iterationCount = DEFAULT_ITERATION_COUNT);
-		/// Creates a new CipherKeyImpl object
+		/// Creates a new CipherKeyImpl object using the given
+		/// cipher name, passphrase, salt value and iteration count.
 
 	CipherKey(const std::string& name, 
 		const ByteVec& key, 
 		const ByteVec& iv);
-		/// Creates a new CipherKeyImpl object
+		/// Creates a new CipherKeyImpl object using the given cipher
+		/// name, key and initialization vector.
 
 	CipherKey(const std::string& name);
-		/// Creates a new CipherKeyImpl object. Autoinitializes  key and iv
+		/// Creates a new CipherKeyImpl object. Autoinitializes key and 
+		/// initialization vector.
 
 	~CipherKey();
 		/// Destroys the CipherKeyImpl.
@@ -130,6 +135,9 @@ private:
 };
 
 
+//
+// inlines
+//
 inline const std::string& CipherKey::name() const
 {
 	return _pImpl->name();

+ 13 - 9
Crypto/include/Poco/Crypto/CipherKeyImpl.h

@@ -1,10 +1,10 @@
 //
 // CipherKeyImpl.h
 //
-// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherKeyImpl.h#1 $
+// $Id: //poco/Main/Crypto/include/Poco/Crypto/CipherKeyImpl.h#2 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CipherKeyImpl
 //
 // Definition of the CipherKeyImpl class.
@@ -54,8 +54,8 @@ namespace Poco {
 namespace Crypto {
 
 
-class CipherKeyImpl : public RefCountedObject
-	/// An implementation of the Cipher 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;
@@ -76,15 +76,19 @@ public:
 		const std::string& passphrase, 
 		const std::string& salt,
 		int iterationCount);
-		/// Creates a new CipherKeyImpl object
+		/// Creates a new CipherKeyImpl object, using
+		/// the given cipher name, passphrase, salt value
+		/// and iteration count.
 
 	CipherKeyImpl(const std::string& name, 
 		const ByteVec& key, 
 		const ByteVec& iv);
-		/// Creates a new CipherKeyImpl object
+		/// Creates a new CipherKeyImpl object, using the 
+		/// given cipher name, key and initialization vector.
 
 	CipherKeyImpl(const std::string& name);
-		/// Creates a new CipherKeyImpl object. Autoinitializes  key and iv
+		/// Creates a new CipherKeyImpl object. Autoinitializes key
+		/// and initialization vector.
 
 	virtual ~CipherKeyImpl();
 		/// Destroys the CipherKeyImpl.
@@ -126,10 +130,10 @@ private:
 	 	/// Generates key and IV from a password and optional salt string.
 
 	void generateKey();
-		/// Generates key and IV from random data
+		/// Generates key and IV from random data.
 
 	void getRandomBytes(ByteVec& vec, std::size_t count);
-		/// Stores random bytes in vec
+		/// Stores random bytes in vec.
 
 private:
 	const EVP_CIPHER* _pCipher;

+ 21 - 0
Crypto/include/Poco/Crypto/Crypto.h

@@ -45,6 +45,27 @@
 #include "Poco/Foundation.h"
 
 
+enum RSAPaddingMode
+	/// The padding mode used for RSA public key encryption.
+{
+	RSA_PADDING_PKCS1,
+		/// PKCS #1 v1.5 padding. This currently is the most widely used mode. 
+		
+	RSA_PADDING_PKCS1_OAEP,
+		/// EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an empty 
+		/// encoding parameter. This mode is recommended for all new applications.
+		
+	RSA_PADDING_SSLV23,
+		/// PKCS #1 v1.5 padding with an SSL-specific modification that denotes 
+		/// that the server is SSL3 capable. 
+		
+	RSA_PADDING_NONE
+		/// Raw RSA encryption. This mode should only be used to implement cryptographically 
+		/// sound padding modes in the application code. Encrypting user data directly with RSA 
+		/// is insecure. 
+};
+
+
 //
 // The following block is the standard way of creating macros which make exporting
 // from a DLL simpler. All files within this DLL are compiled with the Crypto_EXPORTS

+ 17 - 16
Crypto/include/Poco/Crypto/CryptoStream.h

@@ -4,7 +4,7 @@
 // $Id$
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CryptoStream
 //
 // Definition of the CryptoStreamBuf, CryptoInputStream and CryptoOutputStream
@@ -55,18 +55,18 @@ class CryptoTransform;
 class Cipher;
 
 
-class Crypto_API CryptoStreamBuf : public Poco::BufferedStreamBuf
+class Crypto_API CryptoStreamBuf: public Poco::BufferedStreamBuf
 	/// This stream buffer performs cryptographic transformation on the data
 	/// going through it.
 {
 public:
-	CryptoStreamBuf(std::istream& istr, CryptoTransform* pTransform, std::size_t bufferSize = 8192);
-	CryptoStreamBuf(std::ostream& ostr, CryptoTransform* pTransform,
-		std::size_t bufferSize = 8192);
+	CryptoStreamBuf(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192);
+	CryptoStreamBuf(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192);
 
 	virtual ~CryptoStreamBuf();
 
 	void close();
+		/// Flushes all buffers and finishes the encryption.
 
 protected:
 	int readFromDevice(char* buffer, std::streamsize length);
@@ -85,17 +85,15 @@ private:
 };
 
 
-class Crypto_API CryptoIOS : public virtual std::ios
+class Crypto_API CryptoIOS: public virtual std::ios
 	/// The base class for CryptoInputStream and CryptoOutputStream.
 	///
 	/// This class is needed to ensure correct initialization order of the
 	/// stream buffer and base classes.
 {
 public:
-	CryptoIOS(std::istream& istr, CryptoTransform* pTransform,
-		std::size_t bufferSize = 8192);
-	CryptoIOS(std::ostream& ostr, CryptoTransform* pTransform,
-		std::size_t bufferSize = 8192);
+	CryptoIOS(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192);
+	CryptoIOS(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192);
 	~CryptoIOS();
 	CryptoStreamBuf* rdbuf();
 
@@ -104,7 +102,7 @@ protected:
 };
 
 
-class Crypto_API CryptoInputStream : public CryptoIOS, public std::istream
+class Crypto_API CryptoInputStream: public CryptoIOS, public std::istream
 	/// This stream transforms all data passing through it using the given
 	/// CryptoTransform.
 	///
@@ -113,18 +111,19 @@ class Crypto_API CryptoInputStream : public CryptoIOS, public std::istream
 	/// respectively.
 {
 public:
-	CryptoInputStream(std::istream& istr, CryptoTransform* pTransform, std::size_t bufferSize = 8192);
+	CryptoInputStream(std::istream& istr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192);
 		/// Create a new CryptoInputStream object. The CryptoInputStream takes the
 		/// ownership of the given CryptoTransform object.
 
-	CryptoInputStream(std::istream& istr, Cipher& cipher, std::size_t bufferSize = 8192);
+	CryptoInputStream(std::istream& istr, Cipher& cipher, std::streamsize bufferSize = 8192);
 		/// Create a new encrypting CryptoInputStream object using the given cipher.
 
 	~CryptoInputStream();
+		/// Destroys the CryptoInputStream.
 };
 
 
-class Crypto_API CryptoOutputStream : public CryptoIOS, public std::ostream
+class Crypto_API CryptoOutputStream: public CryptoIOS, public std::ostream
 	/// This stream transforms all data passing through it using the given
 	/// CryptoTransform.
 	///
@@ -136,16 +135,18 @@ class Crypto_API CryptoOutputStream : public CryptoIOS, public std::ostream
 	/// to ensure completion of cryptographic transformation.
 {
 public:
-	CryptoOutputStream(std::ostream& ostr, CryptoTransform* pTransform, std::size_t bufferSize = 8192);
+	CryptoOutputStream(std::ostream& ostr, CryptoTransform* pTransform, std::streamsize bufferSize = 8192);
 		/// Create a new CryptoOutputStream object. The CryptoOutputStream takes the
 		/// ownership of the given CryptoTransform object.
 
-	CryptoOutputStream(std::ostream& ostr, Cipher& cipher, std::size_t bufferSize = 8192);
+	CryptoOutputStream(std::ostream& ostr, Cipher& cipher, std::streamsize bufferSize = 8192);
 		/// Create a new decrypting CryptoOutputStream object using the given cipher.
 
 	~CryptoOutputStream();
+		/// Destroys the CryptoOutputStream.
 
 	void close();
+		/// Flushes all buffers and finishes the encryption.
 };
 
 

+ 2 - 2
Crypto/include/Poco/Crypto/CryptoTransform.h

@@ -4,7 +4,7 @@
 // $Id$
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CryptoTransform
 //
 // Definition of the CryptoTransform class.
@@ -41,7 +41,7 @@
 
 
 #include "Poco/Crypto/Crypto.h"
-#include <ios> 
+#include <ios>
 
 
 namespace Poco {

+ 15 - 15
NetSSL_OpenSSL/include/Poco/Net/SSLInitializer.h → Crypto/include/Poco/Crypto/OpenSSLInitializer.h

@@ -1,13 +1,13 @@
 //
-// SSLInitializer.h
+// OpenSSLInitializer.h
 //
-// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SSLInitializer.h#7 $
+// $Id: //poco/Main/Crypto/include/Poco/Crypto/OpenSSLInitializer.h#1 $
 //
-// Library: NetSSL_OpenSSL
-// Package: SSLCore
-// Module:  SSLInitializer
+// Library: Crypto
+// Package: CryptoCore
+// Module:  OpenSSLInitializer
 //
-// Definition of the SSLInitializer class.
+// Definition of the OpenSSLInitializer class.
 //
 // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
 // and Contributors.
@@ -36,11 +36,11 @@
 //
 
 
-#ifndef NetSSL_SSLInitializer_INCLUDED
-#define NetSSL_SSLInitializer_INCLUDED
+#ifndef Crypto_OpenSSLInitializer_INCLUDED
+#define Crypto_OpenSSLInitializer_INCLUDED
 
 
-#include "Poco/Net/NetSSL.h"
+#include "Poco/Crypto/Crypto.h"
 #include "Poco/Mutex.h"
 
 
@@ -54,20 +54,20 @@ extern "C"
 
 
 namespace Poco {
-namespace Net {
+namespace Crypto {
 
 
-class NetSSL_API SSLInitializer
+class Crypto_API OpenSSLInitializer
 	/// Initalizes the OpenSSL library.
 	///
 	/// The class ensures the earliest initialization and the
 	/// latest shutdown of the OpenSSL library.
 {
 public:
-	SSLInitializer();
+	OpenSSLInitializer();
 		/// Automatically initialize OpenSSL on startup.
 		
-	~SSLInitializer();
+	~OpenSSLInitializer();
 		/// Automatically shut down OpenSSL on exit.
 	
 	static void initialize();
@@ -95,7 +95,7 @@ private:
 };
 
 
-} } // namespace Poco::Net
+} } // namespace Poco::Crypto
 
 
-#endif // NetSSL_SSLInitializer_INCLUDED
+#endif // Crypto_OpenSSLInitializer_INCLUDED

+ 14 - 7
Crypto/include/Poco/Crypto/RSACipherImpl.h

@@ -1,10 +1,10 @@
 //
 // RSACipherImpl.h
 //
-// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSACipherImpl.h#1 $
+// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSACipherImpl.h#2 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: RSA
 // Module:  RSACipherImpl
 //
 // Definition of the RSACipherImpl class.
@@ -43,7 +43,6 @@
 #include "Poco/Crypto/Crypto.h"
 #include "Poco/Crypto/Cipher.h"
 #include "Poco/Crypto/RSAKey.h"
-
 #include <openssl/evp.h>
 
 
@@ -51,12 +50,19 @@ namespace Poco {
 namespace Crypto {
 
 
-class RSACipherImpl : public Cipher
-	/// An implementation of the RSA class for OpenSSL's crypto library.
+class RSACipherImpl: public Cipher
+	/// An implementation of the Cipher class for 
+	/// assymetric (public-private key) encryption
+	/// based on the the RSA algorithm in OpenSSL's 
+	/// crypto library.
+	///
+	/// Encryption is using the public key, decryption
+	/// requires the private key.
 {
 public:
-	RSACipherImpl(const RSAKey& key);
-		/// Creates a new RSACipherImpl object for the given RSAKey.
+	RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode);
+		/// Creates a new RSACipherImpl object for the given RSAKey
+		/// and using the given padding mode.
 
 	virtual ~RSACipherImpl();
 		/// Destroys the RSACipherImpl.
@@ -72,6 +78,7 @@ public:
 
 private:
 	RSAKey _key;
+	RSAPaddingMode _paddingMode;
 };
 
 

+ 44 - 12
Crypto/include/Poco/Crypto/RSADigestEngine.h

@@ -1,10 +1,10 @@
 //
 // RSADigestEngine.h
 //
-// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSADigestEngine.h#1 $
+// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSADigestEngine.h#2 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: RSA
 // Module:  RSADigestEngine
 //
 // Definition of the RSADigestEngine class.
@@ -43,6 +43,7 @@
 #include "Poco/Crypto/Crypto.h"
 #include "Poco/Crypto/RSAKey.h"
 #include "Poco/DigestEngine.h"
+#include "Poco/MD5Engine.h"
 #include "Poco/SHA1Engine.h"
 #include <openssl/rsa.h>
 #include <istream>
@@ -53,14 +54,30 @@ namespace Poco {
 namespace Crypto {
 
 
-
-
 class Crypto_API RSADigestEngine: public Poco::DigestEngine
-	/// RSADigestEngine is the implementation class for RSADigestEngine
+	/// This class implements a Poco::DigestEngine that can be
+	/// used to compute a secure digital signature.
+	///
+	/// First another Poco::DigestEngine (Poco::MD5Engine
+	/// or Poco::SHA1Engine) is used to compute a cryptographic
+	/// hash of the data to be signed. Then, the hash value is
+	/// encrypted, using the RSA private key.
+	///
+	/// To verify a signature, pass it to the verify() 
+	/// member function. It will decrypt the signature
+	/// using the RSA public key and compare the resulting
+	/// hash with the actual hash of the data.
 {
 public:
-	RSADigestEngine(const RSAKey& key);
-		/// Creates the RSADigestEngine with the given key
+	enum DigestType
+	{
+		DIGEST_MD5,
+		DIGEST_SHA1
+	};
+	
+	RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1);
+		/// Creates the RSADigestEngine with the given RSA key,
+		/// using the SHA-1 hash algorithm.
 
 	~RSADigestEngine();
 		/// Destroys the RSADigestEngine.
@@ -73,20 +90,35 @@ public:
 		/// digest can be computed.
 		
 	const DigestEngine::Digest& digest();
+		/// Finishes the computation of the digest 
+		/// (the first time it's called) and
+		/// returns the message digest. 
+		///
+		/// Can be called multiple times.
 
 	const DigestEngine::Digest& signature();
-		/// Signs the data
+		/// Signs the digest using the RSA algorithm
+		/// and the private key (teh first time it's
+		/// called) and returns the result.
+		///
+		/// Can be called multiple times.
 
-	void verify(const DigestEngine::Digest& signature);
-		/// Verifies the data against the signature
+	bool verify(const DigestEngine::Digest& signature);
+		/// Verifies the data against the signature.
+		///
+		/// Returns true if the signature can be verified, false otherwise.
 
 protected:
 	void updateImpl(const void* data, unsigned length);
 
 private:
 	RSAKey _key;
-	DigestEngine::Digest _sig;
-	SHA1Engine   _sha1;
+	Poco::DigestEngine& _engine;
+	int _type;
+	Poco::DigestEngine::Digest _digest;
+	Poco::DigestEngine::Digest _signature;
+	Poco::MD5Engine _md5Engine;
+	Poco::SHA1Engine _sha1Engine;
 };
 
 

+ 36 - 24
Crypto/include/Poco/Crypto/RSAKey.h

@@ -1,10 +1,10 @@
 //
 // RSAKey.h
 //
-// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSAKey.h#3 $
+// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSAKey.h#4 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: RSA
 // Module:  RSAKey
 //
 // Definition of the RSAKey class.
@@ -45,19 +45,25 @@
 
 
 namespace Poco {
-	namespace Net {
-		class X509Certificate;
-	}
 namespace Crypto {
 
 
+class X509Certificate;
+
+
 class Crypto_API RSAKey
-	/// Stores an RSAKey
+	/// This class stores an RSA key pair, consisting
+	/// of private and public key. Storage of the private
+	/// key is optional.
+	///
+	/// If a private key is available, the RSAKey can be
+	/// used for decrypting data (encrypted with the public key)
+	/// or computing secure digital signatures.
 {
 public:
 	enum KeyLength
 	{
-		KL_512 = 512,
+		KL_512  = 512,
 		KL_1024 = 1024,
 		KL_2048 = 2048,
 		KL_4096 = 4096
@@ -69,22 +75,19 @@ public:
 		EXP_LARGE
 	};
 
-	RSAKey(const Poco::Net::X509Certificate& cert);
-		/// Extracts the RSAKey from the certificate
+	explicit RSAKey(const X509Certificate& cert);
+		/// Extracts the RSA public key from the given certificate.
 
 	RSAKey(KeyLength keyLength, Exponent exp);
 		/// Creates the RSAKey. Creates a new public/private keypair using the given parameters.
-		/// Can be used to sign and verify a stream
+		/// Can be used to sign data and verify signatures.
 
-	RSAKey(const std::string& publicKeyFile, 
-		const std::string& privateKeyFile="", 
-		const std::string& privateKeyPwd="");
-		/// Creates the RSAKey. Can only by used for signing if privateKeyFile
-		/// is not empty.
+	RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
+		/// Creates the RSAKey, by reading public and private key from the given files and
+		/// using the given passphrase for the private key. Can only by used for signing if 
+		/// a private key is available. 
 
-	RSAKey(std::istream* pPubKey, 
-		std::istream* pPrivKey = 0, 
-		const std::string& privateKeyPwd="");
+	RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
 		/// Creates the RSAKey. Can only by used for signing if pPrivKey
 		/// is not null. If a private key file is specified, you don't need to
 		/// specify a public key file. OpenSSL will auto-create it from the private key.
@@ -93,16 +96,22 @@ public:
 		/// Destroys the RSAKey.
 
 	int size() const;
-		/// Returns the RSA_size
+		/// Returns the RSA modulus size.
 
-	void save(const std::string& pubKeyFile, const std::string& privKeyFile="", const std::string& privKeyPwd="");
-		/// Exports the keys to the given files. pubKeyFile/privKeyFile can be empty
+	void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
+		/// Exports the public and private keys to the given files. 
+		///
+		/// If an empty filename is specified, the corresponding key
+		/// is not exported.
 
-	void save(std::ostream* pPubKey, std::ostream* pPrivKey = 0, const std::string& privateKeyPwd = "");
-		/// Exports the keys to the given streams. pPubKey/pPrivKey can be empty
+	void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
+		/// Exports the public and private key to the given streams.
+		///
+		/// If a null pointer is passed for a stream, the corresponding
+		/// key is not exported.
 
 	RSAKeyImpl::Ptr impl();
-		/// Returns the impl object
+		/// Returns the impl object.
 
 	const std::string& name() const;
 		/// Returns "rsa"
@@ -112,6 +121,9 @@ private:
 };
 
 
+//
+// inlines
+//
 inline RSAKeyImpl::Ptr RSAKey::impl()
 {
 	return _pImpl;

+ 37 - 23
Crypto/include/Poco/Crypto/RSAKeyImpl.h

@@ -1,10 +1,10 @@
 //
 // RSAKeyImpl.h
 //
-// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSAKeyImpl.h#2 $
+// $Id: //poco/Main/Crypto/include/Poco/Crypto/RSAKeyImpl.h#3 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: RSA
 // Module:  RSAKeyImpl
 //
 // Definition of the RSAKeyImpl class.
@@ -43,6 +43,8 @@
 #include "Poco/Crypto/Crypto.h"
 #include "Poco/RefCountedObject.h"
 #include "Poco/AutoPtr.h"
+#include <istream>
+#include <ostream>
 
 
 struct rsa_st;
@@ -50,59 +52,71 @@ typedef struct rsa_st RSA;
 
 
 namespace Poco {
-	namespace Net {
-		class X509Certificate;
-	}
 namespace Crypto {
 
 
+class X509Certificate;
+
+
 class RSAKeyImpl: public Poco::RefCountedObject
 	/// class RSAKeyImpl
 {
 public:
 	typedef Poco::AutoPtr<RSAKeyImpl> Ptr;
 
-	RSAKeyImpl(const Poco::Net::X509Certificate& cert);
-		/// Extracts the RSAKey from the certificate
+	explicit RSAKeyImpl(const X509Certificate& cert);
+		/// Extracts the RSA public key from the given certificate.
 
 	RSAKeyImpl(int keyLength, unsigned long exponent);
-		/// Creates the RSAKeyImpl.
+		/// Creates the RSAKey. Creates a new public/private keypair using the given parameters.
+		/// Can be used to sign data and verify signatures.
 
-	RSAKeyImpl(const std::string& publicKey, const std::string& privateKeyFile, const std::string& privateKeyPwd);
-		/// Creates the RSAKeyImpl.
+	RSAKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase);
+		/// Creates the RSAKey, by reading public and private key from the given files and
+		/// using the given passphrase for the private key. Can only by used for signing if 
+		/// a private key is available. 
 
-	RSAKeyImpl(std::istream* pPubKey, std::istream* pPrivKey, const std::string& privateKeyPwd);
-		/// Creates the RSAKeyImpl. privKey is an optional parameter which can be null.
+	RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase);
+		/// Creates the RSAKey. Can only by used for signing if pPrivKey
+		/// is not null. If a private key file is specified, you don't need to
+		/// specify a public key file. OpenSSL will auto-create it from the private key.
 
 	~RSAKeyImpl();
 		/// Destroys the RSAKeyImpl.
 
 	RSA* getRSA();
-		/// Returns the openssl rsa object
+		/// Returns the OpenSSL RSA object.
 
 	const RSA* getRSA() const;
-		/// Returns the openssl rsa object
+		/// Returns the OpenSSL RSA object.
 
 	int size() const;
-		/// Returns the RSA_size
+		/// Returns the RSA modulus size.
 
-	void save(const std::string& pubKeyFile, const std::string& privKeyFile, const std::string& privKeyPwd);
-		/// Exports the keys to the given files. privKeyFile can be empty
+	void save(const std::string& publicKeyFile, const std::string& privateKeyFile = "", const std::string& privateKeyPassphrase = "");
+		/// Exports the public and private keys to the given files. 
+		///
+		/// If an empty filename is specified, the corresponding key
+		/// is not exported.
 
-	void save(std::ostream* pPubKey, std::ostream* pPrivKey, const std::string& privateKeyPwd);
-		/// Exports the keys to the given streams. Can be empty
+	void save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream = 0, const std::string& privateKeyPassphrase = "");
+		/// Exports the public and private key to the given streams.
+		///
+		/// If a null pointer is passed for a stream, the corresponding
+		/// key is not exported.
 
 private:
-	void init(const std::string& pubKeyFile, const std::string& privKeyFile, const std::string& privKeyPwd);
-		/// Initializes the object
-
+	void init(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase);
 	void freeRSA();
-		// Deletes the RSA object
+
 private:
 	RSA* _pRSA;
 };
 
 
+//
+// inlines
+//
 inline RSA* RSAKeyImpl::getRSA()
 {
 	return _pRSA;

+ 197 - 0
Crypto/include/Poco/Crypto/X509Certificate.h

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

+ 17 - 17
Crypto/samples/genrsakey/Makefile

@@ -1,17 +1,17 @@
-#
-# Makefile
-#
-# $Id: //poco/Main/template/sample.make#4 $
-#
-# Makefile for Poco genrsakey
-#
-
-include $(POCO_BASE)/build/rules/global
-
-objects = genrsakey
-
-target         = genrsakey
-target_version = 1
-target_libs    = PocoCrypto PocoUtil PocoXML PocoFoundation
-
-include $(POCO_BASE)/build/rules/exec
+#
+# Makefile
+#
+# $Id: //poco/Main/template/sample.make#4 $
+#
+# Makefile for Poco genrsakey
+#
+
+include $(POCO_BASE)/build/rules/global
+
+objects = genrsakey
+
+target         = genrsakey
+target_version = 1
+target_libs    = PocoCrypto PocoUtil PocoXML PocoFoundation
+
+include $(POCO_BASE)/build/rules/exec

+ 21 - 23
Crypto/src/Cipher.cpp

@@ -4,7 +4,7 @@
 // $Id$
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  Cipher
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
@@ -37,14 +37,12 @@
 #include "Poco/Crypto/Cipher.h"
 #include "Poco/Crypto/CryptoStream.h"
 #include "Poco/Crypto/CryptoTransform.h"
-
 #include "Poco/Base64Encoder.h"
 #include "Poco/Base64Decoder.h"
 #include "Poco/HexBinaryEncoder.h"
 #include "Poco/HexBinaryDecoder.h"
 #include "Poco/StreamCopier.h"
 #include "Poco/Exception.h"
-
 #include <sstream>
 #include <memory>
 
@@ -95,20 +93,20 @@ void Cipher::encrypt(std::istream& source, std::ostream& sink, Encoding encoding
 		break;
 
 	case ENC_BASE64:
-	{
-		Poco::Base64Encoder encoder(sink);
-		StreamCopier::copyStream(encryptor, encoder);
-		encoder.close();
+		{
+			Poco::Base64Encoder encoder(sink);
+			StreamCopier::copyStream(encryptor, encoder);
+			encoder.close();
+		}
 		break;
-	}
 
 	case ENC_BINHEX:
-	{
-		Poco::HexBinaryEncoder encoder(sink);
-		StreamCopier::copyStream(encryptor, encoder);
-		encoder.close();
+		{
+			Poco::HexBinaryEncoder encoder(sink);
+			StreamCopier::copyStream(encryptor, encoder);
+			encoder.close();
+		}
 		break;
-	}
 
 	default:
 		throw Poco::InvalidArgumentException("Invalid argument", "encoding");
@@ -128,20 +126,20 @@ void Cipher::decrypt(std::istream& source, std::ostream& sink, Encoding encoding
 		break;
 
 	case ENC_BASE64:
-	{
-		Poco::Base64Decoder decoder(source);
-		StreamCopier::copyStream(decoder, decryptor);
-		decryptor.close();
+		{
+			Poco::Base64Decoder decoder(source);
+			StreamCopier::copyStream(decoder, decryptor);
+			decryptor.close();
+		}
 		break;
-	}
 
 	case ENC_BINHEX:
-	{
-		Poco::HexBinaryDecoder decoder(source);
-		StreamCopier::copyStream(decoder, decryptor);
-		decryptor.close();
+		{
+			Poco::HexBinaryDecoder decoder(source);
+			StreamCopier::copyStream(decoder, decryptor);
+			decryptor.close();
+		}
 		break;
-	}
 
 	default:
 		throw Poco::InvalidArgumentException("Invalid argument", "encoding");

+ 3 - 5
Crypto/src/CipherFactory.cpp

@@ -4,7 +4,7 @@
 // $Id$
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CipherFactory
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
@@ -40,10 +40,8 @@
 #include "Poco/Crypto/RSAKey.h"
 #include "Poco/Crypto/CipherImpl.h"
 #include "Poco/Crypto/RSACipherImpl.h"
-
 #include "Poco/Exception.h"
 #include "Poco/SingletonHolder.h"
-
 #include <openssl/evp.h>
 #include <openssl/err.h>
 
@@ -90,9 +88,9 @@ Cipher* CipherFactory::createCipher(const CipherKey& key)
 }
 
 
-Cipher* CipherFactory::createCipher(const RSAKey& key)
+Cipher* CipherFactory::createCipher(const RSAKey& key, RSAPaddingMode paddingMode)
 {
-	return new RSACipherImpl(key);
+	return new RSACipherImpl(key, paddingMode);
 }
 
 

+ 109 - 106
Crypto/src/CipherImpl.cpp

@@ -4,7 +4,7 @@
 // $Id$
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CipherImpl
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
@@ -44,129 +44,134 @@ namespace Poco {
 namespace Crypto {
 
 
-static void throwError()
+namespace
 {
-	unsigned long err;
-	std::string msg;
-	
-	while ((err = ERR_get_error()))
+	void throwError()
 	{
-		if (!msg.empty())
-			msg.append("; ");
-		msg.append(ERR_error_string(err, 0));
+		unsigned long err;
+		std::string msg;
+		
+		while ((err = ERR_get_error()))
+		{
+			if (!msg.empty())
+				msg.append("; ");
+			msg.append(ERR_error_string(err, 0));
+		}
+
+		throw Poco::IOException(msg);
 	}
 
-	throw Poco::IOException(msg);
-}
-
 
-class CryptoTransformImpl : public CryptoTransform
-{
-public:
-	typedef Cipher::ByteVec ByteVec;
-
-	enum Direction
+	class CryptoTransformImpl: public CryptoTransform
 	{
-		DIR_ENCRYPT,
-		DIR_DECRYPT
+	public:
+		typedef Cipher::ByteVec ByteVec;
+
+		enum Direction
+		{
+			DIR_ENCRYPT,
+			DIR_DECRYPT
+		};
+
+		CryptoTransformImpl(
+			const EVP_CIPHER* pCipher,
+			const ByteVec&    key,
+			const ByteVec&    iv,
+			Direction         dir);
+
+		~CryptoTransformImpl();
+		
+		std::size_t blockSize() const;
+
+		std::streamsize transform(
+			const unsigned char* input,
+			std::streamsize      inputLength,
+			unsigned char*       output,
+			std::streamsize      outputLength);
+		
+		std::streamsize finalize(
+			unsigned char*  output,
+			std::streamsize length);
+
+	private:
+		const EVP_CIPHER* _pCipher;
+		EVP_CIPHER_CTX    _ctx;
+		ByteVec           _key;
+		ByteVec           _iv;
 	};
 
-	CryptoTransformImpl(
+
+	CryptoTransformImpl::CryptoTransformImpl(
 		const EVP_CIPHER* pCipher,
 		const ByteVec&    key,
 		const ByteVec&    iv,
-		Direction         dir);
-
-	~CryptoTransformImpl();
-	
-	std::size_t blockSize() const;
-
-	std::streamsize transform(
-		const unsigned char* input,
-		std::streamsize      inputLength,
-		unsigned char*       output,
-		std::streamsize      outputLength);
-	
-	std::streamsize finalize(
-		unsigned char*  output,
-		std::streamsize length);
-
-private:
-	const EVP_CIPHER* _pCipher;
-	EVP_CIPHER_CTX    _ctx;
-	ByteVec           _key;
-	ByteVec           _iv;
-};
-
-
-CryptoTransformImpl::CryptoTransformImpl(
-	const EVP_CIPHER* pCipher,
-	const ByteVec&    key,
-	const ByteVec&    iv,
-	Direction         dir) :
+		Direction         dir):
 		_pCipher(pCipher),
 		_key(key),
 		_iv(iv)
-{
-	EVP_CipherInit(
-		&_ctx,
-		_pCipher,
-		&_key[0],
-		&_iv[0],
-		(dir == DIR_ENCRYPT) ? 1 : 0);
-}
+	{
+		EVP_CipherInit(
+			&_ctx,
+			_pCipher,
+			&_key[0],
+			&_iv[0],
+			(dir == DIR_ENCRYPT) ? 1 : 0);
+	}
 
 
-CryptoTransformImpl::~CryptoTransformImpl()
-{
-	EVP_CIPHER_CTX_cleanup(&_ctx);
-}
+	CryptoTransformImpl::~CryptoTransformImpl()
+	{
+		EVP_CIPHER_CTX_cleanup(&_ctx);
+	}
 
 
-std::size_t CryptoTransformImpl::blockSize() const
-{
-	return EVP_CIPHER_CTX_block_size(&_ctx);
-}
+	std::size_t CryptoTransformImpl::blockSize() const
+	{
+		return EVP_CIPHER_CTX_block_size(&_ctx);
+	}
 
 
-std::streamsize CryptoTransformImpl::transform(
-	const unsigned char* input,
-	std::streamsize      inputLength,
-	unsigned char*       output,
-	std::streamsize      outputLength)
-{
-	poco_assert (outputLength >= (inputLength + blockSize() - 1));
-	int outLen = static_cast<int>(outputLength);
-	int rc = EVP_CipherUpdate(
-		&_ctx,
-		output,
-		&outLen,
-		input,
-		static_cast<int>(inputLength));
-
-	if (rc == 0)
-		throwError();
-
-	outputLength = static_cast<std::streamsize>(outLen);
-	return outputLength;
-}
+	std::streamsize CryptoTransformImpl::transform(
+		const unsigned char* input,
+		std::streamsize      inputLength,
+		unsigned char*       output,
+		std::streamsize      outputLength)
+	{
+		poco_assert (outputLength >= (inputLength + blockSize() - 1));
 
+		int outLen = static_cast<int>(outputLength);
+		int rc = EVP_CipherUpdate(
+			&_ctx,
+			output,
+			&outLen,
+			input,
+			static_cast<int>(inputLength));
 
-std::streamsize CryptoTransformImpl::finalize(
-	unsigned char*	output,
-	std::streamsize length)
-{
-	poco_assert (length >= blockSize());
-	int len = static_cast<int>(length);
-	// Use the '_ex' version that does not perform implicit cleanup since we
-	// will call EVP_CIPHER_CTX_cleanup() from the dtor as there is no
-	// guarantee that finalize() will be called if an error occurred.
-	int rc = EVP_CipherFinal_ex(&_ctx, output, &len);
-
-	if (rc == 0)
-		throwError();
-	length = static_cast<std::streamsize>(len);
-	return length;
+		if (rc == 0)
+			throwError();
+
+		return static_cast<std::streamsize>(outLen);
+	}
+
+
+	std::streamsize CryptoTransformImpl::finalize(
+		unsigned char*	output,
+		std::streamsize length)
+	{
+		poco_assert (length >= blockSize());
+		
+		int len = static_cast<int>(length);
+
+		// Use the '_ex' version that does not perform implicit cleanup since we
+		// will call EVP_CIPHER_CTX_cleanup() from the dtor as there is no
+		// guarantee that finalize() will be called if an error occurred.
+		int rc = EVP_CipherFinal_ex(&_ctx, output, &len);
+
+		if (rc == 0)
+			throwError();
+			
+		return static_cast<std::streamsize>(len);
+	}
 }
 
 
@@ -184,16 +189,14 @@ CipherImpl::~CipherImpl()
 CryptoTransform* CipherImpl::createEncryptor()
 {
 	CipherKeyImpl::Ptr p = _key.impl();
-	return new CryptoTransformImpl(p->cipher(), p->getKey(), p->getIV(),
-		CryptoTransformImpl::DIR_ENCRYPT);
+	return new CryptoTransformImpl(p->cipher(), p->getKey(), p->getIV(), CryptoTransformImpl::DIR_ENCRYPT);
 }
 
 
 CryptoTransform* CipherImpl::createDecryptor()
 {
 	CipherKeyImpl::Ptr p = _key.impl();
-	return new CryptoTransformImpl(p->cipher(), p->getKey(), p->getIV(),
-		CryptoTransformImpl::DIR_DECRYPT);
+	return new CryptoTransformImpl(p->cipher(), p->getKey(), p->getIV(), CryptoTransformImpl::DIR_DECRYPT);
 }
 
 

+ 2 - 2
Crypto/src/CipherKey.cpp

@@ -1,10 +1,10 @@
 //
 // CipherKey.cpp
 //
-// $Id: //poco/Main/Crypto/src/CipherKey.cpp#1 $
+// $Id: //poco/Main/Crypto/src/CipherKey.cpp#2 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CipherKey
 //
 // Copyright (c) 2007, Applied Informatics Software Engineering GmbH.

+ 8 - 7
Crypto/src/CipherKeyImpl.cpp

@@ -1,10 +1,10 @@
 //
 // CipherKeyImpl.cpp
 //
-// $Id: //poco/Main/Crypto/src/CipherKeyImpl.cpp#1 $
+// $Id: //poco/Main/Crypto/src/CipherKeyImpl.cpp#2 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CipherKeyImpl
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
@@ -56,7 +56,7 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name,
 	_key(),
 	_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();
 	_pCipher = EVP_get_cipherbyname(name.c_str());
 
@@ -76,7 +76,7 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name,
 	_key(),
 	_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();
 	_pCipher = EVP_get_cipherbyname(name.c_str());
 
@@ -93,7 +93,7 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name):
 	_key(),
 	_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();
 	_pCipher = EVP_get_cipherbyname(name.c_str());
 
@@ -104,6 +104,7 @@ CipherKeyImpl::CipherKeyImpl(const std::string& name):
 	generateKey();
 }
 
+
 CipherKeyImpl::~CipherKeyImpl()
 {
 }
@@ -169,7 +170,7 @@ void CipherKeyImpl::generateKey(
 
 	if (!salt.empty())
 	{
-		int len = salt.size();
+		int len = static_cast<int>(salt.size());
 		// Create the salt array from the salt string
 		for (int i = 0; i < 8; ++i)
 			saltBytes[i] = salt.at(i % len);
@@ -183,7 +184,7 @@ void CipherKeyImpl::generateKey(
 		EVP_md5(),
 		(salt.empty() ? 0 : saltBytes),
 		reinterpret_cast<const unsigned char*>(password.data()),
-		password.size(),
+		static_cast<int>(password.size()),
 		iterationCount,
 		keyBytes,
 		ivBytes);

+ 17 - 17
Crypto/src/CryptoStream.cpp

@@ -4,7 +4,7 @@
 // $Id$
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CryptoStream
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
@@ -57,7 +57,7 @@ namespace Crypto {
 CryptoStreamBuf::CryptoStreamBuf(
 	std::istream&	 istr,
 	CryptoTransform* pTransform,
-	std::size_t		 bufferSize) :
+	std::streamsize  bufferSize) :
 		Poco::BufferedStreamBuf(bufferSize, std::ios::in),
 		_pTransform(pTransform),
 		_pIstr(&istr),
@@ -73,7 +73,7 @@ CryptoStreamBuf::CryptoStreamBuf(
 CryptoStreamBuf::CryptoStreamBuf(
 	std::ostream&	 ostr,
 	CryptoTransform* pTransform,
-	std::size_t		 bufferSize) :
+	std::streamsize  bufferSize) :
 		Poco::BufferedStreamBuf(bufferSize, std::ios::out),
 		_pTransform(pTransform),
 		_pIstr(0),
@@ -116,7 +116,7 @@ void CryptoStreamBuf::close()
 		_pOstr = 0;
 		
 		// Finalize transformation.
-		int n = _pTransform->finalize(_buffer.begin(), _buffer.size());
+		int n = _pTransform->finalize(_buffer.begin(), static_cast<std::streamsize>(_buffer.size()));
 		
 		if (n > 0)
 		{
@@ -137,7 +137,7 @@ int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length)
 
 	while (!_eof)
 	{
-		int m = length - count - (_pTransform->blockSize() - 1);
+		int m = static_cast<int>(length) - count - static_cast<int>(_pTransform->blockSize() - 1);
 
 		// Make sure we can read at least one more block. Explicitely check
 		// for m < 0 since blockSize() returns an unsigned int and the
@@ -182,22 +182,22 @@ int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
 	if (!_pOstr)
 		return 0;
 
-	int maxChunkSize = _buffer.size() - (_pTransform->blockSize() - 1);
-	int count = 0;
+	std::size_t maxChunkSize = _buffer.size() - (_pTransform->blockSize() - 1);
+	std::size_t count = 0;
 
 	while (count < length)
 	{
 		// Truncate chunk size so that the maximum output fits into _buffer.
-		int n = length - count;
+		std::size_t n = length - count;
 		if (n > maxChunkSize)
 			n = maxChunkSize;
 
 		// Transform next chunk of data
 		int k = _pTransform->transform(
 			reinterpret_cast<const unsigned char*>(buffer + count),
-			n,
+			static_cast<std::streamsize>(n),
 			_buffer.begin(),
-			_buffer.size());
+			static_cast<std::streamsize>(_buffer.size()));
 
 		// Attention: (n != k) might be true. In count, we have to track how
 		// many bytes from buffer have been consumed, not how many bytes have
@@ -212,7 +212,7 @@ int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
 		}
 	}
 
-	return count;
+	return static_cast<int>(count);
 }
 
 
@@ -224,7 +224,7 @@ int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
 CryptoIOS::CryptoIOS(
 	std::istream&	 istr,
 	CryptoTransform* pTransform,
-	std::size_t		 bufferSize) :
+	std::streamsize  bufferSize) :
 		_buf(istr, pTransform, bufferSize)
 {
 	poco_ios_init(&_buf);
@@ -234,7 +234,7 @@ CryptoIOS::CryptoIOS(
 CryptoIOS::CryptoIOS(
 	std::ostream&	 ostr,
 	CryptoTransform* pTransform,
-	std::size_t		 bufferSize) :
+	std::streamsize  bufferSize) :
 		_buf(ostr, pTransform, bufferSize)
 {
 	poco_ios_init(&_buf);
@@ -260,7 +260,7 @@ CryptoStreamBuf* CryptoIOS::rdbuf()
 CryptoInputStream::CryptoInputStream(
 	std::istream&	 istr,
 	CryptoTransform* pTransform,
-	std::size_t		 bufferSize) :
+	std::streamsize  bufferSize) :
 		CryptoIOS(istr, pTransform, bufferSize),
 		std::istream(&_buf)
 {
@@ -270,7 +270,7 @@ CryptoInputStream::CryptoInputStream(
 CryptoInputStream::CryptoInputStream(
 	std::istream&	 istr,
 	Cipher&          cipher, 
-	std::size_t		 bufferSize) :
+	std::streamsize  bufferSize) :
 		CryptoIOS(istr, cipher.createEncryptor(), bufferSize),
 		std::istream(&_buf)
 {
@@ -290,7 +290,7 @@ CryptoInputStream::~CryptoInputStream()
 CryptoOutputStream::CryptoOutputStream(
 	std::ostream&    ostr,
 	CryptoTransform* pTransform,
-	std::size_t      bufferSize) :
+	std::streamsize  bufferSize) :
 		CryptoIOS(ostr, pTransform, bufferSize),
 		std::ostream(&_buf)
 {
@@ -300,7 +300,7 @@ CryptoOutputStream::CryptoOutputStream(
 CryptoOutputStream::CryptoOutputStream(
 	std::ostream&    ostr, 
 	Cipher&          cipher, 
-	std::size_t      bufferSize):
+	std::streamsize  bufferSize):
 		CryptoIOS(ostr, cipher.createDecryptor(), bufferSize),
 		std::ostream(&_buf)
 {

+ 1 - 1
Crypto/src/CryptoTransform.cpp

@@ -4,7 +4,7 @@
 // $Id$
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: Cipher
 // Module:  CryptoTransform
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.

+ 29 - 27
NetSSL_OpenSSL/src/SSLInitializer.cpp → Crypto/src/OpenSSLInitializer.cpp

@@ -1,11 +1,11 @@
 //
-// SSLInitializer.cpp
+// OpenSSLInitializer.cpp
 //
-// $Id: //poco/Main/NetSSL_OpenSSL/src/SSLInitializer.cpp#11 $
+// $Id: //poco/Main/Crypto/src/OpenSSLInitializer.cpp#1 $
 //
-// Library: NetSSL_OpenSSL
-// Package: SSLCore
-// Module:  SSLInitializer
+// Library: Crypto
+// Package: CryotpCore
+// Module:  OpenSSLInitializer
 //
 // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
 // and Contributors.
@@ -34,14 +34,13 @@
 //
 
 
-#include "Poco/Net/SSLInitializer.h"
-#include "Poco/Net/KeyConsoleHandler.h"
-#include "Poco/Net/KeyFileHandler.h"
+#include "Poco/Crypto/OpenSSLInitializer.h"
 #include "Poco/RandomStream.h"
 #include "Poco/Thread.h"
 #include <openssl/ssl.h>
 #include <openssl/rand.h>
 #include <openssl/crypto.h>
+#include <openssl/err.h>
 
 
 using Poco::RandomInputStream;
@@ -50,29 +49,29 @@ using Poco::FastMutex;
 
 
 namespace Poco {
-namespace Net {
+namespace Crypto {
 
 
-FastMutex* SSLInitializer::_mutexes(0);
-int SSLInitializer::_rc(0);
+FastMutex* OpenSSLInitializer::_mutexes(0);
+int OpenSSLInitializer::_rc(0);
 
 
-static SSLInitializer initializer;
+static OpenSSLInitializer initializer;
 
 
-SSLInitializer::SSLInitializer()
+OpenSSLInitializer::OpenSSLInitializer()
 {
 	initialize();
 }
 
 
-SSLInitializer::~SSLInitializer()
+OpenSSLInitializer::~OpenSSLInitializer()
 {
 	uninitialize();
 }
 
 
-void SSLInitializer::initialize()
+void OpenSSLInitializer::initialize()
 {
 	if (++_rc == 1)
 	{
@@ -86,27 +85,30 @@ void SSLInitializer::initialize()
 		
 		int nMutexes = CRYPTO_num_locks();
 		_mutexes = new FastMutex[nMutexes];
-		CRYPTO_set_locking_callback(&SSLInitializer::lock);
+		CRYPTO_set_locking_callback(&OpenSSLInitializer::lock);
 #ifndef POCO_OS_FAMILY_WINDOWS // SF# 1828231: random unhandled exceptions when linking with ssl
-		CRYPTO_set_id_callback(&SSLInitializer::id);
+		CRYPTO_set_id_callback(&OpenSSLInitializer::id);
 #endif
-		CRYPTO_set_dynlock_create_callback(&SSLInitializer::dynlockCreate);
-		CRYPTO_set_dynlock_lock_callback(&SSLInitializer::dynlock);
-		CRYPTO_set_dynlock_destroy_callback(&SSLInitializer::dynlockDestroy);
+		CRYPTO_set_dynlock_create_callback(&OpenSSLInitializer::dynlockCreate);
+		CRYPTO_set_dynlock_lock_callback(&OpenSSLInitializer::dynlock);
+		CRYPTO_set_dynlock_destroy_callback(&OpenSSLInitializer::dynlockDestroy);
 	}
 }
 
 
-void SSLInitializer::uninitialize()
+void OpenSSLInitializer::uninitialize()
 {
 	if (--_rc == 0)
 	{
+		EVP_cleanup();
+		ERR_free_strings();
+		CRYPTO_set_locking_callback(0);
 		delete [] _mutexes;
 	}
 }
 
 
-void SSLInitializer::lock(int mode, int n, const char* file, int line)
+void OpenSSLInitializer::lock(int mode, int n, const char* file, int line)
 {
 	if (mode & CRYPTO_LOCK)
 		_mutexes[n].lock();
@@ -115,20 +117,20 @@ void SSLInitializer::lock(int mode, int n, const char* file, int line)
 }
 
 
-unsigned long SSLInitializer::id()
+unsigned long OpenSSLInitializer::id()
 {
 	Thread* pThread = Thread::current();
 	return pThread ? pThread->id() : 0;
 }
 
 
-struct CRYPTO_dynlock_value* SSLInitializer::dynlockCreate(const char* file, int line)
+struct CRYPTO_dynlock_value* OpenSSLInitializer::dynlockCreate(const char* file, int line)
 {
 	return new CRYPTO_dynlock_value;
 }
 
 
-void SSLInitializer::dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line)
+void OpenSSLInitializer::dynlock(int mode, struct CRYPTO_dynlock_value* lock, const char* file, int line)
 {
 	poco_check_ptr (lock);
 
@@ -139,10 +141,10 @@ void SSLInitializer::dynlock(int mode, struct CRYPTO_dynlock_value* lock, const
 }
 
 
-void SSLInitializer::dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line)
+void OpenSSLInitializer::dynlockDestroy(struct CRYPTO_dynlock_value* lock, const char* file, int line)
 {
 	delete lock;
 }
 
 
-} } // namespace Poco::Net
+} } // namespace Poco::Crypto

+ 217 - 203
Crypto/src/RSACipherImpl.cpp

@@ -1,10 +1,10 @@
 //
 // RSACipherImpl.cpp
 //
-// $Id: //poco/Main/Crypto/src/RSACipherImpl.cpp#1 $
+// $Id: //poco/Main/Crypto/src/RSACipherImpl.cpp#2 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: RSA
 // Module:  RSACipherImpl
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
@@ -16,14 +16,14 @@
 // 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
@@ -39,7 +39,6 @@
 #include "Poco/Exception.h"
 #include <openssl/err.h>
 #include <openssl/rsa.h>
-#include <string>
 #include <cstring>
 
 
@@ -47,254 +46,269 @@ namespace Poco {
 namespace Crypto {
 
 
-static void throwError()
+namespace
 {
-	unsigned long err;
-	std::string msg;
-
-	while ((err = ERR_get_error()))
+	void throwError()
 	{
-		if (!msg.empty())
-			msg.append("; ");
-		msg.append(ERR_error_string(err, 0));
-	}
+		unsigned long err;
+		std::string msg;
+		
+		while ((err = ERR_get_error()))
+		{
+			if (!msg.empty())
+				msg.append("; ");
+			msg.append(ERR_error_string(err, 0));
+		}
 
-	throw Poco::IOException(msg);
-}
+		throw Poco::IOException(msg);
+	}
 
 
-class RSAEncryptImpl : public CryptoTransform
-{
-public:
-	enum
+	int mapPaddingMode(RSAPaddingMode paddingMode)
 	{
-		OVERFLOW = 11
-	};
-	RSAEncryptImpl(
-		const RSA* pRSA);
-
-	~RSAEncryptImpl();
+		switch (paddingMode)
+		{
+		case RSA_PADDING_PKCS1:
+			return RSA_PKCS1_PADDING;
+		case RSA_PADDING_PKCS1_OAEP:
+			return RSA_PKCS1_OAEP_PADDING;
+		case RSA_PADDING_SSLV23:
+			return RSA_SSLV23_PADDING;
+		case RSA_PADDING_NONE:
+			return RSA_NO_PADDING;
+		default:
+			poco_bugcheck();
+			return RSA_NO_PADDING;
+		}
+	}
 
-	std::size_t blockSize() const;
 
-	std::streamsize transform(
-		const unsigned char* input,
-		std::streamsize		 inputLength,
-		unsigned char*		 output,
-		std::streamsize		 outputLength);
+	class RSAEncryptImpl: public CryptoTransform
+	{
+	public:
+		enum
+		{
+			OVERFLOW = 11
+		};
+		
+		RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode);
+		~RSAEncryptImpl();
+		
+		std::size_t blockSize() const;
+
+		std::streamsize transform(
+			const unsigned char* input,
+			std::streamsize		 inputLength,
+			unsigned char*		 output,
+			std::streamsize		 outputLength);
+		
+		std::streamsize finalize(unsigned char*	output, std::streamsize length);
+
+	private:
+		const RSA*      _pRSA;
+		RSAPaddingMode  _paddingMode;
+		std::streamsize _pos;
+		unsigned char*  _pBuf;
+	};
 
-	std::streamsize finalize(
-		unsigned char*	output,
-		std::streamsize length);
 
-private:
-	std::streamsize _pos;
-	const RSA*      _pRSA;
-	unsigned char*  _pBuf;
-};
+	RSAEncryptImpl::RSAEncryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode):
+			_pRSA(pRSA),
+			_paddingMode(paddingMode),
+			_pos(0),
+			_pBuf(0)
+	{
+		_pBuf = new unsigned char[blockSize()];
+	}
 
 
-RSAEncryptImpl::RSAEncryptImpl(
-	const RSA* pRSA):
-		_pos(0),
-		_pRSA(pRSA),
-		_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::streamsize RSAEncryptImpl::transform(
+		const unsigned char* input,
+		std::streamsize		 inputLength,
+		unsigned char*		 output,
+		std::streamsize		 outputLength)
+	{
+		// always fill up the buffer before writing!
+		std::streamsize rsaSize = static_cast<std::streamsize>(blockSize());
+		poco_assert_dbg(_pos <= rsaSize);
+		poco_assert (outputLength >= rsaSize);
+		int rc = 0;
+		while (inputLength > 0)
+		{
+			// check how many data bytes we are missing to get the buffer full
+			poco_assert_dbg (rsaSize >= _pos);
+			std::streamsize missing = rsaSize - _pos;
+			if (missing == 0)
+			{
+				poco_assert (outputLength >= rsaSize);
+				int tmp = RSA_public_encrypt(rsaSize, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_NO_PADDING);
+				if (tmp == -1)
+					throwError();
+				rc += tmp;
+				output += tmp;
+				outputLength -= tmp;
+				_pos = 0;
+				
+			}
+			else
+			{
+				if (missing > inputLength)
+					missing = inputLength;
+
+				std::memcpy(_pBuf+_pos, input, missing);
+				input += missing;
+				_pos += missing;
+				inputLength -= missing;
+			}
+		}
 
+		return rc;
+	}
 
-std::streamsize RSAEncryptImpl::transform(
-	const unsigned char* input,
-	std::streamsize		 inputLength,
-	unsigned char*		 output,
-	std::streamsize		 outputLength)
-{
 
-	// always fill up the buffer before writing!
-	std::streamsize rsaSize = blockSize();
-	poco_assert_dbg(_pos <= rsaSize);
-	poco_assert (outputLength >= rsaSize);
-	int rc = 0;
-	while (inputLength > 0)
+	std::streamsize RSAEncryptImpl::finalize(unsigned char*	output, std::streamsize length)
 	{
-		// check how many data bytes we are missing to get the buffer full
-		poco_assert_dbg (rsaSize >= _pos);
-		std::streamsize missing = rsaSize - _pos;
-		if (missing == 0)
+		poco_assert (length >= blockSize());
+		int rc = 0;
+		if (_pos > 0)
 		{
-			poco_assert (outputLength >= rsaSize);
-			int tmp = RSA_public_encrypt(rsaSize, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_NO_PADDING);
-			if (tmp == -1)
+			rc = RSA_public_encrypt(_pos, _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
+			if (rc == -1)
 				throwError();
-			rc += tmp;
-			output += tmp;
-			outputLength -= tmp;
-			_pos = 0;
-
 		}
-		else
-		{
-			if (missing > inputLength)
-				missing = inputLength;
 
-			std::memcpy(_pBuf+_pos, input, missing);
-			input += missing;
-			_pos += missing;
-			inputLength -= missing;
-		}
+		return rc;
 	}
 
-	return rc;
-}
+
+	class RSADecryptImpl: public CryptoTransform
+	{
+	public:
+		enum
+		{
+			OVERFLOW = 11
+		};
+		
+		RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode);
+		~RSADecryptImpl();
+		
+		std::size_t blockSize() const;
+
+		std::streamsize transform(
+			const unsigned char* input,
+			std::streamsize		 inputLength,
+			unsigned char*		 output,
+			std::streamsize		 outputLength);
+		
+		std::streamsize finalize(
+			unsigned char*	output,
+			std::streamsize length);
+
+	private:
+		const RSA*      _pRSA;
+		RSAPaddingMode  _paddingMode;
+		std::streamsize _pos;
+		unsigned char*  _pBuf;
+	};
 
 
-std::streamsize RSAEncryptImpl::finalize(
-	unsigned char*	output,
-	std::streamsize length)
-{
-	poco_assert (length >= blockSize());
-	int rc = 0;
-	if (_pos > 0)
+	RSADecryptImpl::RSADecryptImpl(const RSA* pRSA, RSAPaddingMode paddingMode):
+			_pRSA(pRSA),
+			_paddingMode(paddingMode),
+			_pos(0),
+			_pBuf(0)
 	{
-		rc = RSA_public_encrypt(_pos, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_PKCS1_PADDING);
-		if (rc == -1)
-			throwError();
+		_pBuf = new unsigned char[blockSize()];
 	}
 
-	return rc;
-}
-
 
+	RSADecryptImpl::~RSADecryptImpl()
+	{
+		delete _pBuf;
+	}
 
 
-class RSADecryptImpl : public CryptoTransform
-{
-public:
-	enum
+	std::size_t RSADecryptImpl::blockSize() const
 	{
-		OVERFLOW = 11
-	};
-	RSADecryptImpl(
-		const RSA* pRSA);
-
-	~RSADecryptImpl();
+		return RSA_size(_pRSA);
+	}
 
-	std::size_t blockSize() const;
 
-	std::streamsize transform(
+	std::streamsize RSADecryptImpl::transform(
 		const unsigned char* input,
 		std::streamsize		 inputLength,
 		unsigned char*		 output,
-		std::streamsize		 outputLength);
-
-	std::streamsize finalize(
-		unsigned char*	output,
-		std::streamsize length);
-
-private:
-	std::streamsize _pos;
-	const RSA*      _pRSA;
-	unsigned char*  _pBuf;
-};
-
-
-RSADecryptImpl::RSADecryptImpl(
-	const RSA* pRSA):
-		_pos(0),
-		_pRSA(pRSA),
-		_pBuf(0)
-{
-	_pBuf = new unsigned char[blockSize()];
-}
-
-
-RSADecryptImpl::~RSADecryptImpl()
-{
-	delete _pBuf;
-}
-
-
-std::size_t RSADecryptImpl::blockSize() const
-{
-	return RSA_size(_pRSA);
-}
+		std::streamsize		 outputLength)
+	{
+		
+		// always fill up the buffer before decrypting!
+		std::streamsize rsaSize = static_cast<std::streamsize>(blockSize());
+		poco_assert_dbg(_pos <= rsaSize);
+		poco_assert (outputLength >= rsaSize);
+		int rc = 0;
+		while (inputLength > 0)
+		{
+			// check how many data bytes we are missing to get the buffer full
+			poco_assert_dbg (rsaSize >= _pos);
+			std::streamsize missing = rsaSize - _pos;
+			if (missing == 0)
+			{
+				int tmp = RSA_private_decrypt(rsaSize, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_NO_PADDING);
+				if (tmp == -1)
+					throwError();
+				rc += tmp;
+				output += tmp;
+				outputLength -= tmp;
+				_pos = 0;
+				
+			}
+			else
+			{
+				if (missing > inputLength)
+					missing = inputLength;
+
+				std::memcpy(_pBuf+_pos, input, missing);
+				input += missing;
+				_pos += missing;
+				inputLength -= missing;
+			}
+		}
 
+		return rc;
+	}
 
-std::streamsize RSADecryptImpl::transform(
-	const unsigned char* input,
-	std::streamsize		 inputLength,
-	unsigned char*		 output,
-	std::streamsize		 outputLength)
-{
 
-	// always fill up the buffer before decrypting!
-	std::streamsize rsaSize = blockSize();
-	poco_assert_dbg(_pos <= rsaSize);
-	poco_assert (outputLength >= rsaSize);
-	int rc = 0;
-while (inputLength > 0)
+	std::streamsize RSADecryptImpl::finalize(unsigned char*	output, std::streamsize length)
 	{
-		// check how many data bytes we are missing to get the buffer full
-		poco_assert_dbg (rsaSize >= _pos);
-		std::streamsize missing = rsaSize - _pos;
-		if (missing == 0)
+		poco_assert (length >= blockSize());
+		int rc = 0;
+		if (_pos > 0)
 		{
-			int tmp = RSA_private_decrypt(rsaSize, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_NO_PADDING);
-			if (tmp == -1)
+			rc = RSA_private_decrypt(_pos, _pBuf, output, const_cast<RSA*>(_pRSA), mapPaddingMode(_paddingMode));
+			if (rc == -1)
 				throwError();
-			rc += tmp;
-			output += tmp;
-			outputLength -= tmp;
-			_pos = 0;
-
 		}
-		else
-		{
-			if (missing > inputLength)
-				missing = inputLength;
 
-			std::memcpy(_pBuf+_pos, input, missing);
-			input += missing;
-			_pos += missing;
-			inputLength -= missing;
-		}
+		return rc;
 	}
-
-	return rc;
 }
 
 
-std::streamsize RSADecryptImpl::finalize(
-	unsigned char*	output,
-	std::streamsize length)
-{
-	poco_assert (length >= blockSize());
-	int rc = 0;
-	if (_pos > 0)
-	{
-		rc = RSA_private_decrypt(_pos, _pBuf, output, const_cast<RSA*>(_pRSA), RSA_PKCS1_PADDING);
-		if (rc == -1)
-			throwError();
-	}
-
-	return rc;
-}
-
-RSACipherImpl::RSACipherImpl(const RSAKey& key):
-	_key(key)
+RSACipherImpl::RSACipherImpl(const RSAKey& key, RSAPaddingMode paddingMode):
+	_key(key),
+	_paddingMode(paddingMode)
 {
 }
 
@@ -306,13 +320,13 @@ RSACipherImpl::~RSACipherImpl()
 
 CryptoTransform* RSACipherImpl::createEncryptor()
 {
-	return new RSAEncryptImpl(_key.impl()->getRSA());
+	return new RSAEncryptImpl(_key.impl()->getRSA(), _paddingMode);
 }
 
 
 CryptoTransform* RSACipherImpl::createDecryptor()
 {
-	return new RSADecryptImpl(_key.impl()->getRSA());
+	return new RSADecryptImpl(_key.impl()->getRSA(), _paddingMode);
 }
 
 

+ 30 - 23
Crypto/src/RSADigestEngine.cpp

@@ -1,10 +1,10 @@
 //
 // RSADigestEngine.cpp
 //
-// $Id: //poco/Main/Crypto/src/RSADigestEngine.cpp#2 $
+// $Id: //poco/Main/Crypto/src/RSADigestEngine.cpp#3 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: RSA
 // Module:  RSADigestEngine
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
@@ -42,12 +42,11 @@ namespace Poco {
 namespace Crypto {
 
 
-RSADigestEngine::RSADigestEngine(const RSAKey& key):
+RSADigestEngine::RSADigestEngine(const RSAKey& key, DigestType digestType):
 	_key(key),
-	_sig(),
-	_sha1()
+	_engine(digestType == DIGEST_MD5 ? static_cast<Poco::DigestEngine&>(_md5Engine) : static_cast<Poco::DigestEngine&>(_sha1Engine)),
+	_type(digestType == DIGEST_MD5 ? NID_md5 : NID_sha1)
 {
-	_sig = DigestEngine::Digest(key.size());
 }
 
 
@@ -58,48 +57,56 @@ RSADigestEngine::~RSADigestEngine()
 
 unsigned RSADigestEngine::digestLength() const
 {
-	return _sha1.digestLength();
+	return _engine.digestLength();
 }
 
 
 void RSADigestEngine::reset()
 {
-	_sha1.reset();
-	_sig = DigestEngine::Digest(_key.size());
+	_engine.reset();
+	_digest.clear();
+	_signature.clear();
 }
 
 	
 const DigestEngine::Digest& RSADigestEngine::digest()
 {
-	return _sha1.digest();
+	if (_digest.empty())
+	{
+		_digest = _engine.digest();
+	}
+	return _digest;
 }
 
 
 const DigestEngine::Digest& RSADigestEngine::signature()
 {
-	const DigestEngine::Digest& digest = _sha1.digest();
-	unsigned int sigLen = _sig.size();
-	RSA_sign(NID_sha1, &digest[0], (unsigned int)digest.size(), &_sig[0], &sigLen, _key.impl()->getRSA());
-	// truncate _sig to sigLen
-	if (sigLen < _sig.size())
-		_sig.resize(sigLen);
-    return _sig;
+	if (_signature.empty())
+	{
+		digest();
+		_signature.resize(_key.size());
+		unsigned sigLen = static_cast<unsigned>(_signature.size());
+		RSA_sign(_type, &_digest[0], static_cast<unsigned>(_digest.size()), &_signature[0], &sigLen, _key.impl()->getRSA());
+		// truncate _sig to sigLen
+		if (sigLen < _signature.size())
+			_signature.resize(sigLen);
+	}
+    return _signature;
 }
 
 	
-void RSADigestEngine::verify(const DigestEngine::Digest& sig)
+bool RSADigestEngine::verify(const DigestEngine::Digest& sig)
 {
-	const DigestEngine::Digest& digest = _sha1.digest();
+	digest();
 	DigestEngine::Digest sigCpy = sig; // copy becausse RSA_verify can modify sigCpy
-	int ret = RSA_verify(NID_sha1, &digest[0], (unsigned int)digest.size(), &sigCpy[0], (unsigned int)sigCpy.size(), _key.impl()->getRSA());
-	if (ret == 0)
-		throw Poco::DataFormatException("Signature does not match");
+	int ret = RSA_verify(_type, &_digest[0], static_cast<unsigned>(_digest.size()), &sigCpy[0], static_cast<unsigned>(sigCpy.size()), _key.impl()->getRSA());
+	return ret != 0;
 }
 
 
 void RSADigestEngine::updateImpl(const void* data, unsigned length)
 {
-	_sha1.update(data, length);
+	_engine.update(data, length);
 }
 
 

+ 13 - 14
Crypto/src/RSAKey.cpp

@@ -1,10 +1,10 @@
 //
 // RSAKey.cpp
 //
-// $Id: //poco/Main/Crypto/src/RSAKey.cpp#3 $
+// $Id: //poco/Main/Crypto/src/RSAKey.cpp#4 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: RSA
 // Module:  RSAKey
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
@@ -42,7 +42,7 @@ namespace Poco {
 namespace Crypto {
 
 
-RSAKey::RSAKey(const Poco::Net::X509Certificate& cert):
+RSAKey::RSAKey(const X509Certificate& cert):
 	_pImpl(new RSAKeyImpl(cert))
 {
 }
@@ -53,22 +53,20 @@ RSAKey::RSAKey(KeyLength keyLength, Exponent exp):
 {
 	int keyLen = keyLength;
 	unsigned long expVal = RSA_3;
-	if (exp == EXP_LARGE)
+	if (expVal == EXP_LARGE)
 		expVal = RSA_F4;
 	_pImpl = new RSAKeyImpl(keyLen, expVal);
 }
 
 
-RSAKey::RSAKey(const std::string& publicKey, const std::string& privateKeyFile, const std::string& pwd):
-	_pImpl(new RSAKeyImpl(publicKey, privateKeyFile, pwd))
+RSAKey::RSAKey(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase):
+	_pImpl(new RSAKeyImpl(publicKeyFile, privateKeyFile, privateKeyPassphrase))
 {
 }
 
 
-RSAKey::RSAKey(std::istream* pPubKey, 
-		std::istream* pPrivKey, 
-		const std::string& privateKeyPwd):
-	_pImpl(new RSAKeyImpl(pPubKey, pPrivKey, privateKeyPwd))
+RSAKey::RSAKey(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
+	_pImpl(new RSAKeyImpl(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase))
 {
 }
 
@@ -83,15 +81,16 @@ int RSAKey::size() const
 	return _pImpl->size();
 }
 
-void RSAKey::save(const std::string& pubKeyFile, const std::string& privKeyFile, const std::string& privKeyPwd)
+
+void RSAKey::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
 {
-	_pImpl->save(pubKeyFile, privKeyFile, privKeyPwd);
+	_pImpl->save(publicKeyFile, privateKeyFile, privateKeyPassphrase);
 }
 
 
-void RSAKey::save(std::ostream* pPubKey, std::ostream* pPrivKey, const std::string& privateKeyPwd)
+void RSAKey::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase)
 {
-	_pImpl->save(pPubKey, pPrivKey, privateKeyPwd);
+	_pImpl->save(pPublicKeyStream, pPrivateKeyStream, privateKeyPassphrase);
 }
 
 

+ 109 - 90
Crypto/src/RSAKeyImpl.cpp

@@ -1,10 +1,10 @@
 //
 // RSAKeyImpl.cpp
 //
-// $Id: //poco/Main/Crypto/src/RSAKeyImpl.cpp#2 $
+// $Id: //poco/Main/Crypto/src/RSAKeyImpl.cpp#3 $
 //
 // Library: Crypto
-// Package: CryptoCore
+// Package: RSA
 // Module:  RSAKeyImpl
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
@@ -35,11 +35,10 @@
 
 
 #include "Poco/Crypto/RSAKeyImpl.h"
+#include "Poco/Crypto/X509Certificate.h"
 #include "Poco/FileStream.h"
 #include "Poco/StreamCopier.h"
 #include "Poco/TemporaryFile.h"
-#include "Poco/Net/SSLManager.h"
-#include "Poco/Net/X509Certificate.h"
 #include <openssl/pem.h>
 #include <openssl/rsa.h>
 
@@ -48,7 +47,7 @@ namespace Poco {
 namespace Crypto {
 
 
-RSAKeyImpl::RSAKeyImpl(const Poco::Net::X509Certificate& cert):
+RSAKeyImpl::RSAKeyImpl(const X509Certificate& cert):
 	_pRSA(0)
 {
 	const X509* pCert = cert.certificate();
@@ -62,11 +61,10 @@ RSAKeyImpl::RSAKeyImpl(const Poco::Net::X509Certificate& cert):
 RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent):
 	_pRSA(0)
 {
-	//dummy access to SSLMananger so that the SSLInitializer of NetSSL gets called!
-	Poco::Net::SSLManager::instance();
+#if OPENSSL_VERSION_NUMBER >= 0x00908000L
 	_pRSA = RSA_new();
 	int ret = 0;
-	BIGNUM *bn = 0;
+	BIGNUM* bn = 0;
 	try
 	{
 		bn = BN_new();
@@ -74,109 +72,108 @@ RSAKeyImpl::RSAKeyImpl(int keyLength, unsigned long exponent):
 		ret = RSA_generate_key_ex(_pRSA, keyLength, bn, 0);
 		BN_free(bn);
 	}
-	catch(...)
+	catch (...)
 	{
 		BN_free(bn);
 		throw;
 	}
-	if (!ret)
-		throw Poco::InvalidArgumentException("Failed to create RSA context");
+	if (!ret) throw Poco::InvalidArgumentException("Failed to create RSA context");
+#else
+	_pRSA = RSA_generate_key(keyLength, exponent, 0, 0);
+	if (!_pRSA) throw Poco::InvalidArgumentException("Failed to create RSA context");
+#endif
 }
 
 
 RSAKeyImpl::RSAKeyImpl(
-		const std::string& publicKey, 
+		const std::string& publicKeyFile, 
 		const std::string& privateKeyFile, 
-		const std::string& privateKeyPwd):
+		const std::string& privateKeyPassphrase):
 	_pRSA(0)
 {
-	//dummy access to SSLMananger so that the SSLInitializer of NetSSL gets called!
-	Poco::Net::SSLManager::instance();
-	init(publicKey, privateKeyFile, privateKeyPwd);
+	init(publicKeyFile, privateKeyFile, privateKeyPassphrase);
 }
 
 
-RSAKeyImpl::RSAKeyImpl(std::istream* pubKey, std::istream* privKey, const std::string& privKeyPwd):
+RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase):
 	_pRSA(0)
 {
-	//dummy access to SSLMananger so that the SSLInitializer of NetSSL gets called!
-	Poco::Net::SSLManager::instance();
 	// due to C lib not supporting streams, we create two temporary files
-	std::string pubKeyFile;
+	std::string publicKeyFile;
 	Poco::TemporaryFile pubFile;
-	if (pubKey)
+	if (pPublicKeyStream)
 	{
 		if (!pubFile.createFile())
-			throw Poco::FileException("No temporary file could be created for public file!");
-		pubKeyFile = pubFile.path();
-		Poco::FileOutputStream fout(pubKeyFile);
-		Poco::StreamCopier::copyStream(*pubKey, fout);
+			throw Poco::CreateFileException("Cannot create temporary file for writing public key");
+		publicKeyFile = pubFile.path();
+		Poco::FileOutputStream fout(publicKeyFile);
+		Poco::StreamCopier::copyStream(*pPublicKeyStream, fout);
 	}
-	std::string privKeyFile;
+	std::string privateKeyFile;
 	Poco::TemporaryFile privFile;
-	if (privKey)
+	if (pPrivateKeyStream)
 	{
 		if (!privFile.createFile())
-			throw Poco::FileException("No temporary file could be created for private file!");
-		privKeyFile = privFile.path();
-		Poco::FileOutputStream fout(privKeyFile);
-		Poco::StreamCopier::copyStream(*privKey, fout);
+			throw Poco::CreateFileException("Cannot create temporary file for writing private key");
+		privateKeyFile = privFile.path();
+		Poco::FileOutputStream fout(privateKeyFile);
+		Poco::StreamCopier::copyStream(*pPrivateKeyStream, fout);
 
 	}
-	init(pubKeyFile, privKeyFile, privKeyPwd);
+	init(publicKeyFile, privateKeyFile, privateKeyPassphrase);
 }
 
 
-void RSAKeyImpl::init(const std::string& pubKeyFile, const std::string& privKeyFile, const std::string& privKeyPwd)
+void RSAKeyImpl::init(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
 {
 	poco_assert_dbg(_pRSA == 0);
+	
 	_pRSA = RSA_new();
-	if (!pubKeyFile.empty())
+	if (!publicKeyFile.empty())
 	{
-		BIO *out=BIO_new(BIO_s_file());
-		const char* pFN = pubKeyFile.c_str();
-		BIO_read_filename(out, (void*)pFN);
-		if (out)
+		BIO* out = BIO_new(BIO_s_file());
+		if (!out) throw Poco::IOException("Cannot create BIO for reading public key", publicKeyFile);
+		int rc = BIO_read_filename(out, publicKeyFile.c_str());
+		if (rc)
 		{
 			RSA* pubKey = PEM_read_bio_RSAPublicKey(out, &_pRSA, 0, 0);
 			BIO_free(out);
 			if (!pubKey)
 			{
 				freeRSA();
-				throw Poco::FileException("Failed to load public key: " + pubKeyFile);
+				throw Poco::FileException("Failed to load public key", publicKeyFile);
 			}
 		}
 		else
 		{
 			freeRSA();
-			throw Poco::FileNotFoundException("Public key file not found: " + pubKeyFile);
+			throw Poco::FileNotFoundException("Public key file", publicKeyFile);
 		}
 	}
 
-	if (!privKeyFile.empty())
+	if (!privateKeyFile.empty())
 	{
-		BIO* out=BIO_new(BIO_s_file());
-		const char* pFN = privKeyFile.c_str();
-		BIO_read_filename(out, (void*)pFN);
-		
-		if (out)
+		BIO* out = BIO_new(BIO_s_file());
+		if (!out) throw Poco::IOException("Cannot create BIO for reading private key", privateKeyFile);
+		int rc = BIO_read_filename(out, privateKeyFile.c_str());
+		if (rc)
 		{
 			RSA* privKey = 0;
-			if (privKeyPwd.empty())
+			if (privateKeyPassphrase.empty())
 				privKey = PEM_read_bio_RSAPrivateKey(out, &_pRSA, 0, 0);
 			else
-				privKey = PEM_read_bio_RSAPrivateKey(out, &_pRSA, 0, (void*)privKeyPwd.c_str());
+				privKey = PEM_read_bio_RSAPrivateKey(out, &_pRSA, 0, const_cast<char*>(privateKeyPassphrase.c_str()));
 			BIO_free(out);
 			if (!privKey)
 			{
 				freeRSA();
-				throw Poco::FileException("Failed to load private key: " + privKeyFile);
+				throw Poco::FileException("Failed to load private key", privateKeyFile);
 			}
 		}
 		else
 		{
 			freeRSA();
-			throw Poco::FileNotFoundException("Private key file not found: " + privKeyFile);
+			throw Poco::FileNotFoundException("Private key file", privateKeyFile);
 		}
 	}
 }
@@ -184,6 +181,7 @@ void RSAKeyImpl::init(const std::string& pubKeyFile, const std::string& privKeyF
 
 RSAKeyImpl::~RSAKeyImpl()
 {
+	freeRSA();
 }
 
 
@@ -201,70 +199,91 @@ int RSAKeyImpl::size() const
 }
 
 
-
-
-void RSAKeyImpl::save(const std::string& pubKeyFile, const std::string& privKeyFile, const std::string& privKeyPwd)
+void RSAKeyImpl::save(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase)
 {
-	if (!pubKeyFile.empty())
+	if (!publicKeyFile.empty())
 	{
-		BIO *out=BIO_new(BIO_s_file());
-		const char* pFN = pubKeyFile.c_str();
-		BIO_write_filename(out, (void*)pFN);
-		if (!PEM_write_bio_RSAPublicKey(out,_pRSA))
-			throw Poco::FileException("Failed to write public key to file:" + pubKeyFile);
+		BIO* out = BIO_new(BIO_s_file());
+		if (!out) throw Poco::IOException("Cannot create BIO for writing public key file", publicKeyFile);
+		try
+		{
+			if (BIO_write_filename(out, const_cast<char*>(publicKeyFile.c_str())))
+			{
+				if (!PEM_write_bio_RSAPublicKey(out, _pRSA))
+					throw Poco::WriteFileException("Failed to write public key to file", publicKeyFile);
+			}
+			else throw Poco::CreateFileException("Cannot create public key file");
+		}
+		catch (...)
+		{
+			BIO_free(out);
+			throw;
+		}
 		BIO_free(out);
 	}
-	if (!privKeyFile.empty())
+	
+	if (!privateKeyFile.empty())
 	{
-		BIO *out=BIO_new(BIO_s_file());
-		const char* pFN = privKeyFile.c_str();
-		BIO_write_filename(out, (void*)pFN);
-
-		int ret = 0;
-		if (privKeyPwd.empty())
-			ret = PEM_write_bio_RSAPrivateKey(out, _pRSA, EVP_des_ede3_cbc(), 0, 0, 0, 0);
-		else
-			ret = PEM_write_bio_RSAPrivateKey(out, _pRSA, EVP_des_ede3_cbc(), (unsigned char *)privKeyPwd.c_str(), privKeyPwd.length(), 0, 0);
-
-		if (!ret)
-			throw Poco::FileException("Failed to write private key to file:" + privKeyFile);
+		BIO* out = BIO_new(BIO_s_file());
+		if (!out) throw Poco::IOException("Cannot create BIO for writing private key file", privateKeyFile);
+		try
+		{
+			if (BIO_write_filename(out, const_cast<char*>(privateKeyFile.c_str())))
+			{
+				int rc = 0;
+				if (privateKeyPassphrase.empty())
+					rc = PEM_write_bio_RSAPrivateKey(out, _pRSA, EVP_des_ede3_cbc(), 0, 0, 0, 0);
+				else
+					rc = PEM_write_bio_RSAPrivateKey(out, _pRSA, EVP_des_ede3_cbc(), 
+						reinterpret_cast<unsigned char*>(const_cast<char*>(privateKeyPassphrase.c_str())), 
+						static_cast<int>(privateKeyPassphrase.length()), 0, 0);
+				if (!rc) throw Poco::FileException("Failed to write private key to file", privateKeyFile);
+			}
+			else throw Poco::CreateFileException("Cannot create private key file", privateKeyFile);
+		}
+		catch (...)
+		{
+			BIO_free(out);
+			throw;
+		}
 		BIO_free(out);
 	}
 }
 
 
-void RSAKeyImpl::save(std::ostream* pPubKey, std::ostream* pPrivKey, const std::string& privateKeyPwd)
+void RSAKeyImpl::save(std::ostream* pPublicKeyStream, std::ostream* pPrivateKeyStream, const std::string& privateKeyPassphrase)
 {
-	if (!pPubKey && !pPrivKey)
-		return;
+	if (!pPublicKeyStream && !pPrivateKeyStream) return;
+	
 	// due to C lib not supporting streams, we create two temporary files
-	std::string pubKeyFile;
+	std::string publicKeyFile;
 	Poco::TemporaryFile pubFile;
-	if (pPubKey)
+	if (pPublicKeyStream)
 	{
-		pubKeyFile = pubFile.path();
+		publicKeyFile = pubFile.path();
 		if (!pubFile.createFile())
-			throw Poco::FileException("No temporary file could be created for public file!");
+			throw Poco::CreateFileException("Cannot create temporary public file");
 	}
-	std::string privKeyFile;
+	std::string privateKeyFile;
 	Poco::TemporaryFile privFile;
-	if (pPrivKey)
+	if (pPrivateKeyStream)
 	{
+		privateKeyFile = privFile.path();
 		if (!privFile.createFile())
-			throw Poco::FileException("No temporary file could be created for private file!");
-		privKeyFile = privFile.path();
+			throw Poco::FileException("Cannot crate temporary private key file");
 	}
-	save(pubKeyFile, privKeyFile, privateKeyPwd);
+	save(publicKeyFile, privateKeyFile, privateKeyPassphrase);
+	
 	// now copy everything from the temp files to the original streams
-	if (pPubKey)
+	if (pPublicKeyStream)
 	{
-		Poco::FileInputStream fPub(pubKeyFile);
-		Poco::StreamCopier::copyStream(fPub, *pPubKey);
+		Poco::FileInputStream istr(publicKeyFile);
+		Poco::StreamCopier::copyStream(istr, *pPublicKeyStream);
 	}
-	if (pPrivKey)
+	if (pPrivateKeyStream)
 	{
-		Poco::FileInputStream fPriv(privKeyFile);
-		Poco::StreamCopier::copyStream(fPriv, *pPrivKey);
+		Poco::FileInputStream istr(privateKeyFile);
+		Poco::StreamCopier::copyStream(istr, *pPrivateKeyStream);
 	}
 }
 

+ 290 - 0
Crypto/src/X509Certificate.cpp

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

+ 1 - 1
Crypto/testsuite/Makefile

@@ -1,7 +1,7 @@
 #
 # Makefile
 #
-# $Id: //poco/Main/Crypto/testsuite/Makefile#1 $
+# $Id: //poco/Main/Crypto/testsuite/Makefile#2 $
 #
 # Makefile for Poco Crypto testsuite
 #

+ 120 - 2
Crypto/testsuite/TestSuite_VS71.vcproj

@@ -20,7 +20,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\NetSSL_OpenSSL\include;..\..\Net\include"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -81,7 +81,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\NetSSL_OpenSSL\include;..\..\Net\include"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -128,6 +128,124 @@
 			<Tool
 				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
+		<Configuration
+			Name="debug_static|Win32"
+			OutputDirectory="obj\debug_static"
+			IntermediateDirectory="obj\debug_static"
+			ConfigurationType="1"
+			UseOfMFC="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\Crypto\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				BufferSecurityCheck="TRUE"
+				TreatWChar_tAsBuiltInType="TRUE"
+				ForceConformanceInForLoopScope="TRUE"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CppUnitmtd.lib WinTestRunnermtd.lib PocoCryptomtd.lib PocoFoundationmtd.lib libeay32mtd.lib ssleay32mtd.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\debug_static\WinTestRunner.res"
+				OutputFile="bin/TestSuitemtd.exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="..\..\lib"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="bin/TestSuitemtd.pdb"
+				SubSystem="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="release_static|Win32"
+			OutputDirectory="obj\release_static"
+			IntermediateDirectory="obj\release_static"
+			ConfigurationType="1"
+			UseOfMFC="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="4"
+				InlineFunctionExpansion="1"
+				EnableIntrinsicFunctions="TRUE"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="TRUE"
+				OptimizeForWindowsApplication="TRUE"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\Crypto\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
+				StringPooling="TRUE"
+				RuntimeLibrary="2"
+				BufferSecurityCheck="FALSE"
+				TreatWChar_tAsBuiltInType="TRUE"
+				ForceConformanceInForLoopScope="TRUE"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CppUnitmt.lib WinTestRunnermt.lib PocoCryptomt.lib PocoFoundationmt.lib libeay32mt.lib ssleay32mt.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\release_static\WinTestRunner.res"
+				OutputFile="bin/TestSuitemt.exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="..\..\lib"
+				GenerateDebugInformation="FALSE"
+				ProgramDatabaseFile=""
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>

+ 179 - 2
Crypto/testsuite/TestSuite_VS80.vcproj

@@ -40,7 +40,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\NetSSL_OpenSSL\include;..\..\Net\include"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -129,7 +129,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\NetSSL_OpenSSL\include;..\..\Net\include"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				StringPooling="true"
 				RuntimeLibrary="2"
@@ -189,6 +189,183 @@
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
+		<Configuration
+			Name="release_static|Win32"
+			OutputDirectory="obj\release_static"
+			IntermediateDirectory="obj\release_static"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="4"
+				InlineFunctionExpansion="1"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\Crypto\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				BufferSecurityCheck="false"
+				TreatWChar_tAsBuiltInType="true"
+				ForceConformanceInForLoopScope="true"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CppUnitmt.lib WinTestRunnermt.lib PocoCryptomt.lib PocoFoundationmt.lib libeay32mt.lib ssleay32mt.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\release_static\WinTestRunner.res"
+				OutputFile="bin/TestSuitemt.exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="..\..\lib"
+				GenerateDebugInformation="false"
+				ProgramDatabaseFile=""
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="debug_static|Win32"
+			OutputDirectory="obj\debug_static"
+			IntermediateDirectory="obj\debug_static"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\Crypto\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				BufferSecurityCheck="true"
+				TreatWChar_tAsBuiltInType="true"
+				ForceConformanceInForLoopScope="true"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CppUnitmtd.lib WinTestRunnermtd.lib PocoCryptomtd.lib PocoFoundationmtd.lib libeay32mtd.lib ssleay32mtd.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\debug_static\WinTestRunner.res"
+				OutputFile="bin/TestSuitemtd.exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="..\..\lib"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile="bin/TestSuitemtd.pdb"
+				SubSystem="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>

+ 173 - 2
Crypto/testsuite/TestSuite_VS90.vcproj

@@ -41,7 +41,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\NetSSL_OpenSSL\include;..\..\Net\include"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -129,7 +129,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\NetSSL_OpenSSL\include;..\..\Net\include"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				StringPooling="true"
 				RuntimeLibrary="2"
@@ -188,6 +188,177 @@
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
+		<Configuration
+			Name="release_static|Win32"
+			OutputDirectory="obj\release_static"
+			IntermediateDirectory="obj\release_static"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="4"
+				InlineFunctionExpansion="1"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\Crypto\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				BufferSecurityCheck="false"
+				TreatWChar_tAsBuiltInType="true"
+				ForceConformanceInForLoopScope="true"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="false"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CppUnitmt.lib WinTestRunnermt.lib PocoCryptomt.lib PocoFoundationmt.lib libeay32mt.lib ssleay32mt.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\release_static\WinTestRunner.res"
+				OutputFile="bin/TestSuitemt.exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="..\..\lib"
+				GenerateDebugInformation="false"
+				ProgramDatabaseFile=""
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="debug_static|Win32"
+			OutputDirectory="obj\debug_static"
+			IntermediateDirectory="obj\debug_static"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\Crypto\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				BufferSecurityCheck="true"
+				TreatWChar_tAsBuiltInType="true"
+				ForceConformanceInForLoopScope="true"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="false"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="CppUnitmtd.lib WinTestRunnermtd.lib PocoCryptomtd.lib PocoFoundationmtd.lib libeay32mtd.lib ssleay32mtd.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\debug_static\WinTestRunner.res"
+				OutputFile="bin/TestSuitemtd.exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="..\..\lib"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile="bin/TestSuitemtd.pdb"
+				SubSystem="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>

+ 64 - 5
Crypto/testsuite/src/CryptoTest.cpp

@@ -1,7 +1,7 @@
 //
 // CryptoTest.cpp
 //
-// $Id: //poco/Main/Crypto/testsuite/src/CryptoTest.cpp#2 $
+// $Id: //poco/Main/Crypto/testsuite/src/CryptoTest.cpp#3 $
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
 // and Contributors.
@@ -36,11 +36,42 @@
 #include "Poco/Crypto/CipherFactory.h"
 #include "Poco/Crypto/Cipher.h"
 #include "Poco/Crypto/CipherKey.h"
+#include "Poco/Crypto/X509Certificate.h"
+#include <sstream>
 
 
 using namespace Poco::Crypto;
 
 
+static const std::string APPINF_PEM(
+	"-----BEGIN CERTIFICATE-----\n"
+	"MIIESzCCAzOgAwIBAgIBATALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu\n"
+	"Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n\n"
+	"aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh\n"
+	"cmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl\n"
+	"bnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu\n"
+	"Y29tMB4XDTA5MDUwNzE0NTY1NloXDTI5MDUwMjE0NTY1NlowgdMxEzARBgNVBAMM\n"
+	"CmFwcGluZi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdh\n"
+	"cmUgRW5naW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNV\n"
+	"BAgMCUNhcmludGhpYTELMAkGA1UEBhMCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBp\n"
+	"bSBSb3NlbnRhbDEtMCsGCSqGSIb3DQEJARYeZ3VlbnRlci5vYmlsdHNjaG5pZ0Bh\n"
+	"cHBpbmYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA89GolWCR\n"
+	"KtLQclJ2M2QtpFqzNC54hUQdR6n8+DAeruH9WFwLSdWW2fEi+jrtd/WEWCdt4PxX\n"
+	"F2/eBYeURus7Hg2ZtJGDd3je0+Ygsv7+we4cMN/knaBY7rATqhmnZWk+yBpkf5F2\n"
+	"IHp9gBxUaJWmt/bq3XrvTtzrDXpCd4zg4zPXZ8IC8ket5o3K2vnkAOsIsgN+Ffqd\n"
+	"4GjF4dsblG6u6E3VarGRLwGtgB8BAZOA/33mV4FHSMkc4OXpAChaK3tM8YhrLw+m\n"
+	"XtsfqDiv1825S6OWFCKGj/iX8X2QAkrdB63vXCSpb3de/ByIUfp31PpMlMh6dKo1\n"
+	"vf7yj0nb2w0utQIDAQABoyowKDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0lAQH/BAww\n"
+	"CgYIKwYBBQUHAwMwDQYJKoZIhvcNAQEFBQADggEBAM0cpfb4BgiU/rkYe121P581\n"
+	"ftg5Ck1PYYda1Fy/FgzbgJh2AwVo/6sn6GF79/QkEcWEgtCMNNO3LMTTddUUApuP\n"
+	"jnEimyfmUhIThyud/vryzTMNa/eZMwaAqUQWqLf+AwgqjUsBSMenbSHavzJOpsvR\n"
+	"LI0PQ1VvqB+3UGz0JUnBJiKvHs83Fdm4ewPAf3M5fGcIa+Fl2nU5Plzwzskj84f6\n"
+	"73ZlEEi3aW9JieNy7RWsMM+1E8Sj2CGRZC4BM9V1Fgnsh4+VHX8Eu7eHucvfeIYx\n"
+	"3mmLMoK4sCayL/FGhrUDw5AkWb8tKNpRXY+W60Et281yxQSeWLPIbatVzIWI0/M=\n"
+	"-----END CERTIFICATE-----\n"
+);
+
+
 CryptoTest::CryptoTest(const std::string& name): CppUnit::TestCase(name)
 {
 }
@@ -51,7 +82,7 @@ CryptoTest::~CryptoTest()
 }
 
 
-void CryptoTest::testEncoding()
+void CryptoTest::testEncryptDecrypt()
 {
 	Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
 
@@ -62,7 +93,7 @@ void CryptoTest::testEncoding()
 }
 
 
-void CryptoTest::testEncoding2()
+void CryptoTest::testEncryptDecryptWithSalt()
 {
 	Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
 	
@@ -76,6 +107,33 @@ void CryptoTest::testEncoding2()
 }
 
 
+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/[email protected]");
+	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()
 {
 }
@@ -90,8 +148,9 @@ CppUnit::Test* CryptoTest::suite()
 {
 	CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("CryptoTest");
 
-	CppUnit_addTest(pSuite, CryptoTest, testEncoding);
-	CppUnit_addTest(pSuite, CryptoTest, testEncoding2);
+	CppUnit_addTest(pSuite, CryptoTest, testEncryptDecrypt);
+	CppUnit_addTest(pSuite, CryptoTest, testEncryptDecryptWithSalt);
+	CppUnit_addTest(pSuite, CryptoTest, testCertificate);
 
 	return pSuite;
 }

+ 4 - 3
Crypto/testsuite/src/CryptoTest.h

@@ -1,7 +1,7 @@
 //
 // CryptoTest.h
 //
-// $Id: //poco/Main/Crypto/testsuite/src/CryptoTest.h#1 $
+// $Id: //poco/Main/Crypto/testsuite/src/CryptoTest.h#2 $
 //
 // Definition of the CryptoTest class.
 //
@@ -46,8 +46,9 @@ public:
 	CryptoTest(const std::string& name);
 	~CryptoTest();
 
-	void testEncoding();
-	void testEncoding2();
+	void testEncryptDecrypt();
+	void testEncryptDecryptWithSalt();
+	void testCertificate();
 
 	void setUp();
 	void tearDown();

+ 65 - 22
Crypto/testsuite/src/RSATest.cpp

@@ -1,7 +1,7 @@
 //
 // RSATest.cpp
 //
-// $Id: //poco/Main/Crypto/testsuite/src/RSATest.cpp#3 $
+// $Id: //poco/Main/Crypto/testsuite/src/RSATest.cpp#5 $
 //
 // Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
 // and Contributors.
@@ -12,14 +12,14 @@
 // 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
@@ -36,13 +36,63 @@
 #include "Poco/Crypto/RSADigestEngine.h"
 #include "Poco/Crypto/CipherFactory.h"
 #include "Poco/Crypto/Cipher.h"
-#include "Poco/Net/X509Certificate.h"
-#include "Poco/Net/Context.h"
+#include "Poco/Crypto/X509Certificate.h"
 #include <sstream>
 
 
 using namespace Poco::Crypto;
-using namespace Poco::Net;
+
+
+static const std::string anyPem(
+	"-----BEGIN CERTIFICATE-----\r\n"
+	"MIICaDCCAdECCQCzfxSsk7yaLjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
+	"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
+	"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
+	"aW5mLmNvbTAeFw0wNjAzMDExMzA3MzFaFw0wNjAzMzExMzA3MzFaMH4xCzAJBgNV\r\n"
+	"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExETAPBgNVBAcTCFN0IEpha29iMRww\r\n"
+	"GgYDVQQKExNBcHBsaWVkIEluZm9ybWF0aWNzMQowCAYDVQQDFAEqMR4wHAYJKoZI\r\n"
+	"hvcNAQkBFg9pbmZvQGFwcGluZi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ\r\n"
+	"AoGBAJHGyXDHyCYoWz+65ltNwwZbhwOGnxr9P1WMATuFJh0bPBZxKbZRdbTm9KhZ\r\n"
+	"OlvsEIsfgiYdsxURYIqXfEgISYLZcZY0pQwGEOmB+0NeC/+ENSfOlNSthx6zSVlc\r\n"
+	"zhJ7+dJOGwepHAiLr1fRuc5jogYLraE+lKTnqAAFfzwvti77AgMBAAEwDQYJKoZI\r\n"
+	"hvcNAQEFBQADgYEAY/ZoeY1ukkEJX7259NeoVM0oahlulWV0rlCqyaeosOiDORPT\r\n"
+	"m6X1w/5MTCf9VyaD1zukoSZ4QqNVjHFXcXidbB7Tgt3yRuZ5PC5LIFCDPv9mgPne\r\n"
+	"mUA70yfctNfza2z3ZiQ6NDkW3mZX+1tmxYIrJQIrkVeYeqf1Gh2nyZrUMcE=\r\n"
+	"-----END CERTIFICATE-----\r\n"
+	"-----BEGIN RSA PRIVATE KEY-----\r\n"
+	"Proc-Type: 4,ENCRYPTED\r\n"
+	"DEK-Info: DES-EDE3-CBC,E7AE93C9E49184EA\r\n"
+	"\r\n"
+	"A2IqzNcWs+I5vzV+i+woDk56+yr58eU0Onw8eEvXkLjnSc58JU4327IF7yUbKWdW\r\n"
+	"Q7BYGGOkVFiZ7ANOwviDg5SUhxRDWCcW8dS6/p1vfdQ1C3qj2OwJjkpg0aDBIzJn\r\n"
+	"FzgguT3MF3ama77vxv0S3kOfmCj62MLqPGpj5pQ0/1hefRFbL8oAX8bXUN7/rmGM\r\n"
+	"Zc0QyzFZv2iQ04dY/6TNclwKPB4H0On4K+8BMs3PRkWA0clCaQaFO2+iwnk3XZfe\r\n"
+	"+MsKUEbLCpAQeYspYv1cw38dCdWq1KTP5aJk+oXgwjfX5cAaPTz74NTqTIsCcaTD\r\n"
+	"3vy7ukJYFlDR9Kyo7z8rMazYrKJslhnuRH0BhK9st9McwL957j5tZmrKyraCcmCx\r\n"
+	"dMAGcsis1va3ayYZpIpFqA4EhYrTM+6N8ZRfUap20+b5IQwHfTQDejUhL6rBwy7j\r\n"
+	"Ti5yD83/itoOMyXq2sV/XWfVD5zk/P5iv22O1EAQMhhnPB9K/I/JhuSGQJfn3cNh\r\n"
+	"ykOUYT0+vDeSeEVa+FVEP1W35G0alTbKbNs5Tb8KxJ3iDJUxokM//SvPXZy9hOVX\r\n"
+	"Y05imB04J15DaGbAHlNzunhuJi7121WV/JRXZRW9diE6hwpD8rwqi3FMuRUmy7U9\r\n"
+	"aFA5poKRAYlo9YtZ3YpFyjGKB6MfCQcB2opuSnQ/gbugV41m67uQ4CDwWLaNRkTb\r\n"
+	"GlsMBNcHnidg15Bsat5HaB7l250ukrI13Uw1MYdDUzaS3gPfw9aC4F2w0p3U+DPH\r\n"
+	"80/zePxtroR7T4/+rI136Rl+aMXDMOEGCX1TVP8rjuZzuRyUSUKC8Q==\r\n"
+	"-----END RSA PRIVATE KEY-----\r\n"
+	"-----BEGIN CERTIFICATE-----\r\n"
+	"MIICXTCCAcYCCQC1Vk/N8qR4AjANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJB\r\n"
+	"VDESMBAGA1UECBMJQ2FyaW50aGlhMRIwEAYDVQQHEwlTdC4gSmFrb2IxDzANBgNV\r\n"
+	"BAoTBkFwcEluZjEPMA0GA1UEAxMGQXBwSW5mMRowGAYJKoZIhvcNAQkBFgthcHBA\r\n"
+	"aW5mLmNvbTAeFw0wNjAyMjcxMzI3MThaFw0wNjAzMjkxMzI3MThaMHMxCzAJBgNV\r\n"
+	"BAYTAkFUMRIwEAYDVQQIEwlDYXJpbnRoaWExEjAQBgNVBAcTCVN0LiBKYWtvYjEP\r\n"
+	"MA0GA1UEChMGQXBwSW5mMQ8wDQYDVQQDEwZBcHBJbmYxGjAYBgkqhkiG9w0BCQEW\r\n"
+	"C2FwcEBpbmYuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsFXiPuicN\r\n"
+	"Im4oJwF8NuaFN+lgYwcZ6dAO3ILIR3kLA2PxF8HSQLfF8J8a4odZhLhctIMAKTxm\r\n"
+	"k0w8TW5qhL8QLdGzY9vzvkgdKOkan2t3sMeXJAfrM1AphTsmgntAQazGZjOj5p4W\r\n"
+	"jDnxQ+VXAylqwjHh49eSBxM3wgoscF4iLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GB\r\n"
+	"AIpfLdXiKchPvFMhQS8xTtXvrw5dVL3yImUMYs4GQi8RrjGmfGB3yMAR7B/b8v4a\r\n"
+	"+ztfusgWAWiUKuSGTk4S8YB0fsFlmOv0WDr+PyZ4Lui/a8opbyzGE7rqpnF/s0GO\r\n"
+	"M7uLCNNwIN7WhmxcWV0KZU1wTppoSWPJda1yTbBzF9XP\r\n"
+	"-----END CERTIFICATE-----\r\n"
+);
 
 
 RSATest::RSATest(const std::string& name): CppUnit::TestCase(name)
@@ -64,7 +114,7 @@ void RSATest::testNewKeys()
 	std::string pubKey = strPub.str();
 	std::string privKey = strPriv.str();
 
-	//now do the round trip
+	// now do the round trip
 	std::istringstream iPub(pubKey);
 	std::istringstream iPriv(privKey);
 	RSAKey key2(&iPub, &iPriv, "testpwd");
@@ -87,7 +137,7 @@ void RSATest::testSign()
 	const Poco::DigestEngine::Digest& sig = eng.signature();
 	std::string hexDig = Poco::DigestEngine::digestToHex(sig);
 
-	//verify
+	// verify
 	std::ostringstream strPub;
 	key.save(&strPub);
 	std::string pubKey = strPub.str();
@@ -95,7 +145,7 @@ void RSATest::testSign()
 	RSAKey keyPub(&iPub);
 	RSADigestEngine eng2(key);
 	eng2.update(msg.c_str(), msg.length());
-	eng2.verify(sig);
+	assert (eng2.verify(sig));
 }
 
 
@@ -109,7 +159,7 @@ void RSATest::testSignManipulated()
 	const Poco::DigestEngine::Digest& sig = eng.signature();
 	std::string hexDig = Poco::DigestEngine::digestToHex(sig);
 
-	//verify
+	// verify
 	std::ostringstream strPub;
 	key.save(&strPub);
 	std::string pubKey = strPub.str();
@@ -117,14 +167,7 @@ void RSATest::testSignManipulated()
 	RSAKey keyPub(&iPub);
 	RSADigestEngine eng2(key);
 	eng2.update(msgManip.c_str(), msgManip.length());
-	try
-	{
-		eng2.verify(sig);
-		fail("must fail");
-	}
-	catch(Poco::DataFormatException&)
-	{
-	}
+	assert (!eng2.verify(sig));
 }
 
 
@@ -150,13 +193,13 @@ void RSATest::createRSACipherLarge()
 
 void RSATest::testCertificate()
 {
-	X509Certificate cert("any.pem");
-	//Context::Ptr pContext(new Context(Context::SERVER_USE,"", "", false));
-	bool ok = cert.verify("www.appinf.com");
+	std::istringstream str(anyPem);
+	X509Certificate cert(str);
+	
 	RSAKey key(cert);
 	Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(key);
 	std::string val("lets do some encryption");
-
+	
 	std::string enc = pCipher->encryptString(val);
 }
 

+ 2 - 2
NetSSL_OpenSSL/Makefile

@@ -13,7 +13,7 @@ SYSLIBS += -lssl -lcrypto
 objects = AcceptCertificateHandler CertificateHandlerFactory \
 	CertificateHandlerFactoryMgr ConsoleCertificateHandler \
 	Context HTTPSClientSession HTTPSStreamFactory HTTPSSessionInstantiator \
-	SSLInitializer InvalidCertificateHandler KeyConsoleHandler \
+	InvalidCertificateHandler KeyConsoleHandler \
 	KeyFileHandler PrivateKeyFactory PrivateKeyFactoryMgr \
 	PrivateKeyPassphraseHandler SecureServerSocket SecureServerSocketImpl \
 	SecureSocketImpl SecureStreamSocket SecureStreamSocketImpl \
@@ -22,6 +22,6 @@ objects = AcceptCertificateHandler CertificateHandlerFactory \
 
 target         = PocoNetSSL
 target_version = $(LIBVERSION)
-target_libs    = PocoFoundation PocoNet PocoUtil
+target_libs    = PocoNet PocoCrypto PocoUtil PocoFoundation 
 
 include $(POCO_BASE)/build/rules/lib

+ 8 - 14
NetSSL_OpenSSL/NetSSL_OpenSSL_vs71.vcproj

@@ -20,7 +20,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include;..\Util\include"
+				AdditionalIncludeDirectories=".\include;..\Net\include;..\Crypto\include;..\Util\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;NetSSL_EXPORTS"
 				StringPooling="TRUE"
 				MinimalRebuild="TRUE"
@@ -85,7 +85,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include;..\Util\include"
+				AdditionalIncludeDirectories=".\include;..\Net\include;..\Crypto\include;..\Util\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;NetSSL_EXPORTS"
 				GeneratePreprocessedFile="0"
 				KeepComments="FALSE"
@@ -140,14 +140,14 @@
 		</Configuration>
 		<Configuration
 			Name="debug_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="2">
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include;..\Util\include"
+				AdditionalIncludeDirectories=".\include;..\Net\include;..\Crypto\include;..\Util\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_STATIC;NetSSL_EXPORTS"
 				StringPooling="TRUE"
 				MinimalRebuild="TRUE"
@@ -189,8 +189,8 @@
 		</Configuration>
 		<Configuration
 			Name="release_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="2">
 			<Tool
@@ -201,7 +201,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include;..\Util\include"
+				AdditionalIncludeDirectories=".\include;..\Net\include;..\Crypto\include;..\Util\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_STATIC;NetSSL_EXPORTS"
 				GeneratePreprocessedFile="0"
 				KeepComments="FALSE"
@@ -290,9 +290,6 @@
 				<File
 					RelativePath=".\include\Poco\Net\SSLException.h">
 				</File>
-				<File
-					RelativePath=".\include\Poco\Net\SSLInitializer.h">
-				</File>
 				<File
 					RelativePath=".\include\Poco\Net\SSLManager.h">
 				</File>
@@ -345,9 +342,6 @@
 				<File
 					RelativePath=".\src\SSLException.cpp">
 				</File>
-				<File
-					RelativePath=".\src\SSLInitializer.cpp">
-				</File>
 				<File
 					RelativePath=".\src\SSLManager.cpp">
 				</File>

+ 16 - 24
NetSSL_OpenSSL/NetSSL_OpenSSL_vs80.vcproj

@@ -17,8 +17,8 @@
 	<Configurations>
 		<Configuration
 			Name="debug_shared|Win32"
-			OutputDirectory=".\obj\debug_shared"
-			IntermediateDirectory=".\obj\debug_shared"
+			OutputDirectory="obj\debug_shared"
+			IntermediateDirectory="obj\debug_shared"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -41,7 +41,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include;..\Util\include"
+				AdditionalIncludeDirectories=".\include;..\Net\include;..\Crypto\include;..\Util\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;NetSSL_EXPORTS"
 				StringPooling="true"
 				MinimalRebuild="true"
@@ -72,7 +72,7 @@
 				OutputFile="..\bin\PocoNetSSLd.dll"
 				LinkIncremental="2"
 				SuppressStartupBanner="true"
-				AdditionalLibraryDirectories="..\lib;C:\OpenSSL\lib\VC"
+				AdditionalLibraryDirectories="..\lib"
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="..\bin\PocoNetSSLd.pdb"
 				SubSystem="1"
@@ -107,8 +107,8 @@
 		</Configuration>
 		<Configuration
 			Name="release_shared|Win32"
-			OutputDirectory=".\obj\release_shared"
-			IntermediateDirectory=".\obj\release_shared"
+			OutputDirectory="obj\release_shared"
+			IntermediateDirectory="obj\release_shared"
 			ConfigurationType="2"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -135,7 +135,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include;..\Util\include"
+				AdditionalIncludeDirectories=".\include;..\Net\include;..\Crypto\include;..\Util\include;..\Foundation\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;NetSSL_EXPORTS"
 				GeneratePreprocessedFile="0"
 				KeepComments="false"
@@ -166,7 +166,7 @@
 				OutputFile="..\bin\PocoNetSSL.dll"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
-				AdditionalLibraryDirectories="..\lib;C:\OpenSSL\lib\VC"
+				AdditionalLibraryDirectories="..\lib"
 				GenerateDebugInformation="false"
 				ProgramDatabaseFile=""
 				SubSystem="1"
@@ -203,8 +203,8 @@
 		</Configuration>
 		<Configuration
 			Name="debug_static|Win32"
-			OutputDirectory=".\obj\debug_static"
-			IntermediateDirectory=".\obj\debug_static"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
 			ConfigurationType="4"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -227,8 +227,8 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include;..\Util\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;NetSSL_EXPORTS;POCO_STATIC"
+				AdditionalIncludeDirectories=".\include;..\Net\include;..\Crypto\include;..\Util\include;..\Foundation\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;NetSSL_EXPORTS;POCO_STATIC"
 				StringPooling="true"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -275,8 +275,8 @@
 		</Configuration>
 		<Configuration
 			Name="release_static|Win32"
-			OutputDirectory=".\obj\release_static"
-			IntermediateDirectory=".\obj\release_static"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
 			ConfigurationType="4"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			CharacterSet="2"
@@ -303,8 +303,8 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include;..\Util\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;NetSSL_EXPORTS;POCO_STATIC"
+				AdditionalIncludeDirectories=".\include;..\Net\include;..\Crypto\include;..\Util\include;..\Foundation\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;NetSSL_EXPORTS;POCO_STATIC"
 				GeneratePreprocessedFile="0"
 				KeepComments="false"
 				StringPooling="true"
@@ -411,10 +411,6 @@
 					RelativePath=".\include\Poco\Net\SSLException.h"
 					>
 				</File>
-				<File
-					RelativePath=".\include\Poco\Net\SSLInitializer.h"
-					>
-				</File>
 				<File
 					RelativePath=".\include\Poco\Net\SSLManager.h"
 					>
@@ -483,10 +479,6 @@
 					RelativePath=".\src\SSLException.cpp"
 					>
 				</File>
-				<File
-					RelativePath=".\src\SSLInitializer.cpp"
-					>
-				</File>
 				<File
 					RelativePath=".\src\SSLManager.cpp"
 					>

+ 6 - 8
NetSSL_OpenSSL/NetSSL_OpenSSL_vs90.vcproj

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9.00"
+	Version="9,00"
 	Name="NetSSL_OpenSSL"
 	ProjectGUID="{5AECC55E-A469-11DA-8DA6-005056C00008}"
 	RootNamespace="OpenSSL"
@@ -67,7 +67,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationd.lib PocoNetd.lib PocoUtild.lib libeay32mtd.lib ssleay32mtd.lib ws2_32.lib"
+				AdditionalDependencies="PocoFoundationd.lib PocoNetd.lib PocoUtild.lib libeay32mdd.lib ssleay32mdd.lib ws2_32.lib"
 				OutputFile="..\bin\PocoNetSSLd.dll"
 				LinkIncremental="2"
 				SuppressStartupBanner="true"
@@ -196,8 +196,8 @@
 		</Configuration>
 		<Configuration
 			Name="debug_static|Win32"
-			OutputDirectory=".\obj\debug_static"
-			IntermediateDirectory=".\obj\debug_static"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="2"
 			>
@@ -245,7 +245,6 @@
 			/>
 			<Tool
 				Name="VCLibrarianTool"
-				AdditionalDependencies="ws2_32.lib"
 				OutputFile="..\lib\PocoNetSSLmtd.lib"
 			/>
 			<Tool
@@ -266,8 +265,8 @@
 		</Configuration>
 		<Configuration
 			Name="release_static|Win32"
-			OutputDirectory=".\obj\release_static"
-			IntermediateDirectory=".\obj\release_static"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="4"
 			CharacterSet="2"
 			>
@@ -319,7 +318,6 @@
 			/>
 			<Tool
 				Name="VCLibrarianTool"
-				AdditionalDependencies="ws2_32.lib"
 				OutputFile="..\lib\PocoNetSSLmt.lib"
 			/>
 			<Tool

+ 15 - 56
NetSSL_OpenSSL/include/Poco/Net/X509Certificate.h

@@ -1,7 +1,7 @@
 //
 // X509Certificate.h
 //
-// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/X509Certificate.h#11 $
+// $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/X509Certificate.h#12 $
 //
 // Library: NetSSL_OpenSSL
 // Package: SSLCore
@@ -41,7 +41,7 @@
 
 
 #include "Poco/Net/NetSSL.h"
-#include "Poco/Net/Context.h"
+#include "Poco/Crypto/X509Certificate.h"
 #include "Poco/DateTime.h"
 #include "Poco/SharedPtr.h"
 #include <set>
@@ -55,8 +55,9 @@ namespace Net {
 class HostEntry;
 
 
-class NetSSL_API X509Certificate
-	/// This class represents a X509 Certificate.
+class NetSSL_API X509Certificate: public Poco::Crypto::X509Certificate
+	/// This class extends Poco::Crypto::X509Certificate with the
+	/// feature to validate a certificate.
 {
 public:
 	explicit X509Certificate(std::istream& istr);
@@ -72,45 +73,28 @@ public:
 		/// OpenSSL certificate. Ownership is taken of 
 		/// the certificate.
 
-	X509Certificate(const X509Certificate& cert);
+	X509Certificate(const Poco::Crypto::X509Certificate& cert);
 		/// Creates the certificate by copying another one.
 
-	X509Certificate& operator = (const X509Certificate& cert);
+	X509Certificate& operator = (const Poco::Crypto::X509Certificate& cert);
 		/// Assigns a certificate.
 
-	void swap(X509Certificate& cert);
-		/// Exchanges the certificate with another one.
-
 	~X509Certificate();
 		/// Destroys the X509Certificate.
 
-	const std::string& issuerName() const;
-		/// Returns the certificate issuer name.
-		
-	const std::string& subjectName() const;
-		/// Returns the certificate subject name.
-		
-	std::string commonName() const;
-		/// Returns the common name stored in the certificate.
-		
-	const X509* certificate() const;
-		/// Returns the underlying OpenSSL certificate.
-
 	long verify(const std::string& hostName) const;
 		/// Verifies the validity of the certificate against the host name.
-
-	void extractNames(std::string& commonName, std::set<std::string>& domainNames) const;
-		/// Extracts the common name and the alias domain names from the
-		/// certificate.
+		///
+		/// Returns X509_V_OK if verification succeeded, or an
+		/// error code (X509_V_ERR_APPLICATION_VERIFICATION) otherwise.
 		
-	Poco::DateTime validFrom() const;
-		/// Returns the date and time the certificate is valid from.
+	static long verify(const Poco::Crypto::X509Certificate& cert, const std::string& hostName);
+		/// Verifies the validity of the certificate against the host name.
+		///
+		/// Returns X509_V_OK if verification succeeded, or an
+		/// error code (X509_V_ERR_APPLICATION_VERIFICATION) otherwise.
 		
-	Poco::DateTime expiresOn() const;
-		/// Returns the date and time the certificate expires.
-
 protected:
-	void init();
 	static bool containsWildcards(const std::string& commonName);
 	static bool matchByAlias(const std::string& alias, const HostEntry& heData);
 	
@@ -119,34 +103,9 @@ private:
 	{
 		NAME_BUFFER_SIZE = 256
 	};
-	
-	std::string _issuerName;
-	std::string _subjectName;
-	X509*       _pCert;
 };
 
 
-//
-// inlines
-//
-inline const std::string& X509Certificate::issuerName() const
-{
-	return _issuerName;
-}
-
-
-inline const std::string& X509Certificate::subjectName() const
-{
-	return _subjectName;
-}
-
-
-inline const X509* X509Certificate::certificate() const
-{
-	return _pCert;
-}
-
-
 } } // namespace Poco::Net
 
 

+ 4 - 4
NetSSL_OpenSSL/samples/HTTPSTimeServer/HTTPSTimeServer_vs71.vcproj

@@ -20,7 +20,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
+				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\Crypto\include;..\..\..\NetSSL_OpenSSL\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -37,7 +37,7 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib PocoNetSSLd.lib"
+				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib PocoCryptod.lib PocoNetSSLd.lib"
 				OutputFile="bin/HTTPSTimeServerd.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="..\..\..\lib"
@@ -81,7 +81,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
+				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\Crypto\include;..\..\..\NetSSL_OpenSSL\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -97,7 +97,7 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib PocoNetSSL.lib"
+				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib PocoCrypto.lib PocoNetSSL.lib"
 				OutputFile="bin/HTTPSTimeServer.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\lib"

+ 5 - 182
NetSSL_OpenSSL/samples/HTTPSTimeServer/HTTPSTimeServer_vs80.vcproj

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8.00"
+	Version="8,00"
 	Name="HTTPSTimeServer"
 	ProjectGUID="{7C4285ED-F0BC-4CBA-B1F0-61FCB7FA26C4}"
 	Keyword="Win32Proj"
@@ -41,7 +41,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
+				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\Crypto\include;..\..\..\NetSSL_OpenSSL\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -66,7 +66,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib PocoNetSSLd.lib"
+				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib PocoCryptod.lib PocoNetSSLd.lib"
 				OutputFile="bin/HTTPSTimeServerd.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="..\..\..\lib"
@@ -131,7 +131,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
+				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\Crypto\include;..\..\..\NetSSL_OpenSSL\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				StringPooling="true"
 				RuntimeLibrary="2"
@@ -155,184 +155,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib PocoNetSSL.lib"
-				OutputFile="bin/HTTPSTimeServer.exe"
-				LinkIncremental="1"
-				AdditionalLibraryDirectories="..\..\..\lib"
-				GenerateDebugInformation="false"
-				ProgramDatabaseFile=""
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="debug_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
-				BufferSecurityCheck="true"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib PocoNetSSLd.lib ws2_32.lib iphlpapi.lib advapi32.lib libeay32mt.lib ssleay32mt.lib"
-				OutputFile="bin/HTTPSTimeServerd.exe"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="..\..\..\lib"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile="bin/HTTPSTimeServerd.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="release_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="4"
-				InlineFunctionExpansion="1"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
-				StringPooling="true"
-				RuntimeLibrary="2"
-				BufferSecurityCheck="false"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib PocoNetSSL.lib ws2_32.lib iphlpapi.lib advapi32.lib libeay32mt.lib ssleay32mt.lib"
+				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib PocoCrypto.lib PocoNetSSL.lib"
 				OutputFile="bin/HTTPSTimeServer.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\lib"

+ 2 - 173
NetSSL_OpenSSL/samples/HTTPSTimeServer/HTTPSTimeServer_vs90.vcproj

@@ -66,7 +66,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib PocoNetSSLd.lib"
-				OutputFile="bin/$(ProjectName)d.exe"
+				OutputFile="bin/HTTPSTimeServerd.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="..\..\..\lib"
 				GenerateDebugInformation="true"
@@ -152,178 +152,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib PocoNetSSL.lib"
-				OutputFile="bin/$(ProjectName).exe"
-				LinkIncremental="1"
-				AdditionalLibraryDirectories="..\..\..\lib"
-				GenerateDebugInformation="false"
-				ProgramDatabaseFile=""
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="debug_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
-				BufferSecurityCheck="true"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationmtd.lib PocoXMLmtd.lib PocoNetmtd.lib PocoUtilmtd.lib PocoNetSSLmtd.lib libeay32mtd.lib ssleay32mtd.lib ws2_32.lib advapi32.lib"
-				OutputFile="bin/$(ProjectName)mtd.exe"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="..\..\..\lib"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile="bin/HTTPSTimeServerd.pdb"
-				SubSystem="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="release_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="4"
-				InlineFunctionExpansion="1"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
-				StringPooling="true"
-				RuntimeLibrary="2"
-				BufferSecurityCheck="false"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationmt.lib PocoXMLmt.lib PocoNetmt.lib PocoUtilmt.lib PocoNetSSLmt.lib libeay32mt.lib ssleay32mt.lib ws2_32.lib advapi32.lib"
-				OutputFile="bin/$(ProjectName)mt.exe"
+				OutputFile="bin/HTTPSTimeServer.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\lib"
 				GenerateDebugInformation="false"

+ 1 - 1
NetSSL_OpenSSL/samples/HTTPSTimeServer/Makefile

@@ -14,6 +14,6 @@ objects = HTTPSTimeServer
 
 target         = HTTPSTimeServer
 target_version = 1
-target_libs    = PocoNetSSL PocoNet PocoUtil PocoXML PocoFoundation
+target_libs    = PocoNetSSL PocoCrypto PocoNet PocoUtil PocoXML PocoFoundation
 
 include $(POCO_BASE)/build/rules/exec

+ 54 - 54
NetSSL_OpenSSL/samples/HTTPSTimeServer/any.pem

@@ -1,54 +1,54 @@
------BEGIN CERTIFICATE-----
-MIIEFjCCAv6gAwIBAgIBAjALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu
-Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n
-aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh
-cmludGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl
-bnRhbDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu
-Y29tMB4XDTA5MDIyMzEzNDIwMloXDTExMTEyMDEzNDIwMlowgcoxCjAIBgNVBAMM
-ASoxNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5naW5l
-ZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNhcmlu
-dGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3NlbnRh
-bDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYuY29t
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxjGFE96wa83Kdiv0m10O
-XmBmZ5xuclalVTCisLzUmAekbItMjkmI6dVw9r5gd0W5zDWrgPYUmYgtvqnxSHRK
-PRAN410Yq9vqWYvQscpnXGlqUag8t+OBXJhiFnnea/btA0zGVZk6RE/7cWK8AtKH
-Q/Xds3AUJ1L/1uV/e/5azyUDyptsmHbCMUwWhGBrj/KZEviHmRMN/xJLrbIBPkla
-4HRB61rI8in0jziCwThJ7KiQumzWRu2IJjS+VoNWvG52dYLDvfxppuY1rlF0SG/h
-JuSJQqJjZZ11V4TePHscFkGU2tnHqF4UhSjLFJWsGuxnAmZTeIRmavmIIMm3/G6C
-WwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQAc+mn/ZEaK59B/UAgx8cMlGM9UigJv
-L9O46pno3YirBq9SrMzf5b6rrbJm8tkQNfldqaVNA5oVbfxnAHhCUDkX8m0x/De8
-teo9nFei8kETQ25ykV+WLapOdrYxakHPtNVgDTGWNb2GY/hH3nMvtdgFvaS80ncD
-tOa13tE4jopFQFY56VKq+sv4Hm5JDvr+dD/g77Cio02sUzSH96FrFIG5/kw1NihB
-IJKZ4n7atQizDe4TiR/NRonmZNbsB+18yTKT8traCS30JGKQqYxXuVKPyQd7FARv
-ajZxRPbcpAtvWBKXpRHXo4xIBJaPktVOG2hGovjRixXYb83hQ87t1Ozy
------END CERTIFICATE-----
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,0950752701CB74AF
-
-OmaLdMcP3JDy8JMX41wNH/WvMp6gLGwmqQRob633n95YxVdii0oR8fk4GgmJeYF0
-FrNm5g32vnVyqDZylX4as3GT822HhCA+f7mYpGZltQ47TG15tGTMUNuwIhHlouZs
-ZGNclelBB3FHEZAD0Fns2hZ4jZhMDj67wD0YyGcp8so/A+fxedGdwNbJSC1Auuy4
-7uRsY0ZJC1LjMHXkyBEXaL1QA4CGjBlm22Dbo8eoGXcaohsZpDsM7OU7MaQnldM0
-AK8jONZ45127JoDJD41Wgfm0m7tIErsD5CbhHPaddOjQ0OerprEkplhOR+V+ano1
-Pv4adRZOBjr00NDB43WK9x+ZHVQ5tIXxUbqYWZAfvA1PpiYego5XLUCxfy7D6Lms
-hV6CAt/fYeBrQOvwLREboKLBOe9A8quP2wi7zkR3KQHty9Tm9efF3PfQSxJTlKg9
-YJ2n/6omX1aXCjQghbnfEcl4tCmj6z2rHCSiJgEOcwDYhGRbQveYieZUH5iKMzYY
-YytHkHPfZfzhlJ0WG0AKdA6UlrjEjF09txaZR3Nj4Zf4kZAu727N81HnlFCRvDqV
-ZjHUrbE7fJuc3diffUfIHuQZuWcoYDejIbASjcJMHZOpbbPR2ZCYQqUmvg/IgAD6
-M2GDbvfvLnu1BaCrNMdOxM4j+sLNhm8qqAMxZ/wkZA9Sqhi2EifZwf5jWKNU3Vtx
-C/w621efHawDME3WTMunDtjn7Sgm3NP508cz8OgcEcZLwENu8JH5pWR0Y0+qvlPM
-DYpCu2Zh6TBLU6Cfuxl2GigHHBhm8Eza/vE6dVbpyvEozejtVKi+RYskqz8ynYtl
-r9NpDkEFcqGFLX/X7fajR4JxzxYx0Ms+CHHBlBLw44eMl1Izb9OBgfUK3a7wJ0Z1
-vEmzcVtXZMqKDvqY3wddCcbtpVZhRnAUFgT3/b5ISxQ6xxFg67YQaJ0knuRwOZCI
-xSvNsxXb6s5xt8gRx8MY8W1CVW0QSH4gUpKdJFiF/6nYq7h8F1A5QYr34uJn5pa2
-bsagCMhCUHKn/hrtTJ/4bC7n7utulXyEZJDGS38nNe5TBmAxeA+MkOAO7AEb8aDo
-RylaKT77tmeZXWBtlQGHj0bt2fPOEW3e0WUeNwk4qnKqSGdwbXGFK+yWxgGOxFDT
-4NqUjDV7lhj1r3mKEufLIqP6GxAlewpH1uLA+ty2eNfG793pytlyhNikzmkliXex
-WnBUYQM6ZBclW0nALHxxOJWZlnBCESgo9lSHMeB7adJXuwaUmqHx4u+yNzaFS6pr
-LemBEUCHfLeGFM9E9YbgNe51q5+vXZYN5MZtqyex4AqPdGEGpwXBk43RK79mP84G
-QQRAAcs6KMj1/Sl7pmg9acrxskLWljtsnvdCJ8a+VXjLDyp2wks1z2Gnw7cguZdD
-Ah4hjH8LDTsEJxOr2DNJu/V9JDPKd0uGyaW0AOanwAn7tszivGddb/WrzImCIMBa
-Lb/cqujvS9YsIK6xrq4LMxR5wE6Hol0qs6xO89Y9OpuuRxAYfRUl4nDTg0WjS5Ga
-0aoSXB0kOFkEwb3WGq+b26606RBYDKu7RsJoyWoXq42JZ1jkEYKCNeNS8hWh8GKd
------END RSA PRIVATE KEY-----
+-----BEGIN CERTIFICATE-----
+MIIEFjCCAv6gAwIBAgIBAjALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu
+Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n
+aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh
+cmludGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl
+bnRhbDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu
+Y29tMB4XDTA5MDIyMzEzNDIwMloXDTExMTEyMDEzNDIwMlowgcoxCjAIBgNVBAMM
+ASoxNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5naW5l
+ZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNhcmlu
+dGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3NlbnRh
+bDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYuY29t
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxjGFE96wa83Kdiv0m10O
+XmBmZ5xuclalVTCisLzUmAekbItMjkmI6dVw9r5gd0W5zDWrgPYUmYgtvqnxSHRK
+PRAN410Yq9vqWYvQscpnXGlqUag8t+OBXJhiFnnea/btA0zGVZk6RE/7cWK8AtKH
+Q/Xds3AUJ1L/1uV/e/5azyUDyptsmHbCMUwWhGBrj/KZEviHmRMN/xJLrbIBPkla
+4HRB61rI8in0jziCwThJ7KiQumzWRu2IJjS+VoNWvG52dYLDvfxppuY1rlF0SG/h
+JuSJQqJjZZ11V4TePHscFkGU2tnHqF4UhSjLFJWsGuxnAmZTeIRmavmIIMm3/G6C
+WwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQAc+mn/ZEaK59B/UAgx8cMlGM9UigJv
+L9O46pno3YirBq9SrMzf5b6rrbJm8tkQNfldqaVNA5oVbfxnAHhCUDkX8m0x/De8
+teo9nFei8kETQ25ykV+WLapOdrYxakHPtNVgDTGWNb2GY/hH3nMvtdgFvaS80ncD
+tOa13tE4jopFQFY56VKq+sv4Hm5JDvr+dD/g77Cio02sUzSH96FrFIG5/kw1NihB
+IJKZ4n7atQizDe4TiR/NRonmZNbsB+18yTKT8traCS30JGKQqYxXuVKPyQd7FARv
+ajZxRPbcpAtvWBKXpRHXo4xIBJaPktVOG2hGovjRixXYb83hQ87t1Ozy
+-----END CERTIFICATE-----
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,0950752701CB74AF
+
+OmaLdMcP3JDy8JMX41wNH/WvMp6gLGwmqQRob633n95YxVdii0oR8fk4GgmJeYF0
+FrNm5g32vnVyqDZylX4as3GT822HhCA+f7mYpGZltQ47TG15tGTMUNuwIhHlouZs
+ZGNclelBB3FHEZAD0Fns2hZ4jZhMDj67wD0YyGcp8so/A+fxedGdwNbJSC1Auuy4
+7uRsY0ZJC1LjMHXkyBEXaL1QA4CGjBlm22Dbo8eoGXcaohsZpDsM7OU7MaQnldM0
+AK8jONZ45127JoDJD41Wgfm0m7tIErsD5CbhHPaddOjQ0OerprEkplhOR+V+ano1
+Pv4adRZOBjr00NDB43WK9x+ZHVQ5tIXxUbqYWZAfvA1PpiYego5XLUCxfy7D6Lms
+hV6CAt/fYeBrQOvwLREboKLBOe9A8quP2wi7zkR3KQHty9Tm9efF3PfQSxJTlKg9
+YJ2n/6omX1aXCjQghbnfEcl4tCmj6z2rHCSiJgEOcwDYhGRbQveYieZUH5iKMzYY
+YytHkHPfZfzhlJ0WG0AKdA6UlrjEjF09txaZR3Nj4Zf4kZAu727N81HnlFCRvDqV
+ZjHUrbE7fJuc3diffUfIHuQZuWcoYDejIbASjcJMHZOpbbPR2ZCYQqUmvg/IgAD6
+M2GDbvfvLnu1BaCrNMdOxM4j+sLNhm8qqAMxZ/wkZA9Sqhi2EifZwf5jWKNU3Vtx
+C/w621efHawDME3WTMunDtjn7Sgm3NP508cz8OgcEcZLwENu8JH5pWR0Y0+qvlPM
+DYpCu2Zh6TBLU6Cfuxl2GigHHBhm8Eza/vE6dVbpyvEozejtVKi+RYskqz8ynYtl
+r9NpDkEFcqGFLX/X7fajR4JxzxYx0Ms+CHHBlBLw44eMl1Izb9OBgfUK3a7wJ0Z1
+vEmzcVtXZMqKDvqY3wddCcbtpVZhRnAUFgT3/b5ISxQ6xxFg67YQaJ0knuRwOZCI
+xSvNsxXb6s5xt8gRx8MY8W1CVW0QSH4gUpKdJFiF/6nYq7h8F1A5QYr34uJn5pa2
+bsagCMhCUHKn/hrtTJ/4bC7n7utulXyEZJDGS38nNe5TBmAxeA+MkOAO7AEb8aDo
+RylaKT77tmeZXWBtlQGHj0bt2fPOEW3e0WUeNwk4qnKqSGdwbXGFK+yWxgGOxFDT
+4NqUjDV7lhj1r3mKEufLIqP6GxAlewpH1uLA+ty2eNfG793pytlyhNikzmkliXex
+WnBUYQM6ZBclW0nALHxxOJWZlnBCESgo9lSHMeB7adJXuwaUmqHx4u+yNzaFS6pr
+LemBEUCHfLeGFM9E9YbgNe51q5+vXZYN5MZtqyex4AqPdGEGpwXBk43RK79mP84G
+QQRAAcs6KMj1/Sl7pmg9acrxskLWljtsnvdCJ8a+VXjLDyp2wks1z2Gnw7cguZdD
+Ah4hjH8LDTsEJxOr2DNJu/V9JDPKd0uGyaW0AOanwAn7tszivGddb/WrzImCIMBa
+Lb/cqujvS9YsIK6xrq4LMxR5wE6Hol0qs6xO89Y9OpuuRxAYfRUl4nDTg0WjS5Ga
+0aoSXB0kOFkEwb3WGq+b26606RBYDKu7RsJoyWoXq42JZ1jkEYKCNeNS8hWh8GKd
+-----END RSA PRIVATE KEY-----

+ 25 - 25
NetSSL_OpenSSL/samples/HTTPSTimeServer/rootcert.pem

@@ -1,25 +1,25 @@
------BEGIN CERTIFICATE-----
-MIIEQTCCAymgAwIBAgIBATALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu
-Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n
-aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh
-cmludGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl
-bnRhbDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu
-Y29tMB4XDTA5MDIyMzEzNDAzNVoXDTExMTEyMDEzNDAzNVowgdMxEzARBgNVBAMM
-CmFwcGluZi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdh
-cmUgRW5naW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNV
-BAgMCUNhcmludGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBp
-bSBSb3NlbnRhbDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0Bh
-cHBpbmYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx8mI/DXh
-dwvwt/qMD5Mm+1ataiRJzau0ct07kyFv0hTYGJR7sl4ocC+lLqLOgOxeG0IaIKvP
-Apqq7KQ1ZJBtpZAAwj8NwMXg8fGYM0JtpkGYmkRGmFolwFWA0FLVmGxAuw2iKN6k
-ajl8U4pz5qzYFEKNL5IJMI8rS2Fsek1pgfpZ5dYFChgVW7urxFhAJCXMrHAOLfed
-SjXtZpvepXRvBtuvOosXSIjmY9x/3/1QeRvZpza2atWRv4pnKBldtI9BZDUQqS3F
-fi/ydXlZVeY3aHW6Cw9DfbnnLv2RegUzjUZCx07IrPulZmqS6rabIIwY/bhX+n7y
-YcP4ADkXDKct6QIDAQABoyAwHjAPBgNVHRMBAf8EBTADAQH/MAsGA1UdDwQEAwIC
-hDANBgkqhkiG9w0BAQUFAAOCAQEAAfoSQow7qv3C9SiOZ+h3s9reQBJnZUcSQ5AS
-90jGmtmcJ1eyWQyGxES0iKYPcF1GbSBkO/kqMzdM/E2GQnbHVrgiPj+9tTxjG/hK
-42K2AEACDYtuQWTui4K1BmrWRJvdoiGRrt87DhmOG6UY5wtUAZdgVjhwBGEWJhYp
-IgeNe5OEdrBkSBjYb2VnJOJFQA7bB7G4snTjNMY+n5+odISHU3debZLdXvX3gKVG
-nVwp91/LnCSCvvZ+nH9xLzNdTbXqhI96bJh/iXLNcwcHOWPYWKuANAs5FR7OSZ+l
-57gz8/BTaM4pTyJzER5p0+cTIzLGF7aYLuKKqXiKykjruO3U7A==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIEQTCCAymgAwIBAgIBATALBgkqhkiG9w0BAQUwgdMxEzARBgNVBAMMCmFwcGlu
+Zi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdhcmUgRW5n
+aW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNVBAgMCUNh
+cmludGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBpbSBSb3Nl
+bnRhbDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0BhcHBpbmYu
+Y29tMB4XDTA5MDIyMzEzNDAzNVoXDTExMTEyMDEzNDAzNVowgdMxEzARBgNVBAMM
+CmFwcGluZi5jb20xNjA0BgNVBAoMLUFwcGxpZWQgSW5mb3JtYXRpY3MgU29mdHdh
+cmUgRW5naW5lZXJpbmcgR21iSDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQxEjAQBgNV
+BAgMCUNhcmludGhpYTELMAkGA1UEBgwCQVQxHjAcBgNVBAcMFVN0LiBKYWtvYiBp
+bSBSb3NlbnRhbDEtMCsGCSqGSIb3DQEJAQweZ3VlbnRlci5vYmlsdHNjaG5pZ0Bh
+cHBpbmYuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx8mI/DXh
+dwvwt/qMD5Mm+1ataiRJzau0ct07kyFv0hTYGJR7sl4ocC+lLqLOgOxeG0IaIKvP
+Apqq7KQ1ZJBtpZAAwj8NwMXg8fGYM0JtpkGYmkRGmFolwFWA0FLVmGxAuw2iKN6k
+ajl8U4pz5qzYFEKNL5IJMI8rS2Fsek1pgfpZ5dYFChgVW7urxFhAJCXMrHAOLfed
+SjXtZpvepXRvBtuvOosXSIjmY9x/3/1QeRvZpza2atWRv4pnKBldtI9BZDUQqS3F
+fi/ydXlZVeY3aHW6Cw9DfbnnLv2RegUzjUZCx07IrPulZmqS6rabIIwY/bhX+n7y
+YcP4ADkXDKct6QIDAQABoyAwHjAPBgNVHRMBAf8EBTADAQH/MAsGA1UdDwQEAwIC
+hDANBgkqhkiG9w0BAQUFAAOCAQEAAfoSQow7qv3C9SiOZ+h3s9reQBJnZUcSQ5AS
+90jGmtmcJ1eyWQyGxES0iKYPcF1GbSBkO/kqMzdM/E2GQnbHVrgiPj+9tTxjG/hK
+42K2AEACDYtuQWTui4K1BmrWRJvdoiGRrt87DhmOG6UY5wtUAZdgVjhwBGEWJhYp
+IgeNe5OEdrBkSBjYb2VnJOJFQA7bB7G4snTjNMY+n5+odISHU3debZLdXvX3gKVG
+nVwp91/LnCSCvvZ+nH9xLzNdTbXqhI96bJh/iXLNcwcHOWPYWKuANAs5FR7OSZ+l
+57gz8/BTaM4pTyJzER5p0+cTIzLGF7aYLuKKqXiKykjruO3U7A==
+-----END CERTIFICATE-----

+ 1 - 1
NetSSL_OpenSSL/samples/HTTPSTimeServer/src/HTTPSTimeServer.cpp

@@ -1,7 +1,7 @@
 //
 // TimeServer.cpp
 //
-// $Id: //poco/svn/NetSSL_OpenSSL/samples/HTTPSTimeServer/src/HTTPSTimeServer.cpp#1 $
+// $Id: //poco/Main/NetSSL_OpenSSL/samples/HTTPSTimeServer/src/HTTPSTimeServer.cpp#6 $
 //
 // This sample demonstrates the HTTPServer and related classes.
 //

+ 1 - 1
NetSSL_OpenSSL/samples/download/Makefile

@@ -14,6 +14,6 @@ objects = download
 
 target         = download
 target_version = 1
-target_libs    = PocoNetSSL PocoNet PocoUtil PocoXML PocoFoundation
+target_libs    = PocoNetSSL PocoCrypto PocoNet PocoUtil PocoXML PocoFoundation
 
 include $(POCO_BASE)/build/rules/exec

+ 4 - 4
NetSSL_OpenSSL/samples/download/download_vs71.vcproj

@@ -20,7 +20,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
+				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\Crypto\include;..\..\..\NetSSL_OpenSSL\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -37,7 +37,7 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib PocoNetSSLd.lib"
+				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib PocoCryptod.lib PocoNetSSLd.lib"
 				OutputFile="bin/downloadd.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="..\..\..\lib"
@@ -81,7 +81,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
+				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\Crypto\include;..\..\..\NetSSL_OpenSSL\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -97,7 +97,7 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib PocoNetSSL.lib"
+				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib PocoCrypto.lib PocoNetSSL.lib"
 				OutputFile="bin/download.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\lib"

+ 8 - 185
NetSSL_OpenSSL/samples/download/download_vs80.vcproj

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8.00"
+	Version="8,00"
 	Name="download"
 	ProjectGUID="{22F6B2E6-A532-4156-A49A-835A21BFF3F6}"
 	RootNamespace="download"
@@ -42,7 +42,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
+				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\Crypto\include;..\..\..\NetSSL_OpenSSL\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -67,12 +67,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoNetSSLd.lib PocoUtild.lib"
-				OutputFile="bin/$(ProjectName)d.exe"
+				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoCryptod.lib PocoNetSSLd.lib PocoUtild.lib"
+				OutputFile="bin/downloadd.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="..\..\..\lib"
 				GenerateDebugInformation="true"
-				ProgramDatabaseFile="bin/$(ProjectName)d.pdb"
+				ProgramDatabaseFile="bin/downloadd.pdb"
 				SubSystem="1"
 				TargetMachine="1"
 			/>
@@ -132,7 +132,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
+				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\Crypto\include;..\..\..\NetSSL_OpenSSL\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				StringPooling="true"
 				RuntimeLibrary="2"
@@ -156,185 +156,8 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoNetSSL.lib PocoUtil.lib"
-				OutputFile="bin/$(ProjectName).exe"
-				LinkIncremental="1"
-				AdditionalLibraryDirectories="..\..\..\lib"
-				GenerateDebugInformation="false"
-				ProgramDatabaseFile=""
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="debug_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
-				BufferSecurityCheck="true"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationmtd.lib PocoXMLmtd.lib PocoNetmtd.lib PocoNetSSLmtd.lib PocoUtilmtd.lib ws2_32.lib iphlpapi.lib advapi32.lib libeay32mt.lib ssleay32mt.lib"
-				OutputFile="bin/$(ProjectName)mtd.exe"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="..\..\..\lib"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile="bin/$(ProjectName)mtd.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="release_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="4"
-				InlineFunctionExpansion="1"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
-				StringPooling="true"
-				RuntimeLibrary="2"
-				BufferSecurityCheck="false"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationmt.lib PocoXMLmt.lib PocoNetmt.lib PocoNetSSLmt.lib PocoUtilmt.lib ws2_32.lib iphlpapi.lib advapi32.lib libeay32mt.lib ssleay32mt.lib"
-				OutputFile="bin/$(ProjectName)mt.exe"
+				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoCrypto.lib PocoNetSSL.lib PocoUtil.lib"
+				OutputFile="bin/download.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\lib"
 				GenerateDebugInformation="false"

+ 2 - 173
NetSSL_OpenSSL/samples/download/download_vs90.vcproj

@@ -67,7 +67,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoNetSSLd.lib PocoUtild.lib"
-				OutputFile="bin/$(ProjectName)d.exe"
+				OutputFile="bin/downloadd.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="..\..\..\lib"
 				GenerateDebugInformation="true"
@@ -153,178 +153,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoNetSSL.lib PocoUtil.lib"
-				OutputFile="bin/$(ProjectName).exe"
-				LinkIncremental="1"
-				AdditionalLibraryDirectories="..\..\..\lib"
-				GenerateDebugInformation="false"
-				ProgramDatabaseFile=""
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="debug_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
-				BufferSecurityCheck="true"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationmtd.lib PocoXMLmtd.lib PocoNetmtd.lib PocoNetSSLmtd.lib PocoUtilmtd.lib libeay32mtd.lib ssleay32mtd.lib ws2_32.lib advapi32.lib"
-				OutputFile="bin/$(ProjectName)mtd.exe"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="..\..\..\lib"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile="bin/downloadd.pdb"
-				SubSystem="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="release_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="4"
-				InlineFunctionExpansion="1"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				OmitFramePointers="true"
-				AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include;..\..\..\NetSSL_OpenSSL\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
-				StringPooling="true"
-				RuntimeLibrary="2"
-				BufferSecurityCheck="false"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="PocoFoundationmt.lib PocoXMLmt.lib PocoNetmt.lib PocoNetSSLmt.lib PocoUtilmt.lib libeay32mt.lib ssleay32mt.lib ws2_32.lib advapi32.lib"
-				OutputFile="bin/$(ProjectName)mt.exe"
+				OutputFile="bin/download.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\..\lib"
 				GenerateDebugInformation="false"

+ 6 - 2
NetSSL_OpenSSL/src/Context.cpp

@@ -1,7 +1,7 @@
 //
 // Context.cpp
 //
-// $Id: //poco/Main/NetSSL_OpenSSL/src/Context.cpp#17 $
+// $Id: //poco/Main/NetSSL_OpenSSL/src/Context.cpp#18 $
 //
 // Library: NetSSL_OpenSSL
 // Package: SSLCore
@@ -63,7 +63,11 @@ Context::Context(
 	_pSSLContext(0)
 {
 	_pSSLContext = SSL_CTX_new(SSLv23_method());
-	if (!_pSSLContext) throw SSLException("Cannot create SSL_CTX object");
+	if (!_pSSLContext) 
+	{
+		unsigned long err = ERR_get_error();
+		throw SSLException("Cannot create SSL_CTX object", ERR_error_string(err, 0));
+	}
 	SSL_CTX_set_default_passwd_cb(_pSSLContext, &SSLManager::privateKeyPasswdCallback);
 	Utility::clearErrorStack();
 	

+ 6 - 4
NetSSL_OpenSSL/src/SSLManager.cpp

@@ -1,7 +1,7 @@
 //
 // SSLManager.cpp
 //
-// $Id: //poco/Main/NetSSL_OpenSSL/src/SSLManager.cpp#14 $
+// $Id: //poco/Main/NetSSL_OpenSSL/src/SSLManager.cpp#15 $
 //
 // Library: NetSSL_OpenSSL
 // Package: SSLCore
@@ -38,7 +38,7 @@
 #include "Poco/Net/Context.h"
 #include "Poco/Net/Utility.h"
 #include "Poco/Net/PrivateKeyPassphraseHandler.h"
-#include "Poco/Net/SSLInitializer.h"
+#include "Poco/Crypto/OpenSSLInitializer.h"
 #include "Poco/Net/SSLException.h"
 #include "Poco/SingletonHolder.h"
 #include "Poco/Delegate.h"
@@ -72,7 +72,7 @@ const std::string SSLManager::CFG_CLIENT_PREFIX("openSSL.client.");
 
 SSLManager::SSLManager()
 {
-	SSLInitializer::initialize();
+	Poco::Crypto::OpenSSLInitializer::initialize();
 }
 
 
@@ -81,7 +81,9 @@ SSLManager::~SSLManager()
 	PrivateKeyPassPhrase.clear();
 	ClientVerificationError.clear();
 	ServerVerificationError.clear();
-	SSLInitializer::uninitialize();
+	_ptrDefaultServerContext = 0; // ensure all Context objects go away before we uninitialize OpenSSL.
+	_ptrDefaultClientContext = 0;
+	Poco::Crypto::OpenSSLInitializer::uninitialize();
 }
 
 

+ 10 - 13
NetSSL_OpenSSL/src/SecureSocketImpl.cpp

@@ -1,7 +1,7 @@
 //
 // SecureSocketImpl.cpp
 //
-// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#29 $
+// $Id: //poco/Main/NetSSL_OpenSSL/src/SecureSocketImpl.cpp#30 $
 //
 // Library: NetSSL_OpenSSL
 // Package: SSLSockets
@@ -237,17 +237,14 @@ void SecureSocketImpl::shutdown()
 {
 	if (_pSSL)
 	{
-		// if we can't get a clean SSL shutdown after 10
-		// attempts, something's probably wrong with the
-		// peer and we give up.
-		int rc;
-		int attempts = 0;
-		do
-		{
-			rc = SSL_shutdown(_pSSL);
-			++attempts;
-		}
-		while (rc == 0 && attempts < 10);
+		// A proper clean shutdown would require us to
+		// retry the shutdown if we get a zero return
+		// value, until SSL_shutdown() returns 1.
+		// However, this will lead to problems with
+		// most web browsers, so we just set the shutdown
+		// flag by calling SSL_shutdown() once and be
+		// done with it.
+		int rc = SSL_shutdown(_pSSL);
 		if (rc < 0) handleError(rc);
 		SSL_clear(_pSSL);
 		SSL_free(_pSSL);
@@ -304,7 +301,7 @@ int SecureSocketImpl::receiveBytes(void* buffer, int length, int flags)
 long SecureSocketImpl::verifyCertificate(const std::string& hostName)
 {
 	Context::VerificationMode mode = _pContext->verificationMode();
-	if (mode == Context::VERIFY_NONE || isLocalHost(hostName) && mode != Context::VERIFY_STRICT)
+	if (mode == Context::VERIFY_NONE || (isLocalHost(hostName) && mode != Context::VERIFY_STRICT))
 	{
 		return X509_V_OK;
 	}

+ 12 - 125
NetSSL_OpenSSL/src/X509Certificate.cpp

@@ -1,7 +1,7 @@
 //
 // X509Certificate.cpp
 //
-// $Id: //poco/Main/NetSSL_OpenSSL/src/X509Certificate.cpp#13 $
+// $Id: //poco/Main/NetSSL_OpenSSL/src/X509Certificate.cpp#14 $
 //
 // Library: NetSSL_OpenSSL
 // Package: SSLCore
@@ -54,73 +54,30 @@ namespace Net {
 
 
 X509Certificate::X509Certificate(std::istream& istr):
-	_pCert(0)
+	Poco::Crypto::X509Certificate(istr)
 {	
-	// copy certificate to a temporary file so that it
-	// can be read by OpenSSL.
-	Poco::TemporaryFile certFile;
-	std::string path = certFile.path();
-	Poco::FileOutputStream ostr(path);
-	Poco::StreamCopier::copyStream(istr, ostr);
-	ostr.close();
-	
-	BIO *pBIO = BIO_new(BIO_s_file());
-	if (!pBIO) throw SSLException("Cannot create BIO for reading certificate file");
-	if (!BIO_read_filename(pBIO, path.c_str()))
-	{
-		BIO_free(pBIO);
-		throw Poco::OpenFileException("Cannot open certificate file for reading");
-	}
-
-	_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
-	BIO_free(pBIO);
-	
-	if (!_pCert) throw SSLException("Faild to load certificate");
-
-	init();
 }
 
 
 X509Certificate::X509Certificate(const std::string& path):
-	_pCert(0)
+	Poco::Crypto::X509Certificate(path)
 {
-	BIO *pBIO = BIO_new(BIO_s_file());
-	if (!pBIO) throw SSLException("Cannot create BIO for reading certificate file");
-	if (!BIO_read_filename(pBIO, path.c_str()))
-	{
-		BIO_free(pBIO);
-		throw Poco::OpenFileException("Cannot open certificate file for reading");
-	}
-	
-	_pCert = PEM_read_bio_X509(pBIO, 0, 0, 0);
-	BIO_free(pBIO);
-	
-	if (!_pCert) throw SSLException("Faild to load certificate from " + path);
-
-	init();
 }
 
 
 X509Certificate::X509Certificate(X509* pCert):
-	_pCert(pCert)
+	Poco::Crypto::X509Certificate(pCert)
 {
-	poco_check_ptr(_pCert);
-	
-	_pCert = X509_dup(_pCert);
-	init();
 }
 
 
-X509Certificate::X509Certificate(const X509Certificate& cert):
-	_issuerName(cert._issuerName),
-	_subjectName(cert._subjectName),
-	_pCert(cert._pCert)
+X509Certificate::X509Certificate(const Poco::Crypto::X509Certificate& cert):
+	Poco::Crypto::X509Certificate(cert)
 {
-	_pCert = X509_dup(_pCert);
 }
 
 
-X509Certificate& X509Certificate::operator = (const X509Certificate& cert)
+X509Certificate& X509Certificate::operator = (const Poco::Crypto::X509Certificate& cert)
 {
 	X509Certificate tmp(cert);
 	swap(tmp);
@@ -128,41 +85,27 @@ X509Certificate& X509Certificate::operator = (const X509Certificate& cert)
 }
 
 
-void X509Certificate::swap(X509Certificate& cert)
-{
-	using std::swap;
-	swap(cert._issuerName, _issuerName);
-	swap(cert._subjectName, _subjectName);
-	swap(cert._pCert, _pCert);
-}
-
-
 X509Certificate::~X509Certificate()
 {
-	X509_free(_pCert);
 }
 
 
-void X509Certificate::init()
+long X509Certificate::verify(const std::string& hostName) const
 {
-	char buffer[NAME_BUFFER_SIZE];
-	X509_NAME_oneline(X509_get_issuer_name(_pCert), buffer, sizeof(buffer));
-	_issuerName = buffer;
-	X509_NAME_oneline(X509_get_subject_name(_pCert), buffer, sizeof(buffer));
-	_subjectName = buffer;
+	return verify(*this, hostName);
 }
 
 
-long X509Certificate::verify(const std::string& hostName) const
+long X509Certificate::verify(const Poco::Crypto::X509Certificate& certificate, const std::string& hostName)
 {		
 	std::string commonName;
 	std::set<std::string> dnsNames;
-	extractNames(commonName, dnsNames);
+	certificate.extractNames(commonName, dnsNames);
 	bool ok = (dnsNames.find(hostName) != dnsNames.end());
 
 	char buffer[NAME_BUFFER_SIZE];
 	X509_NAME* subj = 0;
-	if (!ok && (subj = X509_get_subject_name(_pCert)) && X509_NAME_get_text_by_NID(subj, NID_commonName, buffer, sizeof(buffer)) > 0)
+	if (!ok && (subj = X509_get_subject_name(const_cast<X509*>(certificate.certificate()))) && X509_NAME_get_text_by_NID(subj, NID_commonName, buffer, sizeof(buffer)) > 0)
 	{
 		buffer[NAME_BUFFER_SIZE - 1] = 0;
 		std::string commonName(buffer); // commonName can contain wildcards like *.appinf.com
@@ -241,60 +184,4 @@ bool X509Certificate::matchByAlias(const std::string& alias, const HostEntry& he
 }
 
 
-std::string X509Certificate::commonName() const
-{
-	if (X509_NAME* subj = X509_get_subject_name(_pCert))
-    {
-		char buffer[NAME_BUFFER_SIZE];
-		X509_NAME_get_text_by_NID(subj, NID_commonName, buffer, sizeof(buffer));
-		return std::string(buffer);
-    }
-    else return std::string();
-}
-
-
-void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>& domainNames) const
-{
-	domainNames.clear(); 
-	if (STACK_OF(GENERAL_NAME)* names = static_cast<STACK_OF(GENERAL_NAME)*>(X509_get_ext_d2i(_pCert, NID_subject_alt_name, 0, 0)))
-    {
-		for (int i = 0; i < sk_GENERAL_NAME_num(names); ++i)
-        {
-			const GENERAL_NAME* name = sk_GENERAL_NAME_value(names, i);
-			if (name->type == GEN_DNS)
-			{
-				const char* data = reinterpret_cast<char*>(ASN1_STRING_data(name->d.ia5));
-				std::size_t len = ASN1_STRING_length(name->d.ia5);
-				domainNames.insert(std::string(data, len));
-            }
-		}
-		GENERAL_NAMES_free(names);
-	}
- 
-	cmnName = commonName();
-	if (!cmnName.empty() && domainNames.empty())
-	{
-		domainNames.insert(cmnName);
-	}
-}
-
-
-Poco::DateTime X509Certificate::validFrom() const
-{
-	ASN1_TIME* certTime = X509_get_notBefore(_pCert);
-	std::string dateTime(reinterpret_cast<char*>(certTime->data));
-	int tzd;
-	return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
-}
-
-	
-Poco::DateTime X509Certificate::expiresOn() const
-{
-	ASN1_TIME* certTime = X509_get_notAfter(_pCert);
-	std::string dateTime(reinterpret_cast<char*>(certTime->data));
-	int tzd;
-	return DateTimeParser::parse("%y%m%d%H%M%S", dateTime, tzd);
-}
-
-
 } } // namespace Poco::Net

+ 1 - 1
NetSSL_OpenSSL/testsuite/Makefile

@@ -16,6 +16,6 @@ objects = NetSSLTestSuite Driver \
 
 target         = testrunner
 target_version = 1
-target_libs    = PocoNetSSL PocoNet PocoUtil PocoXML PocoFoundation CppUnit
+target_libs    = PocoNetSSL PocoNet PocoCrypto PocoUtil PocoXML PocoFoundation CppUnit
 
 include $(POCO_BASE)/build/rules/exec

+ 8 - 8
NetSSL_OpenSSL/testsuite/TestSuite_vs71.vcproj

@@ -20,7 +20,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
+				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Crypto\include;..\..\Util\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -81,7 +81,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
+				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Crypto\include;..\..\Util\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -130,15 +130,15 @@
 		</Configuration>
 		<Configuration
 			Name="debug_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
 			ConfigurationType="1"
 			UseOfMFC="2"
 			CharacterSet="2">
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
+				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Crypto\include;..\..\Util\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -186,8 +186,8 @@
 		</Configuration>
 		<Configuration
 			Name="release_static|Win32"
-			OutputDirectory="$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
 			ConfigurationType="1"
 			UseOfMFC="2"
 			CharacterSet="2">
@@ -199,7 +199,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
+				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Crypto\include;..\..\Util\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"

+ 14 - 14
NetSSL_OpenSSL/testsuite/TestSuite_vs80.vcproj

@@ -41,7 +41,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
+				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Crypto\include;..\..\Util\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -67,7 +67,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoFoundationd.lib PocoNetd.lib PocoNetSSLd.lib PocoUtild.lib"
-				OutputFile="bin/$(ProjectName)d.exe"
+				OutputFile="bin/TestSuited.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="..\..\lib"
 				GenerateDebugInformation="true"
@@ -131,7 +131,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
+				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Crypto\include;..\..\Util\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
 				StringPooling="true"
 				RuntimeLibrary="2"
@@ -156,7 +156,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoFoundation.lib PocoNet.lib PocoNetSSL.lib PocoUtil.lib"
-				OutputFile="bin/$(ProjectName).exe"
+				OutputFile="bin/TestSuite.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\lib"
 				GenerateDebugInformation="false"
@@ -193,8 +193,8 @@
 		</Configuration>
 		<Configuration
 			Name="debug_static|Win32"
-			OutputDirectory="obj\debug_static"
-			IntermediateDirectory="obj\debug_static"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
 			ConfigurationType="1"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			UseOfMFC="2"
@@ -218,7 +218,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
+				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Crypto\include;..\..\Util\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -243,8 +243,8 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="CppUnitmtd.lib WinTestRunnermtd.lib PocoFoundationmtd.lib PocoNetmtd.lib PocoNetSSLmtd.lib PocoUtilmtd.lib libeay32mtd.lib ssleay32mtd.lib ws2_32.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\debug_static\WinTestRunner.res"
-				OutputFile="bin/$(ProjectName)d.exe"
+				AdditionalDependencies="CppUnitmtd.lib WinTestRunnermtd.lib PocoFoundationmtd.lib PocoNetmtd.lib PocoNetSSLmtd.lib PocoUtilmtd.lib libeay32mtd.lib ssleay32mtd.lib PocoXMLmtd.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\debug_static\WinTestRunner.res"
+				OutputFile="bin/TestSuitemtd.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="..\..\lib"
 				GenerateDebugInformation="true"
@@ -279,8 +279,8 @@
 		</Configuration>
 		<Configuration
 			Name="release_static|Win32"
-			OutputDirectory="obj\release_static"
-			IntermediateDirectory="obj\release_static"
+			OutputDirectory="obj\$(ConfigurationName)"
+			IntermediateDirectory="obj\$(ConfigurationName)"
 			ConfigurationType="1"
 			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
 			UseOfMFC="2"
@@ -308,7 +308,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
+				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Crypto\include;..\..\Util\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
 				StringPooling="true"
 				RuntimeLibrary="2"
@@ -332,8 +332,8 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="CppUnitmt.lib WinTestRunnermt.lib PocoFoundationmt.lib PocoNetmt.lib PocoNetSSLmt.lib PocoUtilmt.lib libeay32mtd.lib ssleay32mtd.lib ws2_32.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\release_static\WinTestRunner.res"
-				OutputFile="bin/$(ProjectName).exe"
+				AdditionalDependencies="CppUnitmt.lib WinTestRunnermt.lib PocoFoundationmt.lib PocoXMLmt.lib PocoNetmt.lib PocoNetSSLmt.lib PocoUtilmt.lib libeay32mt.lib ssleay32mt.lib winmm.lib ..\..\CppUnit\WinTestRunner\obj\release_static\WinTestRunner.res"
+				OutputFile="bin/TestSuitemt.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\lib"
 				GenerateDebugInformation="false"

+ 2 - 173
NetSSL_OpenSSL/testsuite/TestSuite_vs90.vcproj

@@ -66,7 +66,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoFoundationd.lib PocoNetd.lib PocoNetSSLd.lib PocoUtild.lib"
-				OutputFile="bin/$(ProjectName)d.exe"
+				OutputFile="bin/TestSuited.exe"
 				LinkIncremental="2"
 				AdditionalLibraryDirectories="..\..\lib"
 				GenerateDebugInformation="true"
@@ -152,178 +152,7 @@
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoFoundation.lib PocoNet.lib PocoNetSSL.lib PocoUtil.lib"
-				OutputFile="bin/$(ProjectName).exe"
-				LinkIncremental="1"
-				AdditionalLibraryDirectories="..\..\lib"
-				GenerateDebugInformation="false"
-				ProgramDatabaseFile=""
-				SubSystem="2"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="debug_static|Win32"
-			OutputDirectory="obj\debug_static"
-			IntermediateDirectory="obj\debug_static"
-			ConfigurationType="1"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
-				BufferSecurityCheck="true"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="CppUnitmtd.lib WinTestRunnermtd.lib PocoFoundationmtd.lib PocoNetmtd.lib PocoNetSSLmtd.lib PocoUtilmtd.lib winmm.lib libeay32mtd.lib ssleay32mtd.lib ws2_32.lib ..\..\CppUnit\WinTestRunner\obj\debug_static\WinTestRunner.res"
-				OutputFile="bin/$(ProjectName)d.exe"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="..\..\lib"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile="bin/$(ProjectName)d.pdb"
-				SubSystem="2"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="release_static|Win32"
-			OutputDirectory="obj\release_static"
-			IntermediateDirectory="obj\release_static"
-			ConfigurationType="1"
-			UseOfMFC="2"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="4"
-				InlineFunctionExpansion="1"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				OmitFramePointers="true"
-				AdditionalIncludeDirectories="..\include;..\..\Net\include;..\..\Foundation\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Util\include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
-				StringPooling="true"
-				RuntimeLibrary="2"
-				BufferSecurityCheck="false"
-				TreatWChar_tAsBuiltInType="true"
-				ForceConformanceInForLoopScope="true"
-				RuntimeTypeInfo="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="0"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="CppUnitmt.lib WinTestRunnermt.lib PocoFoundationmt.lib PocoNetmt.lib PocoNetSSLmt.lib PocoUtilmt.lib winmm.lib libeay32mt.lib ssleay32mt.lib ws2_32.lib ..\..\CppUnit\WinTestRunner\obj\release_static\WinTestRunner.res"
-				OutputFile="bin/$(ProjectName).exe"
+				OutputFile="bin/TestSuite.exe"
 				LinkIncremental="1"
 				AdditionalLibraryDirectories="..\..\lib"
 				GenerateDebugInformation="false"