Commit 365e38b0 authored by svoj@april.(none)'s avatar svoj@april.(none)

Merge svojtovich@bk-internal.mysql.com:/home/bk/mysql-5.0

into  april.(none):/home/svoj/devel/mysql/BUG17810/mysql-5.0
parents 23d304b3 2b253498
...@@ -1278,3 +1278,7 @@ include/openssl ...@@ -1278,3 +1278,7 @@ include/openssl
mysql-test/r/bdb.log mysql-test/r/bdb.log
mysql-test/r/im_client_port.log mysql-test/r/im_client_port.log
mysql-test/r/udf.log mysql-test/r/udf.log
extra/yassl/taocrypt/benchmark/benchmark
extra/yassl/taocrypt/test/test
extra/yassl/testsuite/testsuite
client/mysql_upgrade
...@@ -74,5 +74,6 @@ hours: ...@@ -74,5 +74,6 @@ hours:
[jonas:]checkout:get [jonas:]checkout:get
[tomas:]checkout:get [tomas:]checkout:get
[guilhem:]checkout:get [guilhem:]checkout:get
[pekka:]checkout:get
checkout:edit checkout:edit
eoln:unix eoln:unix
# Microsoft Developer Studio Project File - Name="mysql_upgrade" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=mysql_upgrade - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "mysql_upgrade.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "mysql_upgrade.mak" CFG="mysql_upgrade - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "mysql_upgrade - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "mysql_upgrade - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE "mysql_upgrade - Win32 classic" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "mysql_upgrade - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "release"
# PROP Intermediate_Dir "release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D "NDEBUG" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib ..\extra\yassl\Release\yassl.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysql_upgrade.exe" /libpath:"..\lib_release\\"
# SUBTRACT LINK32 /incremental:yes
!ELSEIF "$(CFG)" == "mysql_upgrade - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "mysqlimp"
# PROP BASE Intermediate_Dir "mysqlimp"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "debug"
# PROP Intermediate_Dir "debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib setargv.obj ..\extra\yassl\Debug\yassl.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysql_upgrade.exe" /pdbtype:sept /libpath:"..\lib_debug\\"
!ELSEIF "$(CFG)" == "mysql_upgrade - Win32 classic"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "mysql_upgrade___Win32_classic"
# PROP BASE Intermediate_Dir "mysql_upgrade___Win32_classic"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "classic"
# PROP Intermediate_Dir "classic"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D "NDEBUG" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../" /D "_CONSOLE" /D "_WINDOWS" /D LICENSE=Commercial /D "DBUG_OFF" /D "_MBCS" /D "NDEBUG" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysql_upgrade.exe" /libpath:"..\lib_release\\"
# SUBTRACT BASE LINK32 /incremental:yes
# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib ..\extra\yassl\Release\yassl.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysql_upgrade.exe" /libpath:"..\lib_release\\"
# SUBTRACT LINK32 /incremental:yes
!ENDIF
# Begin Target
# Name "mysql_upgrade - Win32 Release"
# Name "mysql_upgrade - Win32 Debug"
# Name "mysql_upgrade - Win32 classic"
# Begin Source File
SOURCE=.\mysql_upgrade.c
# End Source File
# End Target
# End Project
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="mysql_upgrade"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\debug"
IntermediateDirectory=".\debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="../include,../"
PreprocessorDefinitions="_DEBUG;SAFEMALLOC;SAFE_MUTEX;_CONSOLE;_WINDOWS"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\debug/mysql_upgrade.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="1"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="wsock32.lib odbc32.lib odbccp32.lib setargv.obj"
OutputFile="../client_debug/mysql_upgrade.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories=""
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\debug/mysql_upgrade.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\debug/mysql_upgrade.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\release"
IntermediateDirectory=".\release"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="../include,../"
PreprocessorDefinitions="DBUG_OFF;_CONSOLE;_WINDOWS;NDEBUG"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
PrecompiledHeaderFile=".\release/mysql_upgrade.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="wsock32.lib odbc32.lib odbccp32.lib"
OutputFile="../client_release/mysql_upgrade.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories=""
ProgramDatabaseFile=".\release/mysql_upgrade.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\release/mysql_upgrade.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="classic|Win32"
OutputDirectory=".\classic"
IntermediateDirectory=".\classic"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories="../include,../"
PreprocessorDefinitions="_CONSOLE;_WINDOWS;LICENSE=Commercial;DBUG_OFF;NDEBUG"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
PrecompiledHeaderFile=".\classic/mysql_upgrade.pch"
AssemblerListingLocation=".\classic/"
ObjectFile=".\classic/"
ProgramDataBaseFileName=".\classic/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="wsock32.lib odbc32.lib odbccp32.lib"
OutputFile="../client_classic/mysql_upgrade.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories=""
ProgramDatabaseFile=".\classic/mysql_upgrade.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\classic/mysql_upgrade.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="mysql_upgrade.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="classic|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
# Microsoft Developer Studio Project File - Name="mysql_upgrade" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=mysql_upgrade - WinIA64 classic
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "mysql_upgrade_ia64.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "mysql_upgrade_ia64.mak" CFG="mysql_upgrade - WinIA64 classic"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "mysql_upgrade - WinIA64 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "mysql_upgrade - WinIA64 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE "mysql_upgrade - WinIA64 classic" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "mysql_upgrade - WinIA64 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "release"
# PROP Intermediate_Dir "release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN64" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /Zi /O2 /I "../include" /I "../" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D "NDEBUG" /D "_IA64_" /D "WIN64" /D "WIN32" /D "_AFX_NO_DAO_SUPPORT" /FD /G2 /EHsc /Wp64 /Zm600 /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64
# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysql_upgrade.exe" /libpath:"..\lib_release\\" /machine:IA64
!ELSEIF "$(CFG)" == "mysql_upgrade - WinIA64 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "mysqlimp"
# PROP BASE Intermediate_Dir "mysqlimp"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "debug"
# PROP Intermediate_Dir "debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN64" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MTd /W3 /Zi /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D "_IA64_" /D "WIN64" /D "WIN32" /D "_AFX_NO_DAO_SUPPORT" /FD /G2 /EHsc /Wp64 /Zm600 /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64
# ADD LINK32 setargv.obj ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysql_upgrade.exe" /libpath:"..\lib_debug\\" /machine:IA64
!ELSEIF "$(CFG)" == "mysql_upgrade - WinIA64 classic"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "mysql_upgrade___WinIA64_classic"
# PROP BASE Intermediate_Dir "mysql_upgrade___WinIA64_classic"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "classic"
# PROP Intermediate_Dir "classic"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D "NDEBUG" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /MT /W3 /Zi /O2 /I "../include" /I "../" /D "_CONSOLE" /D "_WINDOWS" /D LICENSE=Commercial /D "DBUG_OFF" /D "_MBCS" /D "NDEBUG" /D "_IA64_" /D "WIN64" /D "WIN32" /D "_AFX_NO_DAO_SUPPORT" /FD /G2 /EHsc /Wp64 /Zm600 /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysql_upgrade.exe" /libpath:"..\lib_release\\" /machine:IA64
# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysql_upgrade.exe" /libpath:"..\lib_release\\" /machine:IA64
!ENDIF
# Begin Target
# Name "mysql_upgrade - WinIA64 Release"
# Name "mysql_upgrade - WinIA64 Debug"
# Name "mysql_upgrade - WinIA64 classic"
# Begin Source File
SOURCE=.\mysql_upgrade.c
# End Source File
# End Target
# End Project
...@@ -423,6 +423,9 @@ Package=<4> ...@@ -423,6 +423,9 @@ Package=<4>
Project_Dep_Name mysqlimport Project_Dep_Name mysqlimport
End Project Dependency End Project Dependency
Begin Project Dependency Begin Project Dependency
Project_Dep_Name mysql_upgrade
End Project Dependency
Begin Project Dependency
Project_Dep_Name mysqlshow Project_Dep_Name mysqlshow
End Project Dependency End Project Dependency
Begin Project Dependency Begin Project Dependency
...@@ -507,6 +510,24 @@ Package=<4> ...@@ -507,6 +510,24 @@ Package=<4>
############################################################################### ###############################################################################
Project: "mysql_upgrade"=".\client\mysql_upgade.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name mysqlclient
End Project Dependency
Begin Project Dependency
Project_Dep_Name mysys
End Project Dependency
}}}
###############################################################################
Project: "mysqlserver"=".\mysqlserver\mysqlserver.dsp" - Package Owner=<4> Project: "mysqlserver"=".\mysqlserver\mysqlserver.dsp" - Package Owner=<4>
Package=<5> Package=<5>
......
...@@ -174,6 +174,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysqlimport", "client\mysql ...@@ -174,6 +174,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysqlimport", "client\mysql
{44D9C7DC-6636-4B82-BD01-6876C64017DF} = {44D9C7DC-6636-4B82-BD01-6876C64017DF} {44D9C7DC-6636-4B82-BD01-6876C64017DF} = {44D9C7DC-6636-4B82-BD01-6876C64017DF}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_upgrade", "client\mysql_upgrade.vcproj", "{AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3D}"
ProjectSection(ProjectDependencies) = postProject
{BA86AE72-0CF5-423D-BBA2-E12B0D72EBFB} = {BA86AE72-0CF5-423D-BBA2-E12B0D72EBFB}
{26383276-4843-494B-8BE0-8936ED3EBAAB} = {26383276-4843-494B-8BE0-8936ED3EBAAB}
{8762A9B8-72A9-462E-A9A2-F3265081F8AF} = {8762A9B8-72A9-462E-A9A2-F3265081F8AF}
{44D9C7DC-6636-4B82-BD01-6876C64017DF} = {44D9C7DC-6636-4B82-BD01-6876C64017DF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysqlserver", "mysqlserver\mysqlserver.vcproj", "{94B86159-C581-42CD-825D-C69CBC237E5C}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysqlserver", "mysqlserver\mysqlserver.vcproj", "{94B86159-C581-42CD-825D-C69CBC237E5C}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{EEC1300B-85A5-497C-B3E1-F708021DF859} = {EEC1300B-85A5-497C-B3E1-F708021DF859} {EEC1300B-85A5-497C-B3E1-F708021DF859} = {EEC1300B-85A5-497C-B3E1-F708021DF859}
...@@ -270,6 +278,7 @@ EndProject ...@@ -270,6 +278,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_client_test", "tests\mysql_client_test.vcproj", "{DA224DAB-5006-42BE-BB77-16E8BE5326D5}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_client_test", "tests\mysql_client_test.vcproj", "{DA224DAB-5006-42BE-BB77-16E8BE5326D5}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{26383276-4843-494B-8BE0-8936ED3EBAAB} = {26383276-4843-494B-8BE0-8936ED3EBAAB} {26383276-4843-494B-8BE0-8936ED3EBAAB} = {26383276-4843-494B-8BE0-8936ED3EBAAB}
{44D9C7DC-6636-4B82-BD01-6876C64017DF} = {44D9C7DC-6636-4B82-BD01-6876C64017DF}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_test_run_new", "mysql-test\mysql_test_run_new.vcproj", "{6189F838-21C6-42A1-B2D0-9146316573F7}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysql_test_run_new", "mysql-test\mysql_test_run_new.vcproj", "{6189F838-21C6-42A1-B2D0-9146316573F7}"
......
...@@ -508,6 +508,9 @@ Package=<4> ...@@ -508,6 +508,9 @@ Package=<4>
Project_Dep_Name mysqlimport Project_Dep_Name mysqlimport
End Project Dependency End Project Dependency
Begin Project Dependency Begin Project Dependency
Project_Dep_Name mysql_upgrade
End Project Dependency
Begin Project Dependency
Project_Dep_Name mysqlshow Project_Dep_Name mysqlshow
End Project Dependency End Project Dependency
Begin Project Dependency Begin Project Dependency
...@@ -580,6 +583,21 @@ Package=<4> ...@@ -580,6 +583,21 @@ Package=<4>
############################################################################### ###############################################################################
Project: "mysql_upgrade"=".\client\mysql_upgrade_ia64.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name mysqlclient
End Project Dependency
}}}
###############################################################################
Project: "mysqlserver"=".\mysqlserver\mysqlserver_ia64.dsp" - Package Owner=<4> Project: "mysqlserver"=".\mysqlserver\mysqlserver_ia64.dsp" - Package Owner=<4>
Package=<5> Package=<5>
......
...@@ -3188,6 +3188,49 @@ ...@@ -3188,6 +3188,49 @@
PreprocessorDefinitions=""/> PreprocessorDefinitions=""/>
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath="my_memmem.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Max|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="TLS_DEBUG|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="TLS|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File <File
RelativePath="my_messnc.c"> RelativePath="my_messnc.c">
<FileConfiguration <FileConfiguration
......
...@@ -31,6 +31,7 @@ LDADD= @CLIENT_EXTRA_LDFLAGS@ \ ...@@ -31,6 +31,7 @@ LDADD= @CLIENT_EXTRA_LDFLAGS@ \
$(top_builddir)/libmysql/libmysqlclient.la $(top_builddir)/libmysql/libmysqlclient.la
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \ bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
mysqldump mysqlimport mysqltest mysqlbinlog \ mysqldump mysqlimport mysqltest mysqlbinlog \
mysql_upgrade \
mysqltestmanagerc mysqltestmanager-pwgen mysqltestmanagerc mysqltestmanager-pwgen
noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \ noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \
client_priv.h client_priv.h
...@@ -48,11 +49,14 @@ mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix) ...@@ -48,11 +49,14 @@ mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix)
mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix) mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix)
mysqldump_SOURCES= mysqldump.c my_user.c $(yassl_dummy_link_fix) mysqldump_SOURCES= mysqldump.c my_user.c $(yassl_dummy_link_fix)
mysqlimport_SOURCES= mysqlimport.c $(yassl_dummy_link_fix) mysqlimport_SOURCES= mysqlimport.c $(yassl_dummy_link_fix)
mysql_upgrade_SOURCES= mysql_upgrade.c $(yassl_dummy_link_fix)
sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc
strings_src=decimal.c strings_src=decimal.c
# Fix for mit-threads # Fix for mit-threads
DEFS = -DUNDEF_THREADS_HACK DEFS = -DUNDEF_THREADS_HACK \
-DDEFAULT_MYSQL_HOME="\"$(prefix)\"" \
-DDATADIR="\"$(localstatedir)\""
link_sources: link_sources:
for f in $(sql_src) ; do \ for f in $(sql_src) ; do \
......
...@@ -3228,10 +3228,9 @@ com_status(String *buffer __attribute__((unused)), ...@@ -3228,10 +3228,9 @@ com_status(String *buffer __attribute__((unused)),
mysql_free_result(result); mysql_free_result(result);
} }
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
if (mysql.net.vio && mysql.net.vio->ssl_arg && if ((status= mysql_get_ssl_cipher(&mysql)))
SSL_get_cipher((SSL*) mysql.net.vio->ssl_arg))
tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
SSL_get_cipher((SSL*) mysql.net.vio->ssl_arg)); status);
else else
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
tee_puts("SSL:\t\t\tNot in use", stdout); tee_puts("SSL:\t\t\tNot in use", stdout);
......
This diff is collapsed.
...@@ -153,7 +153,7 @@ static uint global_expected_errors; ...@@ -153,7 +153,7 @@ static uint global_expected_errors;
/* ************************************************************************ */ /* ************************************************************************ */
static int record = 0, opt_sleep=0; static int record= 0, opt_sleep= -1;
static char *db = 0, *pass=0; static char *db = 0, *pass=0;
const char *user = 0, *host = 0, *unix_sock = 0, *opt_basedir="./"; const char *user = 0, *host = 0, *unix_sock = 0, *opt_basedir="./";
static int port = 0; static int port = 0;
...@@ -1724,11 +1724,12 @@ int do_sleep(struct st_query *query, my_bool real_sleep) ...@@ -1724,11 +1724,12 @@ int do_sleep(struct st_query *query, my_bool real_sleep)
query->first_argument); query->first_argument);
/* Fixed sleep time selected by --sleep option */ /* Fixed sleep time selected by --sleep option */
if (opt_sleep && !real_sleep) if (opt_sleep >= 0 && !real_sleep)
sleep_val= opt_sleep; sleep_val= opt_sleep;
DBUG_PRINT("info", ("sleep_val: %f", sleep_val)); DBUG_PRINT("info", ("sleep_val: %f", sleep_val));
my_sleep((ulong) (sleep_val * 1000000L)); if (sleep_val)
my_sleep((ulong) (sleep_val * 1000000L));
query->last_argument= sleep_end; query->last_argument= sleep_end;
return 0; return 0;
} }
...@@ -2935,7 +2936,7 @@ static struct my_option my_long_options[] = ...@@ -2935,7 +2936,7 @@ static struct my_option my_long_options[] =
"Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG, "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"sleep", 'T', "Sleep always this many seconds on sleep commands.", {"sleep", 'T', "Sleep always this many seconds on sleep commands.",
(gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, 0, 0,
0, 0, 0}, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &unix_sock, (gptr*) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, (gptr*) &unix_sock, (gptr*) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
......
AC_DEFUN([MYSQL_FIND_OPENSSL], [ AC_DEFUN([MYSQL_FIND_OPENSSL], [
incs="$1" incs="$1"
libs="$2" libs="$2"
eval shrexts=\"$shrext_cmds\"
case "$incs---$libs" in case "$incs---$libs" in
---) ---)
for d in /usr/ssl/include /usr/local/ssl/include /usr/include \ for d in /usr/ssl/include /usr/local/ssl/include /usr/include \
...@@ -15,7 +16,7 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [ ...@@ -15,7 +16,7 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [
/usr/lib /usr/lib64 /opt/ssl/lib /opt/openssl/lib \ /usr/lib /usr/lib64 /opt/ssl/lib /opt/openssl/lib \
/usr/freeware/lib32 /usr/local/lib/ ; do /usr/freeware/lib32 /usr/local/lib/ ; do
# Just to be safe, we test for ".so" anyway # Just to be safe, we test for ".so" anyway
if test -f $d/libssl.a || test -f $d/libssl.so || test -f $d/libssl$shrext_cmds ; then if test -f $d/libssl.a || test -f $d/libssl.so || test -f $d/libssl$shrext ; then
OPENSSL_LIB=$d OPENSSL_LIB=$d
fi fi
done done
...@@ -28,7 +29,7 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [ ...@@ -28,7 +29,7 @@ AC_DEFUN([MYSQL_FIND_OPENSSL], [
OPENSSL_INCLUDE=-I$incs OPENSSL_INCLUDE=-I$incs
fi fi
# Just to be safe, we test for ".so" anyway # Just to be safe, we test for ".so" anyway
if test -f $libs/libssl.a || test -f $libs/libssl.so || test -f $libs/libssl$shrext_cmds ; then if test -f $libs/libssl.a || test -f $libs/libssl.so || test -f $libs/libssl$shrext ; then
OPENSSL_LIB=$libs OPENSSL_LIB=$libs
fi fi
;; ;;
......
AC_CONFIG_FILES(extra/yassl/Makefile dnl AC_CONFIG_FILES(extra/yassl/Makefile dnl
extra/yassl/taocrypt/Makefile dnl extra/yassl/taocrypt/Makefile dnl
extra/yassl/taocrypt/src/Makefile dnl extra/yassl/taocrypt/src/Makefile dnl
extra/yassl/src/Makefile) extra/yassl/src/Makefile dnl
extra/yassl/testsuite/Makefile dnl
extra/yassl/taocrypt/test/Makefile dnl
extra/yassl/taocrypt/benchmark/Makefile)
AC_DEFUN([MYSQL_CHECK_YASSL], [ AC_DEFUN([MYSQL_CHECK_YASSL], [
AC_MSG_CHECKING(for yaSSL) AC_MSG_CHECKING(for yaSSL)
......
...@@ -90,8 +90,9 @@ case $SYSTEM_TYPE in ...@@ -90,8 +90,9 @@ case $SYSTEM_TYPE in
;; ;;
*) *)
# Just to be safe, we test for ".so" anyway # Just to be safe, we test for ".so" anyway
eval shrexts=\"$shrext_cmds\"
if test \( -f "$mysql_zlib_dir/lib/libz.a" -o -f "$mysql_zlib_dir/lib/libz.so" -o \ if test \( -f "$mysql_zlib_dir/lib/libz.a" -o -f "$mysql_zlib_dir/lib/libz.so" -o \
-f "$mysql_zlib_dir/lib/libz$shrext_cmds" \) \ -f "$mysql_zlib_dir/lib/libz$shrext" \) \
-a -f "$mysql_zlib_dir/include/zlib.h"; then -a -f "$mysql_zlib_dir/include/zlib.h"; then
ZLIB_INCLUDES="-I$mysql_zlib_dir/include" ZLIB_INCLUDES="-I$mysql_zlib_dir/include"
ZLIB_LIBS="-L$mysql_zlib_dir/lib -lz" ZLIB_LIBS="-L$mysql_zlib_dir/lib -lz"
......
...@@ -218,6 +218,7 @@ then ...@@ -218,6 +218,7 @@ then
else else
AC_PATH_PROG(AS, as, as) AC_PATH_PROG(AS, as, as)
fi fi
# Still need ranlib for readline; local static use only so no libtool. # Still need ranlib for readline; local static use only so no libtool.
AC_PROG_RANLIB AC_PROG_RANLIB
# We use libtool # We use libtool
...@@ -229,6 +230,13 @@ AC_PROG_LIBTOOL ...@@ -229,6 +230,13 @@ AC_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --preserve-dup-deps" LIBTOOL="$LIBTOOL --preserve-dup-deps"
AC_SUBST(LIBTOOL)dnl AC_SUBST(LIBTOOL)dnl
AC_SUBST(NM)dnl
# NM= "$NM -X64"
#archive_expsym_cmds= `echo "$archive_expsym_cmds" | sed -e '/"$(CC)"//'`
#archive_expsym_cmds= "$CC -q64 $archive_expsym_cmds"
# CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-ansi//; s/-pedantic//; s/-Wcheck//'`
#AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL AC_DISABLE_FAST_INSTALL AC_DISABLE_SHARED AC_DISABLE_STATIC #AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL AC_DISABLE_FAST_INSTALL AC_DISABLE_SHARED AC_DISABLE_STATIC
# AC_PROG_INSTALL # AC_PROG_INSTALL
...@@ -513,7 +521,7 @@ then ...@@ -513,7 +521,7 @@ then
AC_MSG_ERROR([MySQL requires an ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.]) AC_MSG_ERROR([MySQL requires an ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.])
fi fi
NOINST_LDFLAGS= NOINST_LDFLAGS="-static"
static_nss="" static_nss=""
STATIC_NSS_FLAGS="" STATIC_NSS_FLAGS=""
...@@ -735,9 +743,8 @@ AC_CHECK_FUNC(yp_get_default_domain, , ...@@ -735,9 +743,8 @@ AC_CHECK_FUNC(yp_get_default_domain, ,
AC_CHECK_FUNC(p2open, , AC_CHECK_LIB(gen, p2open)) AC_CHECK_FUNC(p2open, , AC_CHECK_LIB(gen, p2open))
# This may get things to compile even if bind-8 is installed # This may get things to compile even if bind-8 is installed
AC_CHECK_FUNC(bind, , AC_CHECK_LIB(bind, bind)) AC_CHECK_FUNC(bind, , AC_CHECK_LIB(bind, bind))
# For crypt() on Linux # Check if crypt() exists in libc or libcrypt, sets LIBS if needed
AC_CHECK_LIB(crypt, crypt) AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT, 1, [crypt]))
AC_CHECK_FUNC(crypt, AC_DEFINE([HAVE_CRYPT], [1], [crypt]))
# For sem_xxx functions on Solaris 2.6 # For sem_xxx functions on Solaris 2.6
AC_CHECK_FUNC(sem_init, , AC_CHECK_LIB(posix4, sem_init)) AC_CHECK_FUNC(sem_init, , AC_CHECK_LIB(posix4, sem_init))
......
SUBDIRS = taocrypt src SUBDIRS = taocrypt src testsuite
EXTRA_DIST = yassl.dsp yassl.dsw $(wildcard mySTL/*.hpp) EXTRA_DIST = yassl.dsp yassl.dsw $(wildcard mySTL/*.hpp)
yaSSL Release notes, version 0.9.6 yaSSL Release notes, version 1.2.2 (03/27/06)
This release of yaSSL contains minor bug fixes and portability enhancements.
See build instructions below under 1.0.6:
*******************yaSSL Release notes, version 1.2.0
This release of yaSSL contains minor bug fixes, portability enhancements,
Diffie-Hellman compatibility fixes for other servers and client,
optimization improvements, and x86 ASM changes.
See build instructions below under 1.0.6:
*****************yaSSL Release notes, version 1.1.5
This release of yaSSL contains minor bug fixes, portability enhancements,
and user requested changes including the ability to add all certificates in
a directory, more robust socket handling, no new overloading unless
requested, and an SSL_VERIFY_NONE option.
See build instructions below under 1.0.6:
******************yaSSL Release notes, version 1.0.6
This release of yaSSL contains minor bug fixes, portability enhancements,
x86 assembly for ARC4, SHA, MD5, and RIPEMD, --enable-ia32-asm configure
option, and a security patch for certificate chain processing.
--To build on Linux, Solaris, *BSD, Mac OS X, or Cygwin:
./configure
make
run testsuite from yaSSL-Home/testsuite to test the build
to make a release build:
./configure --disable-debug
make
run testsuite from yaSSL-Home/testsuite to test the build
--To build on Win32
Choose (Re)Build All from the project workspace
run Debug\testsuite.exe from yaSSL-Home\testsuite to test the build
--To enable ia32 assembly for TaoCrypt ciphers and message digests
On MSVC this is always on
On GCC **, use ./configure --enable-ia32-asm
** This isn't on by default because of the use of intel syntax and the
problem that olders versions of gas have with some addressing statements.
If you enable this and get assemler errors during compilation or can't
pass the TaoCrypt tests, please send todd@yassl.com a message and disable
this option in the meantime.
***************** yaSSL Release notes, version 1.0.5
This release of yaSSL contains minor bug fixes, portability enhancements,
x86 assembly for AES, 3DES, BLOWFISH, and TWOFISH, --without-debug configure
option, and --enable-kernel-mode configure option for using TaoCrypt with
kernel modules.
--To build on Linux, Solaris, *BSD, Mac OS X, or Cygwin:
./configure
make
run testsuite from yaSSL-Home/testsuite to test the build
to make a release build:
./configure --without-debug
make
run testsuite from yaSSL-Home/testsuite to test the build
--To build on Win32
Choose (Re)Build All from the project workspace
run Debug\testsuite.exe from yaSSL-Home\testsuite to test the build
******************yaSSL Release notes, version 1.0.1
This release of yaSSL contains minor bug fixes, portability enhancements,
GCC 3.4.4 support, MSVC 2003 support, and more documentation.
Please see build instructions in the release notes for 0.9.6 below.
******************yaSSL Release notes, version 1.0
This release of yaSSL contains minor bug fixes, portability enhancements,
GCC 4.0 support, testsuite, improvements, and API additions.
Please see build instructions in the release notes for 0.9.6 below.
******************yaSSL Release notes, version 0.9.9
This release of yaSSL contains minor bug fixes, portability enchancements,
MSVC 7 support, memory improvements, and API additions.
Please see build instructions in the release notes for 0.9.6 below.
******************yaSSL Release notes, version 0.9.8
This release of yaSSL contains minor bug fixes and portability enchancements.
Please see build instructions in the release notes for 0.9.6 below.
******************yaSSL Release notes, version 0.9.6
This release of yaSSL contains minor bug fixes, removal of STL support, and This release of yaSSL contains minor bug fixes, removal of STL support, and
removal of exceptions and rtti so that the library can be linked without the removal of exceptions and rtti so that the library can be linked without the
......
/* client.cpp */
#include "../../testsuite/test.hpp"
//#define TEST_RESUME
void client_test(void* args)
{
#ifdef _WIN32
WSADATA wsd;
WSAStartup(0x0002, &wsd);
#endif
SOCKET_T sockfd = 0;
int argc = 0;
char** argv = 0;
set_args(argc, argv, *static_cast<func_args*>(args));
tcp_connect(sockfd);
SSL_METHOD* method = TLSv1_client_method();
SSL_CTX* ctx = SSL_CTX_new(method);
set_certs(ctx);
SSL* ssl = SSL_new(ctx);
SSL_set_fd(ssl, sockfd);
if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
showPeer(ssl);
const char* cipher = 0;
int index = 0;
char list[1024];
strcpy(list, "cipherlist");
while ( (cipher = SSL_get_cipher_list(ssl, index++)) ) {
strcat(list, ":");
strcat(list, cipher);
}
printf("%s\n", list);
printf("Using Cipher Suite %s\n", SSL_get_cipher(ssl));
char msg[] = "hello yassl!";
if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))
err_sys("SSL_write failed");
char reply[1024];
reply[SSL_read(ssl, reply, sizeof(reply))] = 0;
printf("Server response: %s\n", reply);
#ifdef TEST_RESUME
SSL_SESSION* session = SSL_get_session(ssl);
SSL* sslResume = SSL_new(ctx);
#endif
SSL_shutdown(ssl);
SSL_free(ssl);
#ifdef TEST_RESUME
tcp_connect(sockfd);
SSL_set_fd(sslResume, sockfd);
SSL_set_session(sslResume, session);
if (SSL_connect(sslResume) != SSL_SUCCESS) err_sys("SSL resume failed");
if (SSL_write(sslResume, msg, sizeof(msg)) != sizeof(msg))
err_sys("SSL_write failed");
reply[SSL_read(sslResume, reply, sizeof(reply))] = 0;
printf("Server response: %s\n", reply);
SSL_shutdown(sslResume);
SSL_free(sslResume);
#endif // TEST_RESUME
SSL_CTX_free(ctx);
((func_args*)args)->return_code = 0;
}
#ifndef NO_MAIN_DRIVER
int main(int argc, char** argv)
{
func_args args;
args.argc = argc;
args.argv = argv;
client_test(&args);
return args.return_code;
}
#endif // NO_MAIN_DRIVER
# Microsoft Developer Studio Project File - Name="client" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=client - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "client.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "client.mak" CFG="client - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "client - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "client - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "client - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /O2 /I "..\..\taocrypt\include" /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "client - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "..\..\include" /I "..\..\taocrypt\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "client - Win32 Release"
# Name "client - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\client.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
/* echoclient.cpp */
#include "../../testsuite/test.hpp"
void echoclient_test(void* args)
{
#ifdef _WIN32
WSADATA wsd;
WSAStartup(0x0002, &wsd);
#endif
SOCKET_T sockfd = 0;
int argc = 0;
char** argv = 0;
FILE* fin = stdin;
FILE* fout = stdout;
bool inCreated = false;
bool outCreated = false;
set_args(argc, argv, *static_cast<func_args*>(args));
if (argc >= 2) {
fin = fopen(argv[1], "r");
inCreated = true;
}
if (argc >= 3) {
fout = fopen(argv[2], "w");
outCreated = true;
}
if (!fin) err_sys("can't open input file");
if (!fout) err_sys("can't open output file");
tcp_connect(sockfd);
SSL_METHOD* method = TLSv1_client_method();
SSL_CTX* ctx = SSL_CTX_new(method);
set_certs(ctx);
SSL* ssl = SSL_new(ctx);
SSL_set_fd(ssl, sockfd);
if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
char send[1024];
char reply[1024];
while (fgets(send, sizeof(send), fin)) {
int sendSz = strlen(send) + 1;
if (SSL_write(ssl, send, sendSz) != sendSz)
err_sys("SSL_write failed");
if (strncmp(send, "quit", 4) == 0) {
fputs("sending server shutdown command: quit!\n", fout);
break;
}
if (SSL_read(ssl, reply, sizeof(reply)) > 0)
fputs(reply, fout);
}
SSL_CTX_free(ctx);
SSL_free(ssl);
fflush(fout);
if (inCreated) fclose(fin);
if (outCreated) fclose(fout);
((func_args*)args)->return_code = 0;
}
#ifndef NO_MAIN_DRIVER
int main(int argc, char** argv)
{
func_args args;
args.argc = argc;
args.argv = argv;
echoclient_test(&args);
return args.return_code;
}
#endif // NO_MAIN_DRIVER
# Microsoft Developer Studio Project File - Name="echoclient" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=echoclient - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "echoclient.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "echoclient.mak" CFG="echoclient - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "echoclient - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "echoclient - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "echoclient - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /O2 /I "..\..\include" /I "..\..\taocrypt\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "echoclient - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "..\..\include" /I "..\..\taocrypt\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "echoclient - Win32 Release"
# Name "echoclient - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\echoclient.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
/* echoclient.cpp */
#include "openssl/ssl.h" /* openssl compatibility test */
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <winsock2.h>
#else
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#endif /* WIN32 */
void err_sys(const char* msg)
{
fputs("yassl client error: ", stderr);
fputs(msg, stderr);
exit(EXIT_FAILURE);
}
const char* loopback = "127.0.0.1";
const short yasslPort = 11111;
using namespace yaSSL;
int main(int argc, char** argv)
{
#ifdef WIN32
WSADATA wsd;
WSAStartup(0x0002, &wsd);
int sockfd;
#else
unsigned int sockfd;
#endif /* WIN32 */
FILE* fin = stdin;
FILE* fout = stdout;
if (argc >= 2) fin = fopen(argv[1], "r");
if (argc >= 3) fout = fopen(argv[2], "w");
if (!fin) err_sys("can't open input file");
if (!fout) err_sys("can't open output file");
sockfd = socket(AF_INET, SOCK_STREAM, 0);
sockaddr_in servaddr;
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(yasslPort);
servaddr.sin_addr.s_addr = inet_addr(loopback);
if (connect(sockfd, (const sockaddr*)&servaddr, sizeof(servaddr)) != 0)
err_sys("tcp connect failed");
SSL_METHOD* method = TLSv1_client_method();
SSL_CTX* ctx = SSL_CTX_new(method);
SSL* ssl = SSL_new(ctx);
SSL_set_fd(ssl, sockfd);
if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
char send[1024];
char reply[1024];
while (fgets(send, sizeof(send), fin)) {
int sendSz = strlen(send) + 1;
if (SSL_write(ssl, send, sendSz) != sendSz)
err_sys("SSL_write failed");
if (strncmp(send, "quit", 4) == 0) {
fputs("sending server shutdown command: quit!", fout);
break;
}
if (SSL_read(ssl, reply, sizeof(reply)) > 0)
fputs(reply, fout);
}
SSL_CTX_free(ctx);
SSL_free(ssl);
return 0;
}
/* echoserver.cpp */
#include "../../testsuite/test.hpp"
#ifndef NO_MAIN_DRIVER
#define ECHO_OUT
THREAD_RETURN YASSL_API echoserver_test(void*);
int main(int argc, char** argv)
{
func_args args;
args.argc = argc;
args.argv = argv;
echoserver_test(&args);
return args.return_code;
}
#endif // NO_MAIN_DRIVER
THREAD_RETURN YASSL_API echoserver_test(void* args)
{
#ifdef _WIN32
WSADATA wsd;
WSAStartup(0x0002, &wsd);
#endif
SOCKET_T sockfd = 0;
int argc = 0;
char** argv = 0;
set_args(argc, argv, *static_cast<func_args*>(args));
#ifdef ECHO_OUT
FILE* fout = stdout;
if (argc >= 2) fout = fopen(argv[1], "w");
if (!fout) err_sys("can't open output file");
#endif
tcp_listen(sockfd);
SSL_METHOD* method = TLSv1_server_method();
SSL_CTX* ctx = SSL_CTX_new(method);
set_serverCerts(ctx);
DH* dh = set_tmpDH(ctx);
bool shutdown(false);
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)
// signal ready to tcp_accept
func_args& server_args = *((func_args*)args);
tcp_ready& ready = *server_args.signal_;
pthread_mutex_lock(&ready.mutex_);
ready.ready_ = true;
pthread_cond_signal(&ready.cond_);
pthread_mutex_unlock(&ready.mutex_);
#endif
while (!shutdown) {
sockaddr_in client;
socklen_t client_len = sizeof(client);
int clientfd = accept(sockfd, (sockaddr*)&client, &client_len);
if (clientfd == -1) err_sys("tcp accept failed");
SSL* ssl = SSL_new(ctx);
SSL_set_fd(ssl, clientfd);
if (SSL_accept(ssl) != SSL_SUCCESS) err_sys("SSL_accept failed");
char command[1024];
int echoSz(0);
while ( (echoSz = SSL_read(ssl, command, sizeof(command))) > 0) {
if ( strncmp(command, "quit", 4) == 0) {
printf("client sent quit command: shutting down!\n");
shutdown = true;
break;
}
else if ( strncmp(command, "GET", 3) == 0) {
char type[] = "HTTP/1.0 200 ok\r\nContent-type:"
" text/html\r\n\r\n";
char header[] = "<html><body BGCOLOR=\"#ffffff\">\n<pre>\n";
char body[] = "greetings from yaSSL\n";
char footer[] = "</body></html>\r\n\r\n";
strncpy(command, type, sizeof(type));
echoSz = sizeof(type) - 1;
strncpy(&command[echoSz], header, sizeof(header));
echoSz += sizeof(header) - 1;
strncpy(&command[echoSz], body, sizeof(body));
echoSz += sizeof(body) - 1;
strncpy(&command[echoSz], footer, sizeof(footer));
echoSz += sizeof(footer);
if (SSL_write(ssl, command, echoSz) != echoSz)
err_sys("SSL_write failed");
break;
}
command[echoSz] = 0;
#ifdef ECHO_OUT
fputs(command, fout);
#endif
if (SSL_write(ssl, command, echoSz) != echoSz)
err_sys("SSL_write failed");
}
SSL_free(ssl);
}
#ifdef _WIN32
closesocket(sockfd);
#else
close(sockfd);
#endif
DH_free(dh);
SSL_CTX_free(ctx);
((func_args*)args)->return_code = 0;
return 0;
}
# Microsoft Developer Studio Project File - Name="echoserver" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=echoserver - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "echoserver.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "echoserver.mak" CFG="echoserver - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "echoserver - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "echoserver - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "echoserver - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /MT /W3 /O2 /I "..\..\include" /I "..\..\taocrypt\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "echoserver - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "..\..\include" /I "..\..\taocrypt\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "echoserver - Win32 Release"
# Name "echoserver - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\echoserver.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
/* server.cpp */
#include "../../testsuite/test.hpp"
THREAD_RETURN YASSL_API server_test(void* args)
{
#ifdef _WIN32
WSADATA wsd;
WSAStartup(0x0002, &wsd);
#endif
SOCKET_T sockfd = 0;
int clientfd = 0;
int argc = 0;
char** argv = 0;
set_args(argc, argv, *static_cast<func_args*>(args));
tcp_accept(sockfd, clientfd, *static_cast<func_args*>(args));
#ifdef _WIN32
closesocket(sockfd);
#else
close(sockfd);
#endif
SSL_METHOD* method = TLSv1_server_method();
SSL_CTX* ctx = SSL_CTX_new(method);
//SSL_CTX_set_cipher_list(ctx, "RC4-SHA");
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);
set_serverCerts(ctx);
DH* dh = set_tmpDH(ctx);
SSL* ssl = SSL_new(ctx);
SSL_set_fd(ssl, clientfd);
if (SSL_accept(ssl) != SSL_SUCCESS) err_sys("SSL_accept failed");
showPeer(ssl);
printf("Using Cipher Suite %s\n", SSL_get_cipher(ssl));
char command[1024];
command[SSL_read(ssl, command, sizeof(command))] = 0;
printf("First client command: %s\n", command);
char msg[] = "I hear you, fa shizzle!";
if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))
err_sys("SSL_write failed");
DH_free(dh);
SSL_CTX_free(ctx);
SSL_free(ssl);
((func_args*)args)->return_code = 0;
return 0;
}
#ifndef NO_MAIN_DRIVER
int main(int argc, char** argv)
{
func_args args;
args.argc = argc;
args.argv = argv;
server_test(&args);
return args.return_code;
}
#endif // NO_MAIN_DRIVER
# Microsoft Developer Studio Project File - Name="server" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=server - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "server.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "server.mak" CFG="server - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "server - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "server - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "server - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /O2 /I "..\..\include" /I "..\..\taocrypt\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "server - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "..\..\include" /I "..\..\taocrypt\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ENDIF
# Begin Target
# Name "server - Win32 Release"
# Name "server - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\server.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
...@@ -83,6 +83,7 @@ class CertManager { ...@@ -83,6 +83,7 @@ class CertManager {
SignerList signers_; // decoded CA keys and names SignerList signers_; // decoded CA keys and names
// plus verified chained certs // plus verified chained certs
bool verifyPeer_; bool verifyPeer_;
bool verifyNone_; // no error if verify fails
bool failNoCert_; bool failNoCert_;
bool sendVerify_; bool sendVerify_;
public: public:
...@@ -107,10 +108,12 @@ public: ...@@ -107,10 +108,12 @@ public:
uint get_privateKeyLength() const; uint get_privateKeyLength() const;
bool verifyPeer() const; bool verifyPeer() const;
bool verifyNone() const;
bool failNoCert() const; bool failNoCert() const;
bool sendVerify() const; bool sendVerify() const;
void setVerifyPeer(); void setVerifyPeer();
void setVerifyNone();
void setFailNoCert(); void setFailNoCert();
void setSendVerify(); void setSendVerify();
private: private:
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
namespace yaSSL { namespace yaSSL {
// Digest policy should implement a get_digest, update, and get sizes for pad and // Digest policy should implement a get_digest, update, and get sizes for pad
// digest // and digest
struct Digest : public virtual_base { struct Digest : public virtual_base {
virtual void get_digest(byte*) = 0; virtual void get_digest(byte*) = 0;
virtual void get_digest(byte*, const byte*, unsigned int) = 0; virtual void get_digest(byte*, const byte*, unsigned int) = 0;
...@@ -380,7 +380,7 @@ public: ...@@ -380,7 +380,7 @@ public:
uint get_agreedKeyLength() const; uint get_agreedKeyLength() const;
const byte* get_agreedKey() const; const byte* get_agreedKey() const;
const byte* get_publicKey() const; const byte* get_publicKey() const;
void makeAgreement(const byte*); void makeAgreement(const byte*, unsigned int);
void set_sizes(int&, int&, int&) const; void set_sizes(int&, int&, int&) const;
void get_parms(byte*, byte*, byte*) const; void get_parms(byte*, byte*, byte*) const;
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* *
*/ */
#ifndef yaSSL_openssl_h__ #ifndef yaSSL_openssl_h__
#define yaSSL_openssl_h__ #define yaSSL_openssl_h__
...@@ -49,7 +51,7 @@ extern "C" { ...@@ -49,7 +51,7 @@ extern "C" {
class X509_NAME; class X509_NAME;
#else #else
typedef struct SSL SSL; typedef struct SSL SSL;
typedef struct SSL_SESION SSL_SESSION; typedef struct SSL_SESSION SSL_SESSION;
typedef struct SSL_METHOD SSL_METHOD; typedef struct SSL_METHOD SSL_METHOD;
typedef struct SSL_CTX SSL_CTX; typedef struct SSL_CTX SSL_CTX;
typedef struct SSL_CIPHER SSL_CIPHER; typedef struct SSL_CIPHER SSL_CIPHER;
...@@ -258,6 +260,8 @@ int SSL_pending(SSL*); ...@@ -258,6 +260,8 @@ int SSL_pending(SSL*);
enum { /* ssl Constants */ enum { /* ssl Constants */
SSL_BAD_STAT = -7,
SSL_BAD_PATH = -6,
SSL_BAD_FILETYPE = -5, SSL_BAD_FILETYPE = -5,
SSL_BAD_FILE = -4, SSL_BAD_FILE = -4,
SSL_NOT_IMPLEMENTED = -3, SSL_NOT_IMPLEMENTED = -3,
......
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
uint send(const byte* buf, unsigned int len, int flags = 0) const; uint send(const byte* buf, unsigned int len, int flags = 0) const;
uint receive(byte* buf, unsigned int len, int flags = 0) const; uint receive(byte* buf, unsigned int len, int flags = 0) const;
void wait() const; bool wait() const;
void closeSocket(); void closeSocket();
void shutDown(int how = SD_SEND); void shutDown(int how = SD_SEND);
......
/* yassl.hpp
*
* Copyright (C) 2003 Sawtooth Consulting Ltd.
*
* This file is part of yaSSL.
*
* yaSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* yaSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/* yaSSL externel header defines yaSSL API
*/
#ifndef yaSSL_EXT_HPP
#define yaSSL_EXT_HPP
namespace yaSSL {
#ifdef _WIN32
typedef unsigned int SOCKET_T;
#else
typedef int SOCKET_T;
#endif
class Client {
public:
Client();
~Client();
// basics
int Connect(SOCKET_T);
int Write(const void*, int);
int Read(void*, int);
// options
void SetCA(const char*);
void SetCert(const char*);
void SetKey(const char*);
private:
struct ClientImpl;
ClientImpl* pimpl_;
Client(const Client&); // hide copy
Client& operator=(const Client&); // and assign
};
class Server {
public:
Server();
~Server();
// basics
int Accept(SOCKET_T);
int Write(const void*, int);
int Read(void*, int);
// options
void SetCA(const char*);
void SetCert(const char*);
void SetKey(const char*);
private:
struct ServerImpl;
ServerImpl* pimpl_;
Server(const Server&); // hide copy
Server& operator=(const Server&); // and assign
};
} // namespace yaSSL
#endif // yaSSL_EXT_HPP
...@@ -59,6 +59,10 @@ enum YasslError { ...@@ -59,6 +59,10 @@ enum YasslError {
enum Library { yaSSL_Lib = 0, CryptoLib, SocketLib }; enum Library { yaSSL_Lib = 0, CryptoLib, SocketLib };
enum { MAX_ERROR_SZ = 80 };
void SetErrorString(YasslError, char*);
// Base class for all yaSSL exceptions // Base class for all yaSSL exceptions
class Error : public mySTL::runtime_error { class Error : public mySTL::runtime_error {
......
...@@ -662,7 +662,7 @@ struct Parameters { ...@@ -662,7 +662,7 @@ struct Parameters {
uint8 suites_size_; uint8 suites_size_;
Cipher suites_[MAX_SUITE_SZ]; Cipher suites_[MAX_SUITE_SZ];
char cipher_name_[MAX_SUITE_NAME]; char cipher_name_[MAX_SUITE_NAME];
char cipher_list_[MAX_CIPHER_LIST]; char cipher_list_[MAX_CIPHERS][MAX_SUITE_NAME];
Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion); Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion);
......
...@@ -77,8 +77,6 @@ enum ServerState { ...@@ -77,8 +77,6 @@ enum ServerState {
// combines all states // combines all states
class States { class States {
enum {MAX_ERROR_SZ = 80 };
RecordLayerState recordLayer_; RecordLayerState recordLayer_;
HandShakeState handshakeLayer_; HandShakeState handshakeLayer_;
ClientState clientState_; ClientState clientState_;
...@@ -227,7 +225,8 @@ sslFactory& GetSSL_Factory(); ...@@ -227,7 +225,8 @@ sslFactory& GetSSL_Factory();
class SSL_METHOD { class SSL_METHOD {
ProtocolVersion version_; ProtocolVersion version_;
ConnectionEnd side_; ConnectionEnd side_;
bool verifyPeer_; bool verifyPeer_; // request or send certificate
bool verifyNone_; // whether to verify certificate
bool failNoCert_; bool failNoCert_;
public: public:
explicit SSL_METHOD(ConnectionEnd ce, ProtocolVersion pv); explicit SSL_METHOD(ConnectionEnd ce, ProtocolVersion pv);
...@@ -236,9 +235,11 @@ public: ...@@ -236,9 +235,11 @@ public:
ConnectionEnd getSide() const; ConnectionEnd getSide() const;
void setVerifyPeer(); void setVerifyPeer();
void setVerifyNone();
void setFailNoCert(); void setFailNoCert();
bool verifyPeer() const; bool verifyPeer() const;
bool verifyNone() const;
bool failNoCert() const; bool failNoCert() const;
private: private:
SSL_METHOD(const SSL_METHOD&); // hide copy SSL_METHOD(const SSL_METHOD&); // hide copy
...@@ -331,6 +332,7 @@ public: ...@@ -331,6 +332,7 @@ public:
const Stats& GetStats() const; const Stats& GetStats() const;
void setVerifyPeer(); void setVerifyPeer();
void setVerifyNone();
void setFailNoCert(); void setFailNoCert();
bool SetCipherList(const char*); bool SetCipherList(const char*);
bool SetDH(const DH&); bool SetDH(const DH&);
......
...@@ -39,32 +39,34 @@ namespace yaSSL { ...@@ -39,32 +39,34 @@ namespace yaSSL {
void CleanUp(); void CleanUp();
// library allocation #ifdef YASSL_PURE_C
struct new_t {}; // yaSSL New type
extern new_t ys; // pass in parameter
} // namespace yaSSL // library allocation
struct new_t {}; // yaSSL New type
extern new_t ys; // pass in parameter
void* operator new (size_t, yaSSL::new_t); } // namespace yaSSL
void* operator new[](size_t, yaSSL::new_t);
void operator delete (void*, yaSSL::new_t); void* operator new (size_t, yaSSL::new_t);
void operator delete[](void*, yaSSL::new_t); void* operator new[](size_t, yaSSL::new_t);
void operator delete (void*, yaSSL::new_t);
void operator delete[](void*, yaSSL::new_t);
namespace yaSSL {
namespace yaSSL {
template<typename T>
void ysDelete(T* ptr) template<typename T>
{ void ysDelete(T* ptr)
{
if (ptr) ptr->~T(); if (ptr) ptr->~T();
::operator delete(ptr, yaSSL::ys); ::operator delete(ptr, yaSSL::ys);
} }
template<typename T> template<typename T>
void ysArrayDelete(T* ptr) void ysArrayDelete(T* ptr)
{ {
// can't do array placement destruction since not tracking size in // can't do array placement destruction since not tracking size in
// allocation, only allow builtins to use array placement since they // allocation, only allow builtins to use array placement since they
// don't need destructors called // don't need destructors called
...@@ -72,15 +74,40 @@ void ysArrayDelete(T* ptr) ...@@ -72,15 +74,40 @@ void ysArrayDelete(T* ptr)
(void)sizeof(builtin); (void)sizeof(builtin);
::operator delete[](ptr, yaSSL::ys); ::operator delete[](ptr, yaSSL::ys);
} }
#define NEW_YS new (ys)
// to resolve compiler generated operator delete on base classes with // to resolve compiler generated operator delete on base classes with
// virtual destructors (when on stack), make sure doesn't get called // virtual destructors (when on stack), make sure doesn't get called
class virtual_base { class virtual_base {
public: public:
static void operator delete(void*) { assert(0); } static void operator delete(void*) { assert(0); }
}; };
#else // YASSL_PURE_C
template<typename T>
void ysDelete(T* ptr)
{
delete ptr;
}
template<typename T>
void ysArrayDelete(T* ptr)
{
delete[] ptr;
}
#define NEW_YS new
class virtual_base {};
#endif // YASSL_PURE_C
typedef unsigned char uint8; typedef unsigned char uint8;
...@@ -110,7 +137,7 @@ const int KEY_PREFIX = 7; // up to 7 prefix letters for key rounds ...@@ -110,7 +137,7 @@ const int KEY_PREFIX = 7; // up to 7 prefix letters for key rounds
const int FORTEZZA_MAX = 128; // Maximum Fortezza Key length const int FORTEZZA_MAX = 128; // Maximum Fortezza Key length
const int MAX_SUITE_SZ = 64; // 32 max suites * sizeof(suite) const int MAX_SUITE_SZ = 64; // 32 max suites * sizeof(suite)
const int MAX_SUITE_NAME = 48; // max length of suite name const int MAX_SUITE_NAME = 48; // max length of suite name
const int MAX_CIPHER_LIST = 512; // max length of cipher list names const int MAX_CIPHERS = 32; // max supported ciphers for cipher list
const int SIZEOF_ENUM = 1; // SSL considers an enum 1 byte, not 4 const int SIZEOF_ENUM = 1; // SSL considers an enum 1 byte, not 4
const int SIZEOF_SENDER = 4; // Sender constant, for finished generation const int SIZEOF_SENDER = 4; // Sender constant, for finished generation
const int PAD_MD5 = 48; // pad length 1 and 2 for md5 finished const int PAD_MD5 = 48; // pad length 1 and 2 for md5 finished
......
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#define mySTL_HELPERS_HPP #define mySTL_HELPERS_HPP
#include <stdlib.h> #include <stdlib.h>
#ifdef _MSC_VER
#include <new>
#endif
/* /*
Workaround for the lack of operator new(size_t, void*) Workaround for the lack of operator new(size_t, void*)
...@@ -43,7 +46,6 @@ ...@@ -43,7 +46,6 @@
typedef Dummy* yassl_pointer; typedef Dummy* yassl_pointer;
namespace mySTL { namespace mySTL {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* with SSL types and sockets * with SSL types and sockets
*/ */
#include <string.h> // memcpy #include <string.h> // memcpy
#include "runtime.hpp" #include "runtime.hpp"
#include "buffer.hpp" #include "buffer.hpp"
...@@ -63,13 +64,13 @@ input_buffer::input_buffer() ...@@ -63,13 +64,13 @@ input_buffer::input_buffer()
input_buffer::input_buffer(uint s) input_buffer::input_buffer(uint s)
: size_(0), current_(0), buffer_(new (ys) byte[s]), end_(buffer_ + s) : size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
{} {}
// with assign // with assign
input_buffer::input_buffer(uint s, const byte* t, uint len) input_buffer::input_buffer(uint s, const byte* t, uint len)
: size_(0), current_(0), buffer_(new (ys) byte[s]), end_(buffer_ + s) : size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
{ {
assign(t, len); assign(t, len);
} }
...@@ -85,7 +86,7 @@ input_buffer::~input_buffer() ...@@ -85,7 +86,7 @@ input_buffer::~input_buffer()
void input_buffer::allocate(uint s) void input_buffer::allocate(uint s)
{ {
assert(!buffer_); // find realloc error assert(!buffer_); // find realloc error
buffer_ = new (ys) byte[s]; buffer_ = NEW_YS byte[s];
end_ = buffer_ + s; end_ = buffer_ + s;
} }
...@@ -97,7 +98,7 @@ byte* input_buffer::get_buffer() const ...@@ -97,7 +98,7 @@ byte* input_buffer::get_buffer() const
} }
// after a raw write user can set new (ys) size // after a raw write user can set NEW_YS size
// if you know the size before the write use assign() // if you know the size before the write use assign()
void input_buffer::add_size(uint i) void input_buffer::add_size(uint i)
{ {
...@@ -199,13 +200,13 @@ output_buffer::output_buffer() ...@@ -199,13 +200,13 @@ output_buffer::output_buffer()
// with allocate // with allocate
output_buffer::output_buffer(uint s) output_buffer::output_buffer(uint s)
: current_(0), buffer_(new (ys) byte[s]), end_(buffer_ + s) : current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
{} {}
// with assign // with assign
output_buffer::output_buffer(uint s, const byte* t, uint len) output_buffer::output_buffer(uint s, const byte* t, uint len)
: current_(0), buffer_(new (ys) byte[s]), end_(buffer_+ s) : current_(0), buffer_(NEW_YS byte[s]), end_(buffer_+ s)
{ {
write(t, len); write(t, len);
} }
...@@ -240,7 +241,7 @@ void output_buffer::set_current(uint c) ...@@ -240,7 +241,7 @@ void output_buffer::set_current(uint c)
void output_buffer::allocate(uint s) void output_buffer::allocate(uint s)
{ {
assert(!buffer_); // find realloc error assert(!buffer_); // find realloc error
buffer_ = new (ys) byte[s]; end_ = buffer_ + s; buffer_ = NEW_YS byte[s]; end_ = buffer_ + s;
} }
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
namespace yaSSL { namespace yaSSL {
x509::x509(uint sz) : length_(sz), buffer_(new (ys) opaque[sz]) x509::x509(uint sz) : length_(sz), buffer_(NEW_YS opaque[sz])
{ {
} }
...@@ -51,7 +51,7 @@ x509::~x509() ...@@ -51,7 +51,7 @@ x509::~x509()
x509::x509(const x509& that) : length_(that.length_), x509::x509(const x509& that) : length_(that.length_),
buffer_(new (ys) opaque[length_]) buffer_(NEW_YS opaque[length_])
{ {
memcpy(buffer_, that.buffer_, length_); memcpy(buffer_, that.buffer_, length_);
} }
...@@ -92,7 +92,8 @@ opaque* x509::use_buffer() ...@@ -92,7 +92,8 @@ opaque* x509::use_buffer()
//CertManager //CertManager
CertManager::CertManager() CertManager::CertManager()
: peerX509_(0), verifyPeer_(false), failNoCert_(false), sendVerify_(false) : peerX509_(0), verifyPeer_(false), verifyNone_(false), failNoCert_(false),
sendVerify_(false)
{} {}
...@@ -114,6 +115,12 @@ bool CertManager::verifyPeer() const ...@@ -114,6 +115,12 @@ bool CertManager::verifyPeer() const
} }
bool CertManager::verifyNone() const
{
return verifyNone_;
}
bool CertManager::failNoCert() const bool CertManager::failNoCert() const
{ {
return failNoCert_; return failNoCert_;
...@@ -132,6 +139,12 @@ void CertManager::setVerifyPeer() ...@@ -132,6 +139,12 @@ void CertManager::setVerifyPeer()
} }
void CertManager::setVerifyNone()
{
verifyNone_ = true;
}
void CertManager::setFailNoCert() void CertManager::setFailNoCert()
{ {
failNoCert_ = true; failNoCert_ = true;
...@@ -153,7 +166,7 @@ void CertManager::AddPeerCert(x509* x) ...@@ -153,7 +166,7 @@ void CertManager::AddPeerCert(x509* x)
void CertManager::CopySelfCert(const x509* x) void CertManager::CopySelfCert(const x509* x)
{ {
if (x) if (x)
list_.push_back(new (ys) x509(*x)); list_.push_back(NEW_YS x509(*x));
} }
...@@ -161,11 +174,12 @@ void CertManager::CopySelfCert(const x509* x) ...@@ -161,11 +174,12 @@ void CertManager::CopySelfCert(const x509* x)
int CertManager::CopyCaCert(const x509* x) int CertManager::CopyCaCert(const x509* x)
{ {
TaoCrypt::Source source(x->get_buffer(), x->get_length()); TaoCrypt::Source source(x->get_buffer(), x->get_length());
TaoCrypt::CertDecoder cert(source, true, &signers_); TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_,
TaoCrypt::CertDecoder::CA);
if (!cert.GetError().What()) { if (!cert.GetError().What()) {
const TaoCrypt::PublicKey& key = cert.GetPublicKey(); const TaoCrypt::PublicKey& key = cert.GetPublicKey();
signers_.push_back(new (ys) TaoCrypt::Signer(key.GetKey(), key.size(), signers_.push_back(NEW_YS TaoCrypt::Signer(key.GetKey(), key.size(),
cert.GetCommonName(), cert.GetHash())); cert.GetCommonName(), cert.GetHash()));
} }
return cert.GetError().What(); return cert.GetError().What();
...@@ -228,13 +242,13 @@ int CertManager::Validate() ...@@ -228,13 +242,13 @@ int CertManager::Validate()
while ( count > 1 ) { while ( count > 1 ) {
TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length()); TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());
TaoCrypt::CertDecoder cert(source, true, &signers_); TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
if (int err = cert.GetError().What()) if (int err = cert.GetError().What())
return err; return err;
const TaoCrypt::PublicKey& key = cert.GetPublicKey(); const TaoCrypt::PublicKey& key = cert.GetPublicKey();
signers_.push_back(new (ys) TaoCrypt::Signer(key.GetKey(), key.size(), signers_.push_back(NEW_YS TaoCrypt::Signer(key.GetKey(), key.size(),
cert.GetCommonName(), cert.GetHash())); cert.GetCommonName(), cert.GetHash()));
--last; --last;
--count; --count;
...@@ -243,7 +257,7 @@ int CertManager::Validate() ...@@ -243,7 +257,7 @@ int CertManager::Validate()
if (count) { if (count) {
// peer's is at the front // peer's is at the front
TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length()); TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());
TaoCrypt::CertDecoder cert(source, true, &signers_); TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
if (int err = cert.GetError().What()) if (int err = cert.GetError().What())
return err; return err;
...@@ -259,7 +273,7 @@ int CertManager::Validate() ...@@ -259,7 +273,7 @@ int CertManager::Validate()
int iSz = cert.GetIssuer() ? strlen(cert.GetIssuer()) + 1 : 0; int iSz = cert.GetIssuer() ? strlen(cert.GetIssuer()) + 1 : 0;
int sSz = cert.GetCommonName() ? strlen(cert.GetCommonName()) + 1 : 0; int sSz = cert.GetCommonName() ? strlen(cert.GetCommonName()) + 1 : 0;
peerX509_ = new (ys) X509(cert.GetIssuer(), iSz, cert.GetCommonName(), peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(),
sSz); sSz);
} }
return 0; return 0;
......
...@@ -58,13 +58,13 @@ struct MD5::MD5Impl { ...@@ -58,13 +58,13 @@ struct MD5::MD5Impl {
}; };
MD5::MD5() : pimpl_(new (ys) MD5Impl) {} MD5::MD5() : pimpl_(NEW_YS MD5Impl) {}
MD5::~MD5() { ysDelete(pimpl_); } MD5::~MD5() { ysDelete(pimpl_); }
MD5::MD5(const MD5& that) : Digest(), pimpl_(new (ys) MD5::MD5(const MD5& that) : Digest(), pimpl_(NEW_YS
MD5Impl(that.pimpl_->md5_)) {} MD5Impl(that.pimpl_->md5_)) {}
...@@ -116,13 +116,13 @@ struct SHA::SHAImpl { ...@@ -116,13 +116,13 @@ struct SHA::SHAImpl {
}; };
SHA::SHA() : pimpl_(new (ys) SHAImpl) {} SHA::SHA() : pimpl_(NEW_YS SHAImpl) {}
SHA::~SHA() { ysDelete(pimpl_); } SHA::~SHA() { ysDelete(pimpl_); }
SHA::SHA(const SHA& that) : Digest(), pimpl_(new (ys) SHAImpl(that.pimpl_->sha_)) {} SHA::SHA(const SHA& that) : Digest(), pimpl_(NEW_YS SHAImpl(that.pimpl_->sha_)) {}
SHA& SHA::operator=(const SHA& that) SHA& SHA::operator=(const SHA& that)
{ {
...@@ -173,13 +173,13 @@ struct RMD::RMDImpl { ...@@ -173,13 +173,13 @@ struct RMD::RMDImpl {
}; };
RMD::RMD() : pimpl_(new (ys) RMDImpl) {} RMD::RMD() : pimpl_(NEW_YS RMDImpl) {}
RMD::~RMD() { ysDelete(pimpl_); } RMD::~RMD() { ysDelete(pimpl_); }
RMD::RMD(const RMD& that) : Digest(), pimpl_(new (ys) RMDImpl(that.pimpl_->rmd_)) {} RMD::RMD(const RMD& that) : Digest(), pimpl_(NEW_YS RMDImpl(that.pimpl_->rmd_)) {}
RMD& RMD::operator=(const RMD& that) RMD& RMD::operator=(const RMD& that)
{ {
...@@ -230,7 +230,7 @@ struct HMAC_MD5::HMAC_MD5Impl { ...@@ -230,7 +230,7 @@ struct HMAC_MD5::HMAC_MD5Impl {
HMAC_MD5::HMAC_MD5(const byte* secret, unsigned int len) HMAC_MD5::HMAC_MD5(const byte* secret, unsigned int len)
: pimpl_(new (ys) HMAC_MD5Impl) : pimpl_(NEW_YS HMAC_MD5Impl)
{ {
pimpl_->mac_.SetKey(secret, len); pimpl_->mac_.SetKey(secret, len);
} }
...@@ -280,7 +280,7 @@ struct HMAC_SHA::HMAC_SHAImpl { ...@@ -280,7 +280,7 @@ struct HMAC_SHA::HMAC_SHAImpl {
HMAC_SHA::HMAC_SHA(const byte* secret, unsigned int len) HMAC_SHA::HMAC_SHA(const byte* secret, unsigned int len)
: pimpl_(new (ys) HMAC_SHAImpl) : pimpl_(NEW_YS HMAC_SHAImpl)
{ {
pimpl_->mac_.SetKey(secret, len); pimpl_->mac_.SetKey(secret, len);
} }
...@@ -331,7 +331,7 @@ struct HMAC_RMD::HMAC_RMDImpl { ...@@ -331,7 +331,7 @@ struct HMAC_RMD::HMAC_RMDImpl {
HMAC_RMD::HMAC_RMD(const byte* secret, unsigned int len) HMAC_RMD::HMAC_RMD(const byte* secret, unsigned int len)
: pimpl_(new (ys) HMAC_RMDImpl) : pimpl_(NEW_YS HMAC_RMDImpl)
{ {
pimpl_->mac_.SetKey(secret, len); pimpl_->mac_.SetKey(secret, len);
} }
...@@ -379,7 +379,7 @@ struct DES::DESImpl { ...@@ -379,7 +379,7 @@ struct DES::DESImpl {
}; };
DES::DES() : pimpl_(new (ys) DESImpl) {} DES::DES() : pimpl_(NEW_YS DESImpl) {}
DES::~DES() { ysDelete(pimpl_); } DES::~DES() { ysDelete(pimpl_); }
...@@ -415,7 +415,7 @@ struct DES_EDE::DES_EDEImpl { ...@@ -415,7 +415,7 @@ struct DES_EDE::DES_EDEImpl {
}; };
DES_EDE::DES_EDE() : pimpl_(new (ys) DES_EDEImpl) {} DES_EDE::DES_EDE() : pimpl_(NEW_YS DES_EDEImpl) {}
DES_EDE::~DES_EDE() { ysDelete(pimpl_); } DES_EDE::~DES_EDE() { ysDelete(pimpl_); }
...@@ -453,7 +453,7 @@ struct RC4::RC4Impl { ...@@ -453,7 +453,7 @@ struct RC4::RC4Impl {
}; };
RC4::RC4() : pimpl_(new (ys) RC4Impl) {} RC4::RC4() : pimpl_(NEW_YS RC4Impl) {}
RC4::~RC4() { ysDelete(pimpl_); } RC4::~RC4() { ysDelete(pimpl_); }
...@@ -495,7 +495,7 @@ struct AES::AESImpl { ...@@ -495,7 +495,7 @@ struct AES::AESImpl {
}; };
AES::AES(unsigned int ks) : pimpl_(new (ys) AESImpl(ks)) {} AES::AES(unsigned int ks) : pimpl_(NEW_YS AESImpl(ks)) {}
AES::~AES() { ysDelete(pimpl_); } AES::~AES() { ysDelete(pimpl_); }
...@@ -536,7 +536,7 @@ struct RandomPool::RandomImpl { ...@@ -536,7 +536,7 @@ struct RandomPool::RandomImpl {
TaoCrypt::RandomNumberGenerator RNG_; TaoCrypt::RandomNumberGenerator RNG_;
}; };
RandomPool::RandomPool() : pimpl_(new (ys) RandomImpl) {} RandomPool::RandomPool() : pimpl_(NEW_YS RandomImpl) {}
RandomPool::~RandomPool() { ysDelete(pimpl_); } RandomPool::~RandomPool() { ysDelete(pimpl_); }
...@@ -580,7 +580,7 @@ void DSS::DSSImpl::SetPrivate(const byte* key, unsigned int sz) ...@@ -580,7 +580,7 @@ void DSS::DSSImpl::SetPrivate(const byte* key, unsigned int sz)
// Set public or private key // Set public or private key
DSS::DSS(const byte* key, unsigned int sz, bool publicKey) DSS::DSS(const byte* key, unsigned int sz, bool publicKey)
: pimpl_(new (ys) DSSImpl) : pimpl_(NEW_YS DSSImpl)
{ {
if (publicKey) if (publicKey)
pimpl_->SetPublic(key, sz); pimpl_->SetPublic(key, sz);
...@@ -651,7 +651,7 @@ void RSA::RSAImpl::SetPrivate(const byte* key, unsigned int sz) ...@@ -651,7 +651,7 @@ void RSA::RSAImpl::SetPrivate(const byte* key, unsigned int sz)
// Set public or private key // Set public or private key
RSA::RSA(const byte* key, unsigned int sz, bool publicKey) RSA::RSA(const byte* key, unsigned int sz, bool publicKey)
: pimpl_(new (ys) RSAImpl) : pimpl_(NEW_YS RSAImpl)
{ {
if (publicKey) if (publicKey)
pimpl_->SetPublic(key, sz); pimpl_->SetPublic(key, sz);
...@@ -723,13 +723,13 @@ struct Integer::IntegerImpl { ...@@ -723,13 +723,13 @@ struct Integer::IntegerImpl {
explicit IntegerImpl(const TaoCrypt::Integer& i) : int_(i) {} explicit IntegerImpl(const TaoCrypt::Integer& i) : int_(i) {}
}; };
Integer::Integer() : pimpl_(new (ys) IntegerImpl) {} Integer::Integer() : pimpl_(NEW_YS IntegerImpl) {}
Integer::~Integer() { ysDelete(pimpl_); } Integer::~Integer() { ysDelete(pimpl_); }
Integer::Integer(const Integer& other) : pimpl_(new (ys) Integer::Integer(const Integer& other) : pimpl_(NEW_YS
IntegerImpl(other.pimpl_->int_)) IntegerImpl(other.pimpl_->int_))
{} {}
...@@ -773,9 +773,9 @@ struct DiffieHellman::DHImpl { ...@@ -773,9 +773,9 @@ struct DiffieHellman::DHImpl {
void AllocKeys(unsigned int pubSz, unsigned int privSz, unsigned int agrSz) void AllocKeys(unsigned int pubSz, unsigned int privSz, unsigned int agrSz)
{ {
publicKey_ = new (ys) byte[pubSz]; publicKey_ = NEW_YS byte[pubSz];
privateKey_ = new (ys) byte[privSz]; privateKey_ = NEW_YS byte[privSz];
agreedKey_ = new (ys) byte[agrSz]; agreedKey_ = NEW_YS byte[agrSz];
} }
}; };
...@@ -784,7 +784,7 @@ struct DiffieHellman::DHImpl { ...@@ -784,7 +784,7 @@ struct DiffieHellman::DHImpl {
/* /*
// server Side DH, server's view // server Side DH, server's view
DiffieHellman::DiffieHellman(const char* file, const RandomPool& random) DiffieHellman::DiffieHellman(const char* file, const RandomPool& random)
: pimpl_(new (ys) DHImpl(random.pimpl_->RNG_)) : pimpl_(NEW_YS DHImpl(random.pimpl_->RNG_))
{ {
using namespace TaoCrypt; using namespace TaoCrypt;
Source source; Source source;
...@@ -808,12 +808,12 @@ DiffieHellman::DiffieHellman(const char* file, const RandomPool& random) ...@@ -808,12 +808,12 @@ DiffieHellman::DiffieHellman(const char* file, const RandomPool& random)
DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g, DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g,
unsigned int gSz, const byte* pub, unsigned int gSz, const byte* pub,
unsigned int pubSz, const RandomPool& random) unsigned int pubSz, const RandomPool& random)
: pimpl_(new (ys) DHImpl(random.pimpl_->RNG_)) : pimpl_(NEW_YS DHImpl(random.pimpl_->RNG_))
{ {
using TaoCrypt::Integer; using TaoCrypt::Integer;
pimpl_->dh_.Initialize(Integer(p, pSz).Ref(), Integer(g, gSz).Ref()); pimpl_->dh_.Initialize(Integer(p, pSz).Ref(), Integer(g, gSz).Ref());
pimpl_->publicKey_ = new (ys) opaque[pubSz]; pimpl_->publicKey_ = NEW_YS opaque[pubSz];
memcpy(pimpl_->publicKey_, pub, pubSz); memcpy(pimpl_->publicKey_, pub, pubSz);
} }
...@@ -821,7 +821,7 @@ DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g, ...@@ -821,7 +821,7 @@ DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g,
// Server Side DH, server's view // Server Side DH, server's view
DiffieHellman::DiffieHellman(const Integer& p, const Integer& g, DiffieHellman::DiffieHellman(const Integer& p, const Integer& g,
const RandomPool& random) const RandomPool& random)
: pimpl_(new (ys) DHImpl(random.pimpl_->RNG_)) : pimpl_(NEW_YS DHImpl(random.pimpl_->RNG_))
{ {
using TaoCrypt::Integer; using TaoCrypt::Integer;
...@@ -839,7 +839,7 @@ DiffieHellman::~DiffieHellman() { ysDelete(pimpl_); } ...@@ -839,7 +839,7 @@ DiffieHellman::~DiffieHellman() { ysDelete(pimpl_); }
// Client side and view, use server that for p and g // Client side and view, use server that for p and g
DiffieHellman::DiffieHellman(const DiffieHellman& that) DiffieHellman::DiffieHellman(const DiffieHellman& that)
: pimpl_(new (ys) DHImpl(*that.pimpl_)) : pimpl_(NEW_YS DHImpl(*that.pimpl_))
{ {
pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_, pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,
pimpl_->publicKey_); pimpl_->publicKey_);
...@@ -855,9 +855,9 @@ DiffieHellman& DiffieHellman::operator=(const DiffieHellman& that) ...@@ -855,9 +855,9 @@ DiffieHellman& DiffieHellman::operator=(const DiffieHellman& that)
} }
void DiffieHellman::makeAgreement(const byte* other) void DiffieHellman::makeAgreement(const byte* other, unsigned int otherSz)
{ {
pimpl_->dh_.Agree(pimpl_->agreedKey_, pimpl_->privateKey_, other); pimpl_->dh_.Agree(pimpl_->agreedKey_, pimpl_->privateKey_, other, otherSz);
} }
...@@ -960,7 +960,7 @@ x509* PemToDer(const char* fname, CertType type) ...@@ -960,7 +960,7 @@ x509* PemToDer(const char* fname, CertType type)
Base64Decoder b64Dec(der); Base64Decoder b64Dec(der);
uint sz = der.size(); uint sz = der.size();
mySTL::auto_ptr<x509> x(new (ys) x509(sz), ysDelete); mySTL::auto_ptr<x509> x(NEW_YS x509(sz), ysDelete);
memcpy(x->use_buffer(), der.get_buffer(), sz); memcpy(x->use_buffer(), der.get_buffer(), sz);
fclose(file); fclose(file);
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
* the various handshake messages. * the various handshake messages.
*/ */
#include "runtime.hpp" #include "runtime.hpp"
#include "handshake.hpp" #include "handshake.hpp"
#include "yassl_int.hpp" #include "yassl_int.hpp"
...@@ -362,9 +364,9 @@ void p_hash(output_buffer& result, const output_buffer& secret, ...@@ -362,9 +364,9 @@ void p_hash(output_buffer& result, const output_buffer& secret,
if (lastLen) times += 1; if (lastLen) times += 1;
if (hash == md5) if (hash == md5)
hmac.reset(new (ys) HMAC_MD5(secret.get_buffer(), secret.get_size())); hmac.reset(NEW_YS HMAC_MD5(secret.get_buffer(), secret.get_size()));
else else
hmac.reset(new (ys) HMAC_SHA(secret.get_buffer(), secret.get_size())); hmac.reset(NEW_YS HMAC_SHA(secret.get_buffer(), secret.get_size()));
// A0 = seed // A0 = seed
hmac->get_digest(previous, seed.get_buffer(), seed.get_size());// A1 hmac->get_digest(previous, seed.get_buffer(), seed.get_size());// A1
uint lastTime = times - 1; uint lastTime = times - 1;
...@@ -582,11 +584,11 @@ void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz, ...@@ -582,11 +584,11 @@ void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz,
MACAlgorithm algo = ssl.getSecurity().get_parms().mac_algorithm_; MACAlgorithm algo = ssl.getSecurity().get_parms().mac_algorithm_;
if (algo == sha) if (algo == sha)
hmac.reset(new (ys) HMAC_SHA(ssl.get_macSecret(verify), SHA_LEN)); hmac.reset(NEW_YS HMAC_SHA(ssl.get_macSecret(verify), SHA_LEN));
else if (algo == rmd) else if (algo == rmd)
hmac.reset(new (ys) HMAC_RMD(ssl.get_macSecret(verify), RMD_LEN)); hmac.reset(NEW_YS HMAC_RMD(ssl.get_macSecret(verify), RMD_LEN));
else else
hmac.reset(new (ys) HMAC_MD5(ssl.get_macSecret(verify), MD5_LEN)); hmac.reset(NEW_YS HMAC_MD5(ssl.get_macSecret(verify), MD5_LEN));
hmac->update(seq, SEQ_SZ); // seq_num hmac->update(seq, SEQ_SZ); // seq_num
inner[0] = content; // type inner[0] = content; // type
...@@ -603,7 +605,7 @@ void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz, ...@@ -603,7 +605,7 @@ void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz,
void PRF(byte* digest, uint digLen, const byte* secret, uint secLen, void PRF(byte* digest, uint digLen, const byte* secret, uint secLen,
const byte* label, uint labLen, const byte* seed, uint seedLen) const byte* label, uint labLen, const byte* seed, uint seedLen)
{ {
uint half = secLen / 2 + secLen % 2; uint half = (secLen + 1) / 2;
output_buffer md5_half(half); output_buffer md5_half(half);
output_buffer sha_half(half); output_buffer sha_half(half);
...@@ -648,18 +650,19 @@ void build_certHashes(SSL& ssl, Hashes& hashes) ...@@ -648,18 +650,19 @@ void build_certHashes(SSL& ssl, Hashes& hashes)
} }
// do process input requests // do process input requests
mySTL::auto_ptr<input_buffer> mySTL::auto_ptr<input_buffer>
DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered) DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered)
{ {
ssl.getSocket().wait(); // wait for input if blocking // wait for input if blocking
uint ready = ssl.getSocket().get_ready(); if (!ssl.getSocket().wait()) {
if (!ready) {
// Nothing to receive after blocking wait => error
ssl.SetError(receive_error); ssl.SetError(receive_error);
buffered.reset(0); buffered.reset(0);
return buffered; return buffered;
} }
uint ready = ssl.getSocket().get_ready();
if (!ready) return buffered;
// add buffered data if its there // add buffered data if its there
uint buffSz = buffered.get() ? buffered.get()->get_size() : 0; uint buffSz = buffered.get() ? buffered.get()->get_size() : 0;
...@@ -690,7 +693,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered) ...@@ -690,7 +693,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr<input_buffer> buffered)
// make sure we have enough input in buffer to process this record // make sure we have enough input in buffer to process this record
if (hdr.length_ > buffer.get_remaining()) { if (hdr.length_ > buffer.get_remaining()) {
uint sz = buffer.get_remaining() + RECORD_HEADER; uint sz = buffer.get_remaining() + RECORD_HEADER;
buffered.reset(new (ys) input_buffer(sz, buffer.get_buffer() + buffered.reset(NEW_YS input_buffer(sz, buffer.get_buffer() +
buffer.get_current() - RECORD_HEADER, sz)); buffer.get_current() - RECORD_HEADER, sz));
break; break;
} }
...@@ -730,6 +733,7 @@ void processReply(SSL& ssl) ...@@ -730,6 +733,7 @@ void processReply(SSL& ssl)
buffered = tmp; buffered = tmp;
else else
break; break;
if (ssl.GetError()) return;
} }
} }
...@@ -767,7 +771,7 @@ void sendClientKeyExchange(SSL& ssl, BufferOutput buffer) ...@@ -767,7 +771,7 @@ void sendClientKeyExchange(SSL& ssl, BufferOutput buffer)
RecordLayerHeader rlHeader; RecordLayerHeader rlHeader;
HandShakeHeader hsHeader; HandShakeHeader hsHeader;
mySTL::auto_ptr<output_buffer> out(new (ys) output_buffer, ysDelete); mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer, ysDelete);
buildHeaders(ssl, hsHeader, rlHeader, ck); buildHeaders(ssl, hsHeader, rlHeader, ck);
buildOutput(*out.get(), rlHeader, hsHeader, ck); buildOutput(*out.get(), rlHeader, hsHeader, ck);
hashHandShake(ssl, *out.get()); hashHandShake(ssl, *out.get());
...@@ -788,7 +792,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer) ...@@ -788,7 +792,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer)
RecordLayerHeader rlHeader; RecordLayerHeader rlHeader;
HandShakeHeader hsHeader; HandShakeHeader hsHeader;
mySTL::auto_ptr<output_buffer> out(new (ys) output_buffer, ysDelete); mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer, ysDelete);
buildHeaders(ssl, hsHeader, rlHeader, sk); buildHeaders(ssl, hsHeader, rlHeader, sk);
buildOutput(*out.get(), rlHeader, hsHeader, sk); buildOutput(*out.get(), rlHeader, hsHeader, sk);
hashHandShake(ssl, *out.get()); hashHandShake(ssl, *out.get());
...@@ -813,7 +817,7 @@ void sendChangeCipher(SSL& ssl, BufferOutput buffer) ...@@ -813,7 +817,7 @@ void sendChangeCipher(SSL& ssl, BufferOutput buffer)
ChangeCipherSpec ccs; ChangeCipherSpec ccs;
RecordLayerHeader rlHeader; RecordLayerHeader rlHeader;
buildHeader(ssl, rlHeader, ccs); buildHeader(ssl, rlHeader, ccs);
mySTL::auto_ptr<output_buffer> out(new (ys) output_buffer, ysDelete); mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer, ysDelete);
buildOutput(*out.get(), rlHeader, ccs); buildOutput(*out.get(), rlHeader, ccs);
if (buffer == buffered) if (buffer == buffered)
...@@ -830,7 +834,7 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer) ...@@ -830,7 +834,7 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer)
Finished fin; Finished fin;
buildFinished(ssl, fin, side == client_end ? client : server); buildFinished(ssl, fin, side == client_end ? client : server);
mySTL::auto_ptr<output_buffer> out(new (ys) output_buffer, ysDelete); mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer, ysDelete);
cipherFinished(ssl, fin, *out.get()); // hashes handshake cipherFinished(ssl, fin, *out.get()); // hashes handshake
if (ssl.getSecurity().get_resuming()) { if (ssl.getSecurity().get_resuming()) {
...@@ -914,7 +918,7 @@ void sendServerHello(SSL& ssl, BufferOutput buffer) ...@@ -914,7 +918,7 @@ void sendServerHello(SSL& ssl, BufferOutput buffer)
ServerHello sh(ssl.getSecurity().get_connection().version_); ServerHello sh(ssl.getSecurity().get_connection().version_);
RecordLayerHeader rlHeader; RecordLayerHeader rlHeader;
HandShakeHeader hsHeader; HandShakeHeader hsHeader;
mySTL::auto_ptr<output_buffer> out(new (ys) output_buffer, ysDelete); mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer, ysDelete);
buildServerHello(ssl, sh); buildServerHello(ssl, sh);
ssl.set_random(sh.get_random(), server_end); ssl.set_random(sh.get_random(), server_end);
...@@ -937,7 +941,7 @@ void sendServerHelloDone(SSL& ssl, BufferOutput buffer) ...@@ -937,7 +941,7 @@ void sendServerHelloDone(SSL& ssl, BufferOutput buffer)
ServerHelloDone shd; ServerHelloDone shd;
RecordLayerHeader rlHeader; RecordLayerHeader rlHeader;
HandShakeHeader hsHeader; HandShakeHeader hsHeader;
mySTL::auto_ptr<output_buffer> out(new (ys) output_buffer, ysDelete); mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer, ysDelete);
buildHeaders(ssl, hsHeader, rlHeader, shd); buildHeaders(ssl, hsHeader, rlHeader, shd);
buildOutput(*out.get(), rlHeader, hsHeader, shd); buildOutput(*out.get(), rlHeader, hsHeader, shd);
...@@ -958,7 +962,7 @@ void sendCertificate(SSL& ssl, BufferOutput buffer) ...@@ -958,7 +962,7 @@ void sendCertificate(SSL& ssl, BufferOutput buffer)
Certificate cert(ssl.getCrypto().get_certManager().get_cert()); Certificate cert(ssl.getCrypto().get_certManager().get_cert());
RecordLayerHeader rlHeader; RecordLayerHeader rlHeader;
HandShakeHeader hsHeader; HandShakeHeader hsHeader;
mySTL::auto_ptr<output_buffer> out(new (ys) output_buffer, ysDelete); mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer, ysDelete);
buildHeaders(ssl, hsHeader, rlHeader, cert); buildHeaders(ssl, hsHeader, rlHeader, cert);
buildOutput(*out.get(), rlHeader, hsHeader, cert); buildOutput(*out.get(), rlHeader, hsHeader, cert);
...@@ -980,7 +984,7 @@ void sendCertificateRequest(SSL& ssl, BufferOutput buffer) ...@@ -980,7 +984,7 @@ void sendCertificateRequest(SSL& ssl, BufferOutput buffer)
request.Build(); request.Build();
RecordLayerHeader rlHeader; RecordLayerHeader rlHeader;
HandShakeHeader hsHeader; HandShakeHeader hsHeader;
mySTL::auto_ptr<output_buffer> out(new (ys) output_buffer, ysDelete); mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer, ysDelete);
buildHeaders(ssl, hsHeader, rlHeader, request); buildHeaders(ssl, hsHeader, rlHeader, request);
buildOutput(*out.get(), rlHeader, hsHeader, request); buildOutput(*out.get(), rlHeader, hsHeader, request);
...@@ -1002,7 +1006,7 @@ void sendCertificateVerify(SSL& ssl, BufferOutput buffer) ...@@ -1002,7 +1006,7 @@ void sendCertificateVerify(SSL& ssl, BufferOutput buffer)
verify.Build(ssl); verify.Build(ssl);
RecordLayerHeader rlHeader; RecordLayerHeader rlHeader;
HandShakeHeader hsHeader; HandShakeHeader hsHeader;
mySTL::auto_ptr<output_buffer> out(new (ys) output_buffer, ysDelete); mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer, ysDelete);
buildHeaders(ssl, hsHeader, rlHeader, verify); buildHeaders(ssl, hsHeader, rlHeader, verify);
buildOutput(*out.get(), rlHeader, hsHeader, verify); buildOutput(*out.get(), rlHeader, hsHeader, verify);
......
# quick and dirty build file for testing different MSDEVs
setlocal
set myFLAGS= /I../include /I../mySTL /I../taocrypt/include /W3 /c /ZI
cl %myFLAGS% buffer.cpp
cl %myFLAGS% cert_wrapper.cpp
cl %myFLAGS% crypto_wrapper.cpp
cl %myFLAGS% handshake.cpp
cl %myFLAGS% lock.cpp
cl %myFLAGS% log.cpp
cl %myFLAGS% socket_wrapper.cpp
cl %myFLAGS% ssl.cpp
cl %myFLAGS% template_instnt.cpp
cl %myFLAGS% timer.cpp
cl %myFLAGS% yassl.cpp
cl %myFLAGS% yassl_error.cpp
cl %myFLAGS% yassl_imp.cpp
cl %myFLAGS% yassl_int.cpp
link.exe -lib /out:yassl.lib buffer.obj cert_wrapper.obj crypto_wrapper.obj handshake.obj lock.obj log.obj socket_wrapper.obj ssl.obj template_instnt.obj timer.obj yassl.obj yassl_error.obj yassl_imp.obj yassl_int.obj
...@@ -46,9 +46,11 @@ ...@@ -46,9 +46,11 @@
#ifdef _WIN32 #ifdef _WIN32
const int SOCKET_EINVAL = WSAEINVAL; const int SOCKET_EINVAL = WSAEINVAL;
const int SOCKET_EWOULDBLOCK = WSAEWOULDBLOCK; const int SOCKET_EWOULDBLOCK = WSAEWOULDBLOCK;
const int SOCKET_EAGAIN = WSAEWOULDBLOCK;
#else #else
const int SOCKET_EINVAL = EINVAL; const int SOCKET_EINVAL = EINVAL;
const int SOCKET_EWOULDBLOCK = EWOULDBLOCK; const int SOCKET_EWOULDBLOCK = EWOULDBLOCK;
const int SOCKET_EAGAIN = EAGAIN;
#endif // _WIN32 #endif // _WIN32
...@@ -98,10 +100,10 @@ uint Socket::get_ready() const ...@@ -98,10 +100,10 @@ uint Socket::get_ready() const
ioctlsocket(socket_, FIONREAD, &ready); ioctlsocket(socket_, FIONREAD, &ready);
#else #else
/* /*
64-bit Solaris requires the variable passed to 64-bit Solaris requires the variable passed to
FIONREAD be a 32-bit value. FIONREAD be a 32-bit value.
*/ */
int ready = 0; unsigned int ready = 0;
ioctl(socket_, FIONREAD, &ready); ioctl(socket_, FIONREAD, &ready);
#endif #endif
...@@ -126,18 +128,24 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags) const ...@@ -126,18 +128,24 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags) const
assert(socket_ != INVALID_SOCKET); assert(socket_ != INVALID_SOCKET);
int recvd = ::recv(socket_, reinterpret_cast<char *>(buf), sz, flags); int recvd = ::recv(socket_, reinterpret_cast<char *>(buf), sz, flags);
if (recvd == -1) // idea to seperate error from would block by arnetheduck@gmail.com
if (recvd == -1) {
if (get_lastError() == SOCKET_EWOULDBLOCK ||
get_lastError() == SOCKET_EAGAIN)
return 0; return 0;
}
else if (recvd == 0)
return static_cast<uint>(-1);
return recvd; return recvd;
} }
// wait if blocking for input, or error // wait if blocking for input, return false for error
void Socket::wait() const bool Socket::wait() const
{ {
byte b; byte b;
receive(&b, 1, MSG_PEEK); return receive(&b, 1, MSG_PEEK) != static_cast<uint>(-1);
} }
......
...@@ -38,6 +38,14 @@ ...@@ -38,6 +38,14 @@
#include "yassl_int.hpp" #include "yassl_int.hpp"
#include <stdio.h> #include <stdio.h>
#ifdef _WIN32
#include <windows.h> // FindFirstFile etc..
#else
#include <sys/types.h> // file helper
#include <sys/stat.h> // stat
#include <dirent.h> // opendir
#endif
namespace yaSSL { namespace yaSSL {
...@@ -52,25 +60,25 @@ SSL_METHOD* SSLv3_method() ...@@ -52,25 +60,25 @@ SSL_METHOD* SSLv3_method()
SSL_METHOD* SSLv3_server_method() SSL_METHOD* SSLv3_server_method()
{ {
return new (ys) SSL_METHOD(server_end, ProtocolVersion(3,0)); return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,0));
} }
SSL_METHOD* SSLv3_client_method() SSL_METHOD* SSLv3_client_method()
{ {
return new (ys) SSL_METHOD(client_end, ProtocolVersion(3,0)); return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,0));
} }
SSL_METHOD* TLSv1_server_method() SSL_METHOD* TLSv1_server_method()
{ {
return new (ys) SSL_METHOD(server_end, ProtocolVersion(3,1)); return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,1));
} }
SSL_METHOD* TLSv1_client_method() SSL_METHOD* TLSv1_client_method()
{ {
return new (ys) SSL_METHOD(client_end, ProtocolVersion(3,1)); return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,1));
} }
...@@ -83,7 +91,7 @@ SSL_METHOD* SSLv23_server_method() ...@@ -83,7 +91,7 @@ SSL_METHOD* SSLv23_server_method()
SSL_CTX* SSL_CTX_new(SSL_METHOD* method) SSL_CTX* SSL_CTX_new(SSL_METHOD* method)
{ {
return new (ys) SSL_CTX(method); return NEW_YS SSL_CTX(method);
} }
...@@ -95,7 +103,7 @@ void SSL_CTX_free(SSL_CTX* ctx) ...@@ -95,7 +103,7 @@ void SSL_CTX_free(SSL_CTX* ctx)
SSL* SSL_new(SSL_CTX* ctx) SSL* SSL_new(SSL_CTX* ctx)
{ {
return new (ys) SSL(ctx); return NEW_YS SSL(ctx);
} }
...@@ -115,7 +123,12 @@ int SSL_set_fd(SSL* ssl, int fd) ...@@ -115,7 +123,12 @@ int SSL_set_fd(SSL* ssl, int fd)
int SSL_connect(SSL* ssl) int SSL_connect(SSL* ssl)
{ {
sendClientHello(*ssl); sendClientHello(*ssl);
ClientState neededState = ssl->getSecurity().get_resuming() ?
serverFinishedComplete : serverHelloDoneComplete;
while (ssl->getStates().getClient() < neededState) {
if (ssl->GetError()) break;
processReply(*ssl); processReply(*ssl);
}
if(ssl->getCrypto().get_certManager().sendVerify()) if(ssl->getCrypto().get_certManager().sendVerify())
sendCertificate(*ssl); sendCertificate(*ssl);
...@@ -130,7 +143,10 @@ int SSL_connect(SSL* ssl) ...@@ -130,7 +143,10 @@ int SSL_connect(SSL* ssl)
sendFinished(*ssl, client_end); sendFinished(*ssl, client_end);
ssl->flushBuffer(); ssl->flushBuffer();
if (!ssl->getSecurity().get_resuming()) if (!ssl->getSecurity().get_resuming())
while (ssl->getStates().getClient() < serverFinishedComplete) {
if (ssl->GetError()) break;
processReply(*ssl); processReply(*ssl);
}
ssl->verifyState(serverFinishedComplete); ssl->verifyState(serverFinishedComplete);
ssl->useLog().ShowTCP(ssl->getSocket().get_fd()); ssl->useLog().ShowTCP(ssl->getSocket().get_fd());
...@@ -171,9 +187,7 @@ int SSL_accept(SSL* ssl) ...@@ -171,9 +187,7 @@ int SSL_accept(SSL* ssl)
sendServerHelloDone(*ssl); sendServerHelloDone(*ssl);
ssl->flushBuffer(); ssl->flushBuffer();
// Java Client sends fragmented response while (ssl->getStates().getServer() < clientFinishedComplete) {
while (ssl->getStates().getServer() <
clientFinishedComplete) {
if (ssl->GetError()) break; if (ssl->GetError()) break;
processReply(*ssl); processReply(*ssl);
} }
...@@ -182,10 +196,7 @@ int SSL_accept(SSL* ssl) ...@@ -182,10 +196,7 @@ int SSL_accept(SSL* ssl)
sendFinished(*ssl, server_end); sendFinished(*ssl, server_end);
ssl->flushBuffer(); ssl->flushBuffer();
if (ssl->getSecurity().get_resuming()) { if (ssl->getSecurity().get_resuming()) {
while (ssl->getStates().getServer() < clientFinishedComplete) {
// Java Client sends fragmented response
while (ssl->getStates().getServer() <
clientFinishedComplete) {
if (ssl->GetError()) break; if (ssl->GetError()) break;
processReply(*ssl); processReply(*ssl);
} }
...@@ -281,9 +292,15 @@ char* SSL_get_shared_ciphers(SSL* /*ssl*/, char* buf, int len) ...@@ -281,9 +292,15 @@ char* SSL_get_shared_ciphers(SSL* /*ssl*/, char* buf, int len)
} }
const char* SSL_get_cipher_list(SSL* ssl, int /*priority */) const char* SSL_get_cipher_list(SSL* ssl, int priority)
{ {
return ssl->getSecurity().get_parms().cipher_list_; if (priority < 0 || priority >= MAX_CIPHERS)
return 0;
if (ssl->getSecurity().get_parms().cipher_list_[priority][0])
return ssl->getSecurity().get_parms().cipher_list_[priority];
return 0;
} }
...@@ -455,7 +472,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) ...@@ -455,7 +472,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type)
fseek(input, 0, SEEK_END); fseek(input, 0, SEEK_END);
long sz = ftell(input); long sz = ftell(input);
rewind(input); rewind(input);
x = new (ys) x509(sz); // takes ownership x = NEW_YS x509(sz); // takes ownership
size_t bytes = fread(x->use_buffer(), sz, 1, input); size_t bytes = fread(x->use_buffer(), sz, 1, input);
if (bytes != 1) { if (bytes != 1) {
fclose(input); fclose(input);
...@@ -492,16 +509,74 @@ void SSL_CTX_set_verify(SSL_CTX* ctx, int mode, VerifyCallback /*vc*/) ...@@ -492,16 +509,74 @@ void SSL_CTX_set_verify(SSL_CTX* ctx, int mode, VerifyCallback /*vc*/)
if (mode & SSL_VERIFY_PEER) if (mode & SSL_VERIFY_PEER)
ctx->setVerifyPeer(); ctx->setVerifyPeer();
if (mode == SSL_VERIFY_NONE)
ctx->setVerifyNone();
if (mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) if (mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
ctx->setFailNoCert(); ctx->setFailNoCert();
} }
int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file, int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file,
const char* /*path*/) const char* path)
{ {
// just files for now int ret = SSL_SUCCESS;
return read_file(ctx, file, SSL_FILETYPE_PEM, CA); const int HALF_PATH = 128;
if (file) ret = read_file(ctx, file, SSL_FILETYPE_PEM, CA);
if (ret == SSL_SUCCESS && path) {
// call read_file for each reqular file in path
#ifdef _WIN32
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
char name[MAX_PATH + 1]; // directory specification
strncpy(name, path, MAX_PATH - 3);
strncat(name, "\\*", 3);
hFind = FindFirstFile(name, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) return SSL_BAD_PATH;
do {
if (FindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) {
strncpy(name, path, MAX_PATH - 2 - HALF_PATH);
strncat(name, "\\", 2);
strncat(name, FindFileData.cFileName, HALF_PATH);
ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);
}
} while (ret == SSL_SUCCESS && FindNextFile(hFind, &FindFileData));
FindClose(hFind);
#else // _WIN32
const int MAX_PATH = 260;
DIR* dir = opendir(path);
if (!dir) return SSL_BAD_PATH;
struct dirent* entry;
struct stat buf;
char name[MAX_PATH + 1];
while (ret == SSL_SUCCESS && (entry = readdir(dir))) {
strncpy(name, path, MAX_PATH - 1 - HALF_PATH);
strncat(name, "/", 1);
strncat(name, entry->d_name, HALF_PATH);
if (stat(name, &buf) < 0) return SSL_BAD_STAT;
if (S_ISREG(buf.st_mode))
ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);
}
closedir(dir);
#endif
}
return ret;
} }
...@@ -648,13 +723,13 @@ void OpenSSL_add_all_algorithms() // compatibility only ...@@ -648,13 +723,13 @@ void OpenSSL_add_all_algorithms() // compatibility only
{} {}
void SSL_library_init() // compatibility only void SSL_library_init() // compatiblity only
{} {}
DH* DH_new(void) DH* DH_new(void)
{ {
DH* dh = new (ys) DH; DH* dh = NEW_YS DH;
if (dh) if (dh)
dh->p = dh->g = 0; dh->p = dh->g = 0;
return dh; return dh;
...@@ -679,7 +754,7 @@ BIGNUM* BN_bin2bn(const unsigned char* num, int sz, BIGNUM* retVal) ...@@ -679,7 +754,7 @@ BIGNUM* BN_bin2bn(const unsigned char* num, int sz, BIGNUM* retVal)
if (!retVal) { if (!retVal) {
created = true; created = true;
bn.reset(new (ys) BIGNUM); bn.reset(NEW_YS BIGNUM);
retVal = bn.get(); retVal = bn.get();
} }
...@@ -706,12 +781,14 @@ void ERR_print_errors_fp(FILE* /*fp*/) ...@@ -706,12 +781,14 @@ void ERR_print_errors_fp(FILE* /*fp*/)
} }
char* ERR_error_string(unsigned long /*err*/, char* buffer) char* ERR_error_string(unsigned long errNumber, char* buffer)
{ {
// TODO: static char* msg = "Please supply a buffer for error string";
static char* msg = "Not Implemented";
if (buffer) if (buffer) {
return strncpy(buffer, msg, strlen(msg)); SetErrorString(YasslError(errNumber), buffer);
return buffer;
}
return msg; return msg;
} }
...@@ -728,14 +805,14 @@ const char* X509_verify_cert_error_string(long /* error */) ...@@ -728,14 +805,14 @@ const char* X509_verify_cert_error_string(long /* error */)
const EVP_MD* EVP_md5(void) const EVP_MD* EVP_md5(void)
{ {
// TODO: FIX add to some list for destruction // TODO: FIX add to some list for destruction
return new (ys) MD5; return NEW_YS MD5;
} }
const EVP_CIPHER* EVP_des_ede3_cbc(void) const EVP_CIPHER* EVP_des_ede3_cbc(void)
{ {
// TODO: FIX add to some list for destruction // TODO: FIX add to some list for destruction
return new (ys) DES_EDE; return NEW_YS DES_EDE;
} }
......
...@@ -35,13 +35,6 @@ ...@@ -35,13 +35,6 @@
#include "openssl/ssl.h" #include "openssl/ssl.h"
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
#if !defined(USE_CRYPTOPP_LIB)
namespace TaoCrypt {
template class HMAC<MD5>;
template class HMAC<SHA>;
template class HMAC<RIPEMD160>;
}
#endif // USE_CRYPTOPP_LIB
namespace mySTL { namespace mySTL {
template class list<unsigned char*>; template class list<unsigned char*>;
......
...@@ -26,17 +26,13 @@ ...@@ -26,17 +26,13 @@
#include "runtime.hpp" #include "runtime.hpp"
#include "timer.hpp" #include "timer.hpp"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <sys/time.h>
#endif
namespace yaSSL { namespace yaSSL {
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
timer_d timer() timer_d timer()
{ {
static bool init(false); static bool init(false);
...@@ -61,6 +57,8 @@ namespace yaSSL { ...@@ -61,6 +57,8 @@ namespace yaSSL {
#else // _WIN32 #else // _WIN32
#include <sys/time.h>
timer_d timer() timer_d timer()
{ {
struct timeval tv; struct timeval tv;
......
/* yassl.cpp
*
* Copyright (C) 2003 Sawtooth Consulting Ltd.
*
* This file is part of yaSSL.
*
* yaSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* yaSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/* yaSSL implements external API
*/
#include "runtime.hpp"
#include "yassl.hpp"
#include "yassl_int.hpp"
#include "handshake.hpp"
#include <stdio.h>
#include "openssl/ssl.h" // get rid of this
// yaSSL overloads hide these
void* operator new[](size_t sz)
{
return ::operator new(sz);
}
void operator delete[](void* ptr)
{
::operator delete(ptr);
}
namespace yaSSL {
using mySTL::min;
struct Base {
SSL_METHOD* method_;
SSL_CTX* ctx_;
SSL* ssl_;
char* ca_;
char* cert_;
char* key_;
DH* dh_;
Base() : method_(0), ctx_(0), ssl_(0), ca_(0), cert_(0), key_(0), dh_(0)
{}
~Base()
{
if (dh_) DH_free(dh_);
delete[] key_;
delete[] cert_;
delete[] ca_;
SSL_CTX_free(ctx_); // frees method_ too
SSL_free(ssl_);
}
};
void SetDH(Base&);
void SetUpBase(Base& base, ConnectionEnd end, SOCKET_T s)
{
base.method_ = new SSL_METHOD(end, ProtocolVersion(3,1));
base.ctx_ = new SSL_CTX(base.method_);
if (base.ca_)
if (SSL_CTX_load_verify_locations(base.ctx_,
base.ca_, 0) != SSL_SUCCESS) assert(0);
if (base.cert_)
if (SSL_CTX_use_certificate_file(base.ctx_,
base.cert_, SSL_FILETYPE_PEM) != SSL_SUCCESS) assert(0);
if (base.key_)
if (SSL_CTX_use_PrivateKey_file(base.ctx_, base.key_,
SSL_FILETYPE_PEM) != SSL_SUCCESS) assert(0);
if (end == server_end) SetDH(base);
base.ssl_ = new SSL(base.ctx_);
base.ssl_->useSocket().set_fd(s);
}
void SetDH(Base& base)
{
static unsigned char dh512_p[] =
{
0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75,
0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F,
0xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,0x57,0x46,0x50,0xD3,
0x69,0x99,0xDB,0x29,0xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12,
0xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,0xD8,0x00,0x3E,0x7C,
0x47,0x74,0xE8,0x33,
};
static unsigned char dh512_g[] =
{
0x02,
};
if ( (base.dh_ = DH_new()) ) {
base.dh_->p = BN_bin2bn(dh512_p, sizeof(dh512_p), 0);
base.dh_->g = BN_bin2bn(dh512_g, sizeof(dh512_g), 0);
}
if (!base.dh_->p || !base.dh_->g) {
DH_free(base.dh_);
base.dh_ = 0;
}
SSL_CTX_set_tmp_dh(base.ctx_, base.dh_);
}
void NewCopy(char*& dst, const char* src)
{
size_t len = strlen(src) + 1;
dst = new char[len];
strncpy(dst, src, len);
}
// Client Implementation
struct Client::ClientImpl {
Base base_;
};
Client::Client() : pimpl_(new ClientImpl)
{}
Client::~Client() { delete pimpl_; }
int Client::Connect(SOCKET_T s)
{
SetUpBase(pimpl_->base_, client_end, s);
return SSL_connect(pimpl_->base_.ssl_);
}
int Client::Write(const void* buffer, int sz)
{
return sendData(*pimpl_->base_.ssl_, buffer, sz);
}
int Client::Read(void* buffer, int sz)
{
Data data(min(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));
return receiveData(*pimpl_->base_.ssl_, data);
}
void Client::SetCA(const char* name)
{
NewCopy(pimpl_->base_.ca_, name);
}
void Client::SetCert(const char* name)
{
NewCopy(pimpl_->base_.cert_, name);
}
void Client::SetKey(const char* name)
{
NewCopy(pimpl_->base_.key_, name);
}
// Server Implementation
struct Server::ServerImpl {
Base base_;
};
Server::Server() : pimpl_(new ServerImpl)
{}
Server::~Server() { delete pimpl_; }
int Server::Accept(SOCKET_T s)
{
SetUpBase(pimpl_->base_, server_end, s);
return SSL_accept(pimpl_->base_.ssl_);
}
int Server::Write(const void* buffer, int sz)
{
return sendData(*pimpl_->base_.ssl_, buffer, sz);
}
int Server::Read(void* buffer, int sz)
{
Data data(min(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));
return receiveData(*pimpl_->base_.ssl_, data);
}
void Server::SetCA(const char* name)
{
NewCopy(pimpl_->base_.ca_, name);
}
void Server::SetCert(const char* name)
{
NewCopy(pimpl_->base_.cert_, name);
}
void Server::SetKey(const char* name)
{
NewCopy(pimpl_->base_.key_, name);
}
} // namespace yaSSL
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "runtime.hpp" #include "runtime.hpp"
#include "yassl_error.hpp" #include "yassl_error.hpp"
#include "error.hpp" // TaoCrypt error numbers
namespace yaSSL { namespace yaSSL {
...@@ -48,6 +49,184 @@ Library Error::get_lib() const ...@@ -48,6 +49,184 @@ Library Error::get_lib() const
} }
void SetErrorString(YasslError error, char* buffer)
{
using namespace TaoCrypt;
const int max = MAX_ERROR_SZ; // shorthand
switch (error) {
// yaSSL proper errors
case range_error :
strncpy(buffer, "buffer index error, out of range", max);
break;
case realloc_error :
strncpy(buffer, "trying to realloc a fixed buffer", max);
break;
case factory_error :
strncpy(buffer, "unknown factory create request", max);
break;
case unknown_cipher :
strncpy(buffer, "trying to use an unknown cipher", max);
break;
case prefix_error :
strncpy(buffer, "bad master secret derivation, prefix too big", max);
break;
case record_layer :
strncpy(buffer, "record layer not ready yet", max);
break;
case handshake_layer :
strncpy(buffer, "handshake layer not ready yet", max);
break;
case out_of_order :
strncpy(buffer, "handshake message received in wrong order", max);
break;
case bad_input :
strncpy(buffer, "bad cipher suite input", max);
break;
case match_error :
strncpy(buffer, "unable to match a supported cipher suite", max);
break;
case no_key_file :
strncpy(buffer, "the server needs a private key file", max);
break;
case verify_error :
strncpy(buffer, "unable to verify peer checksum", max);
break;
case send_error :
strncpy(buffer, "socket layer send error", max);
break;
case receive_error :
strncpy(buffer, "socket layer receive error", max);
break;
case certificate_error :
strncpy(buffer, "unable to proccess cerificate", max);
break;
// TaoCrypt errors
case NO_ERROR :
strncpy(buffer, "not in error state", max);
break;
case WINCRYPT_E :
strncpy(buffer, "bad wincrypt acquire", max);
break;
case CRYPTGEN_E :
strncpy(buffer, "CryptGenRandom error", max);
break;
case OPEN_RAN_E :
strncpy(buffer, "unable to use random device", max);
break;
case READ_RAN_E :
strncpy(buffer, "unable to use random device", max);
break;
case INTEGER_E :
strncpy(buffer, "ASN: bad DER Integer Header", max);
break;
case SEQUENCE_E :
strncpy(buffer, "ASN: bad Sequence Header", max);
break;
case SET_E :
strncpy(buffer, "ASN: bad Set Header", max);
break;
case VERSION_E :
strncpy(buffer, "ASN: version length not 1", max);
break;
case SIG_OID_E :
strncpy(buffer, "ASN: signature OID mismatch", max);
break;
case BIT_STR_E :
strncpy(buffer, "ASN: bad BitString Header", max);
break;
case UNKNOWN_OID_E :
strncpy(buffer, "ASN: unknown key OID type", max);
break;
case OBJECT_ID_E :
strncpy(buffer, "ASN: bad Ojbect ID Header", max);
break;
case TAG_NULL_E :
strncpy(buffer, "ASN: expected TAG NULL", max);
break;
case EXPECT_0_E :
strncpy(buffer, "ASN: expected 0", max);
break;
case OCTET_STR_E :
strncpy(buffer, "ASN: bad Octet String Header", max);
break;
case TIME_E :
strncpy(buffer, "ASN: bad TIME", max);
break;
case DATE_SZ_E :
strncpy(buffer, "ASN: bad Date Size", max);
break;
case SIG_LEN_E :
strncpy(buffer, "ASN: bad Signature Length", max);
break;
case UNKOWN_SIG_E :
strncpy(buffer, "ASN: unknown signature OID", max);
break;
case UNKOWN_HASH_E :
strncpy(buffer, "ASN: unknown hash OID", max);
break;
case DSA_SZ_E :
strncpy(buffer, "ASN: bad DSA r or s size", max);
break;
case BEFORE_DATE_E :
strncpy(buffer, "ASN: before date in the future", max);
break;
case AFTER_DATE_E :
strncpy(buffer, "ASN: after date in the past", max);
break;
case SIG_CONFIRM_E :
strncpy(buffer, "ASN: bad self signature confirmation", max);
break;
case SIG_OTHER_E :
strncpy(buffer, "ASN: bad other signature confirmation", max);
break;
default :
strncpy(buffer, "unknown error number", max);
}
}
} // namespace yaSSL } // namespace yaSSL
This diff is collapsed.
This diff is collapsed.
SUBDIRS = src SUBDIRS = src test benchmark
EXTRA_DIST = taocrypt.dsw taocrypt.dsp EXTRA_DIST = taocrypt.dsw taocrypt.dsp
INCLUDES = -I../include -I../../mySTL
bin_PROGRAMS = benchmark
benchmark_SOURCES = benchmark.cpp
benchmark_LDFLAGS = -L../src
benchmark_LDADD = -ltaocrypt
benchmark_CXXFLAGS = -DYASSL_PURE_C
benchmark_DEPENDENCIES = ../src/libtaocrypt.la
EXTRA_DIST = benchmark.dsp rsa1024.der dh1024.der dsa1024.der make.bat
This diff is collapsed.
# Microsoft Developer Studio Project File - Name="benchmark" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=benchmark - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "benchmark.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "benchmark.mak" CFG="benchmark - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "benchmark - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "benchmark - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "benchmark - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "benchmark___Win32_Release"
# PROP BASE Intermediate_Dir "benchmark___Win32_Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\include" /I "..\..\mySTL" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "benchmark - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "benchmark___Win32_Debug"
# PROP BASE Intermediate_Dir "benchmark___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "benchmark - Win32 Release"
# Name "benchmark - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\benchmark.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
# quick and dirty build file for testing different MSDEVs
setlocal
set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2
#set myFLAGS= /I../include /I../../mySTL /c /W3
cl %myFLAGS% benchmark.cpp
link.exe /out:benchmark.exe ../src/taocrypt.lib benchmark.obj
...@@ -26,13 +26,13 @@ ...@@ -26,13 +26,13 @@
#ifndef TAO_CRYPT_AES_HPP #ifndef TAO_CRYPT_AES_HPP
#define TAO_CRYPT_AES_HPP #define TAO_CRYPT_AES_HPP
#include <string.h>
#include "misc.hpp" #include "misc.hpp"
#include "modes.hpp" #include "modes.hpp"
#include "block.hpp"
namespace TaoCrypt { namespace TaoCrypt {
enum { AES_BLOCK_SIZE = 16 }; enum { AES_BLOCK_SIZE = 16 };
...@@ -45,32 +45,38 @@ public: ...@@ -45,32 +45,38 @@ public:
: Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {} : Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
void Process(byte*, const byte*, word32); void Process(byte*, const byte*, word32);
void SetKey(const byte* iv, word32 sz, CipherDir fake = ENCRYPTION); void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION);
void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
private: private:
CipherDir dir_; CipherDir dir_;
Mode mode_; Mode mode_;
static const word32 Te0[256];
static const word32 Te1[256];
static const word32 Te2[256];
static const word32 Te3[256];
static const word32 Te4[256];
static const word32 Td0[256];
static const word32 Td1[256];
static const word32 Td2[256];
static const word32 Td3[256];
static const word32 Td4[256];
static const word32 rcon_[]; static const word32 rcon_[];
word32 rounds_; word32 rounds_;
Word32Block key_; word32 key_[60]; // max size
static const word32 Te[5][256];
static const word32 Td[5][256];
static const word32* Te0;
static const word32* Te1;
static const word32* Te2;
static const word32* Te3;
static const word32* Te4;
static const word32* Td0;
static const word32* Td1;
static const word32* Td2;
static const word32* Td3;
static const word32* Td4;
void encrypt(const byte*, const byte*, byte*) const; void encrypt(const byte*, const byte*, byte*) const;
void AsmEncrypt(const byte*, byte*, void*) const;
void decrypt(const byte*, const byte*, byte*) const; void decrypt(const byte*, const byte*, byte*) const;
void AsmDecrypt(const byte*, byte*, void*) const;
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
AES(const AES&); // hide copy AES(const AES&); // hide copy
AES& operator=(const AES&); // and assign AES& operator=(const AES&); // and assign
......
...@@ -42,6 +42,7 @@ public: ...@@ -42,6 +42,7 @@ public:
ARC4() {} ARC4() {}
void Process(byte*, const byte*, word32); void Process(byte*, const byte*, word32);
void AsmProcess(byte*, const byte*, word32);
void SetKey(const byte*, word32); void SetKey(const byte*, word32);
private: private:
byte x_; byte x_;
......
...@@ -232,7 +232,12 @@ enum KeyType { DSAk = 515, RSAk = 645 }; // sums of algo OID ...@@ -232,7 +232,12 @@ enum KeyType { DSAk = 515, RSAk = 645 }; // sums of algo OID
// an x509v Certificate BER Decoder // an x509v Certificate BER Decoder
class CertDecoder : public BER_Decoder { class CertDecoder : public BER_Decoder {
public: public:
explicit CertDecoder(Source&, bool decode = true, SignerList* = 0); enum DateType { BEFORE, AFTER };
enum NameType { ISSUER, SUBJECT };
enum CertType { CA, USER };
explicit CertDecoder(Source&, bool decode = true, SignerList* sl = 0,
bool noVerify = false, CertType ct = USER);
~CertDecoder(); ~CertDecoder();
const PublicKey& GetPublicKey() const { return key_; } const PublicKey& GetPublicKey() const { return key_; }
...@@ -242,9 +247,6 @@ public: ...@@ -242,9 +247,6 @@ public:
const byte* GetHash() const { return subjectHash_; } const byte* GetHash() const { return subjectHash_; }
void DecodeToKey(); void DecodeToKey();
enum DateType { BEFORE, AFTER };
enum NameType { ISSUER, SUBJECT };
private: private:
PublicKey key_; PublicKey key_;
word32 certBegin_; // offset to start of cert word32 certBegin_; // offset to start of cert
...@@ -257,9 +259,10 @@ private: ...@@ -257,9 +259,10 @@ private:
byte* signature_; byte* signature_;
char* issuer_; // CommonName char* issuer_; // CommonName
char* subject_; // CommonName char* subject_; // CommonName
bool verify_; // Default to yes, but could be off
void ReadHeader(); void ReadHeader();
void Decode(SignerList*); void Decode(SignerList*, CertType);
void StoreKey(); void StoreKey();
void AddDSA(); void AddDSA();
bool ValidateSelfSignature(); bool ValidateSelfSignature();
......
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
CheckSize(n); CheckSize(n);
if (n == 0) if (n == 0)
return 0; return 0;
return new (tc) T[n]; return NEW_TC T[n];
} }
void deallocate(void* p, size_type n) void deallocate(void* p, size_type n)
......
/* blowfish.hpp
*
* Copyright (C) 2003 Sawtooth Consulting Ltd.
*
* This file is part of yaSSL.
*
* yaSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* yaSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/* blowfish.hpp defines Blowfish
*/
#ifndef TAO_CRYPT_BLOWFISH_HPP
#define TAO_CRYPT_BLOWFISH_HPP
#include "misc.hpp"
#include "modes.hpp"
#include "algorithm.hpp"
namespace TaoCrypt {
enum { BLOWFISH_BLOCK_SIZE = 8 };
// Blowfish encryption and decryption, see
class Blowfish : public Mode_BASE {
public:
enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 };
Blowfish(CipherDir DIR, Mode MODE)
: Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
void Process(byte*, const byte*, word32);
void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION);
void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }
private:
CipherDir dir_;
Mode mode_;
static const word32 p_init_[ROUNDS + 2];
static const word32 s_init_[4 * 256];
word32 pbox_[ROUNDS + 2];
word32 sbox_[4 * 256];
void crypt_block(const word32 in[2], word32 out[2]) const;
void AsmProcess(const byte* in, byte* out) const;
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
Blowfish(const Blowfish&); // hide copy
Blowfish& operator=(const Blowfish&); // and assign
};
typedef BlockCipher<ENCRYPTION, Blowfish, ECB> Blowfish_ECB_Encryption;
typedef BlockCipher<DECRYPTION, Blowfish, ECB> Blowfish_ECB_Decryption;
typedef BlockCipher<ENCRYPTION, Blowfish, CBC> Blowfish_CBC_Encryption;
typedef BlockCipher<DECRYPTION, Blowfish, CBC> Blowfish_CBC_Decryption;
} // naemspace
#endif // TAO_CRYPT_BLOWFISH_HPP
This diff is collapsed.
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
} }
void GenerateKeyPair(RandomNumberGenerator&, byte*, byte*); void GenerateKeyPair(RandomNumberGenerator&, byte*, byte*);
void Agree(byte*, const byte*, const byte*); void Agree(byte*, const byte*, const byte*, word32 otherSz = 0);
void SetP(const Integer& p) { p_ = p; } void SetP(const Integer& p) { p_ = p; }
void SetG(const Integer& g) { g_ = g; } void SetG(const Integer& g) { g_ = g; }
......
...@@ -57,17 +57,26 @@ public: ...@@ -57,17 +57,26 @@ public:
virtual void Update(const byte*, word32); virtual void Update(const byte*, word32);
virtual void Final(byte*); virtual void Final(byte*);
word32 GetBitCountLo() const { return loLen_ << 3; }
word32 GetBitCountHi() const { return (loLen_ >> (8*sizeof(loLen_) - 3)) +
(hiLen_ << 3); }
enum { MaxDigestSz = 5, MaxBufferSz = 64 }; enum { MaxDigestSz = 5, MaxBufferSz = 64 };
protected: protected:
word32 buffLen_; typedef word32 HashLengthType;
word32 length_; // in Bits word32 buffLen_; // in bytes
HashLengthType loLen_; // length in bytes
HashLengthType hiLen_; // length in bytes
word32 digest_[MaxDigestSz]; word32 digest_[MaxDigestSz];
word32 buffer_[MaxBufferSz / sizeof(word32)]; word32 buffer_[MaxBufferSz / sizeof(word32)];
virtual void Transform() = 0; virtual void Transform() = 0;
void AddLength(word32);
}; };
} // namespace } // namespace
#endif // TAO_CRYPT_HASH_HPP #endif // TAO_CRYPT_HASH_HPP
...@@ -56,12 +56,12 @@ private: ...@@ -56,12 +56,12 @@ private:
T mac_; T mac_;
// MSVC 6 HACK, gives compiler error if calculated in array // MSVC 6 HACK, gives compiler error if calculated in array
enum { HMAC_BSIZE = T::BLOCK_SIZE / sizeof(word32), enum { BSIZE = T::BLOCK_SIZE / sizeof(word32),
HMAC_DSIZE = T::DIGEST_SIZE / sizeof(word32) }; DSIZE = T::DIGEST_SIZE / sizeof(word32) };
word32 ip_[HMAC_BSIZE]; // align ipad_ on word32 word32 ip_[BSIZE]; // align ipad_ on word32
word32 op_[HMAC_BSIZE]; // align opad_ on word32 word32 op_[BSIZE]; // align opad_ on word32
word32 innerH_[HMAC_DSIZE]; // align innerHash_ on word32 word32 innerH_[DSIZE]; // align innerHash_ on word32
void KeyInnerHash(); void KeyInnerHash();
......
...@@ -274,7 +274,6 @@ private: ...@@ -274,7 +274,6 @@ private:
Integer& dividend, const Integer& divisor); Integer& dividend, const Integer& divisor);
AlignedWordBlock reg_; AlignedWordBlock reg_;
Sign sign_; Sign sign_;
}; };
inline bool operator==(const Integer& a, const Integer& b) inline bool operator==(const Integer& a, const Integer& b)
......
/* kernelc.hpp
*
* Copyright (C) 2003 Sawtooth Consulting Ltd.
*
* This file is part of yaSSL.
*
* yaSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* yaSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/* kernelc.hpp provides support for C std lib when compiled in kernel mode
*/
#ifndef TAOCRYPT_KERNELC_HPP
#define TAOCRYPT_KERNELC_HPP
#include <linux/types.h> // get right size_t
// system functions that c++ doesn't like headers for
extern "C" void* memcpy(void*, const void*, size_t);
extern "C" void* memset(void*, int, size_t);
extern "C" void printk(char *fmt, ...);
#define KERN_ERR "<3>" /* error conditions */
#if defined(NDEBUG)
#define assert(p) ((void)0)
#else
#define assert(expr) \
if (!(expr)) { \
printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \
#expr,__FILE__,__FUNCTION__,__LINE__); }
#endif
#endif // TAOCRYPT_KERNELC_HPP
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment