Merge perch.ndb.mysql.com:/home/jonas/src/mysql-5.1-new

into  perch.ndb.mysql.com:/home/jonas/src/51-jonas
This commit is contained in:
jonas@perch.ndb.mysql.com 2006-05-08 07:52:39 +02:00
commit cfeef33c13
392 changed files with 17515 additions and 4156 deletions

View file

@ -291,6 +291,7 @@ client/my_decimal.h
client/my_user.c client/my_user.c
client/mysql client/mysql
client/mysql.cpp client/mysql.cpp
client/mysql_upgrade
client/mysqladmin client/mysqladmin
client/mysqladmin.c client/mysqladmin.c
client/mysqladmin.cpp client/mysqladmin.cpp
@ -321,6 +322,7 @@ cmd-line-utils/libedit/makelist
comon.h comon.h
comp_err/*.ds? comp_err/*.ds?
comp_err/*.vcproj comp_err/*.vcproj
compile
config.cache config.cache
config.guess config.guess
config.h config.h
@ -367,6 +369,9 @@ extra/resolve_stack_dump
extra/resolveip extra/resolveip
extra/sql_state.h extra/sql_state.h
extra/tztime.cc extra/tztime.cc
extra/yassl/taocrypt/benchmark/benchmark
extra/yassl/taocrypt/test/test
extra/yassl/testsuite/testsuite
fcns.c fcns.c
fcns.h fcns.h
gdbinit gdbinit
@ -549,6 +554,7 @@ libmysqld/spatial.cc
libmysqld/sql_acl.cc libmysqld/sql_acl.cc
libmysqld/sql_analyse.cc libmysqld/sql_analyse.cc
libmysqld/sql_base.cc libmysqld/sql_base.cc
libmysqld/sql_builtin.cc
libmysqld/sql_cache.cc libmysqld/sql_cache.cc
libmysqld/sql_class.cc libmysqld/sql_class.cc
libmysqld/sql_command libmysqld/sql_command
@ -679,6 +685,7 @@ mysql-test/mysql-test-run.log
mysql-test/mysql_test_run_new mysql-test/mysql_test_run_new
mysql-test/ndb/ndbcluster mysql-test/ndb/ndbcluster
mysql-test/r/*.err mysql-test/r/*.err
mysql-test/r/*.log
mysql-test/r/*.out mysql-test/r/*.out
mysql-test/r/*.reject mysql-test/r/*.reject
mysql-test/r/alter_table.err mysql-test/r/alter_table.err
@ -1174,6 +1181,7 @@ sql/share/gmon.out
sql/share/mysql sql/share/mysql
sql/share/norwegian-ny/errmsg.sys sql/share/norwegian-ny/errmsg.sys
sql/share/norwegian/errmsg.sys sql/share/norwegian/errmsg.sys
sql/sql_builtin.cc
sql/sql_select.cc.orig sql/sql_select.cc.orig
sql/sql_yacc.cc sql/sql_yacc.cc
sql/sql_yacc.h sql/sql_yacc.h
@ -1747,6 +1755,10 @@ tools/mysqlmanager
tools/mysqlmngd tools/mysqlmngd
tools/mysqltestmanager tools/mysqltestmanager
tools/mysys_priv.h tools/mysys_priv.h
unittest/examples/*.t
unittest/mysys/*.t
unittest/mytap/t/*.t
unittest/unit
vi.h vi.h
vio/*.ds? vio/*.ds?
vio/*.vcproj vio/*.vcproj
@ -1758,9 +1770,3 @@ vio/viotest-sslconnect.cpp
vio/viotest.cpp vio/viotest.cpp
zlib/*.ds? zlib/*.ds?
zlib/*.vcproj zlib/*.vcproj
mysql-test/r/*.log
client/mysql_upgrade
unittest/examples/*.t
unittest/mysys/*.t
unittest/mytap/t/*.t
unittest/unit

View file

@ -147,18 +147,9 @@ static_link="$static_link --with-client-ldflags=-all-static"
local_infile_configs="--enable-local-infile" local_infile_configs="--enable-local-infile"
max_configs="--with-innodb --with-berkeley-db" max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max"
max_configs="$max_configs --with-archive-storage-engine" max_no_ndb_configs="$SSL_LIBRARY --with-plugins=max-no-ndb --with-embedded-server"
max_configs="$max_configs --with-big-tables" max_configs="$SSL_LIBRARY --with-plugins=max --with-embedded-server"
max_configs="$max_configs --with-blackhole-storage-engine"
max_configs="$max_configs --with-federated-storage-engine"
max_configs="$max_configs --with-csv-storage-engine"
max_configs="$max_configs --with-example-storage-engine"
max_configs="$max_configs --with-partition $SSL_LIBRARY"
max_no_embedded_configs="$max_configs --with-ndbcluster"
max_no_ndb_configs="$max_configs --without-ndbcluster --with-embedded-server"
max_configs="$max_configs --with-ndbcluster --with-embedded-server"
# #
# CPU and platform specific compilation flags. # CPU and platform specific compilation flags.

View file

@ -24,12 +24,11 @@ EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \
SUBDIRS = . include @docs_dirs@ @zlib_dir@ \ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
@readline_topdir@ sql-common \ @readline_topdir@ sql-common \
@thread_dirs@ pstack \ @thread_dirs@ pstack \
@sql_union_dirs@ storage \ @sql_union_dirs@ storage plugin \
@sql_server@ scripts @man_dirs@ tests \ @sql_server@ scripts @man_dirs@ tests \
@mysql_se_plugins@ \
netware @libmysqld_dirs@ \ netware @libmysqld_dirs@ \
mysql-test support-files @tools_dirs@ \ mysql-test support-files @tools_dirs@ \
plugin unittest win unittest win
DIST_SUBDIRS = $(SUBDIRS) BUILD DIST_SUBDIRS = $(SUBDIRS) BUILD

View file

@ -4,7 +4,7 @@
# TARGTYPE "Win32 (x86) Console Application" 0x0103 # TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=mysql_upgrade - Win32 Release CFG=mysql_upgrade - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run !MESSAGE use the Export Makefile command and run
!MESSAGE !MESSAGE
@ -13,59 +13,112 @@ CFG=mysql_upgrade - Win32 Release
!MESSAGE You can specify a configuration when running NMAKE !MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "mysql_upgrade.mak" CFG="mysql_upgrade - Win32 Release" !MESSAGE NMAKE /f "mysql_upgrade.mak" CFG="mysql_upgrade - Win32 Debug"
!MESSAGE !MESSAGE
!MESSAGE Possible choices for configuration are: !MESSAGE Possible choices for configuration are:
!MESSAGE !MESSAGE
!MESSAGE "mysql_upgrade - Win32 Release" (based on "Win32 (x86) Console Application") !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 !MESSAGE
# Begin Project # Begin Project
# PROP AllowPerConfigDependencies 0 # PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "" # PROP Scc_ProjName ""
# PROP Scc_LocalPath "" # PROP Scc_LocalPath ""
CPP=cl.exe CPP=xicl6.exe
RSC=rc.exe RSC=rc.exe
!IF "$(CFG)" == "mysql_upgrade - Win32 Release"
# PROP BASE Use_MFC 0 # PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0 # PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "mysql_upgrade___Win32_Release" # PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "mysql_upgrade___Win32_Release" # PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir "" # PROP BASE Target_Dir ""
# PROP Use_MFC 0 # PROP Use_MFC 0
# PROP Use_Debug_Libraries 0 # PROP Use_Debug_Libraries 0
# PROP Output_Dir "mysql_upgrade___Win32_Release" # PROP Output_Dir "release"
# PROP Intermediate_Dir "mysql_upgrade___Win32_Release" # PROP Intermediate_Dir "release"
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # 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" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /Fp"Release/mysql_upgrade.pch" /YX /Fo"Release/" /Fd"Release/" /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
# ADD BASE RSC /l 0x416 /d "NDEBUG" # SUBTRACT CPP /YX
# ADD RSC /l 0x416 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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 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 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 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 /nologo /subsystem:console /pdb:"release/mysql_upgrade.pdb" /machine:I386 /out:"../client_release/mysql_upgrade.exe" /libpath:"..\lib_release\\" # 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 /pdb:none # 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 # Begin Target
# Name "mysql_upgrade - Win32 Release" # Name "mysql_upgrade - Win32 Release"
# Begin Group "Source Files" # Name "mysql_upgrade - Win32 Debug"
# Name "mysql_upgrade - Win32 classic"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File # Begin Source File
SOURCE=.\mysql_upgrade.c SOURCE=.\mysql_upgrade.c
# End Source File # 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 Target
# End Project # End Project

View file

@ -0,0 +1,232 @@
<?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>

View file

@ -4,20 +4,22 @@
# TARGTYPE "Win32 (x86) Console Application" 0x0103 # TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=mysql_upgrade - Win32 Release CFG=mysql_upgrade - WinIA64 classic
!MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run !MESSAGE use the Export Makefile command and run
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "mysql_upgrade.mak". !MESSAGE NMAKE /f "mysql_upgrade_ia64.mak".
!MESSAGE !MESSAGE
!MESSAGE You can specify a configuration when running NMAKE !MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "mysql_upgrade.mak" CFG="mysql_upgrade - Win32 Release" !MESSAGE NMAKE /f "mysql_upgrade_ia64.mak" CFG="mysql_upgrade - WinIA64 classic"
!MESSAGE !MESSAGE
!MESSAGE Possible choices for configuration are: !MESSAGE Possible choices for configuration are:
!MESSAGE !MESSAGE
!MESSAGE "mysql_upgrade - WinIA64 Release" (based on "Win32 (x86) Console Application") !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 !MESSAGE
# Begin Project # Begin Project
@ -27,51 +29,96 @@ CFG=mysql_upgrade - Win32 Release
CPP=cl.exe CPP=cl.exe
RSC=rc.exe RSC=rc.exe
!IF "$(CFG)" == "mysql - WinIA64 Release" !IF "$(CFG)" == "mysql_upgrade - WinIA64 Release"
# PROP BASE Use_MFC 0 # PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0 # PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "mysql_upgrade___WinIA64_Release" # PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "mysql_upgrade___WinIA64_Release" # PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir "" # PROP BASE Target_Dir ""
# PROP Use_MFC 0 # PROP Use_MFC 0
# PROP Use_Debug_Libraries 0 # PROP Use_Debug_Libraries 0
# PROP Output_Dir "mysql_upgrade___WinIA64_Release" # PROP Output_Dir "release"
# PROP Intermediate_Dir "mysql_upgrade___WinIA64_Release" # PROP Intermediate_Dir "release"
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # 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 BASE CPP /nologo /W3 /GX /O2 /D "WIN64" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /I "../include" /D"NDEBUG" /D"DBUG_OFF" /D"_CONSOLE" /D"_MBCS" /D"_WINDOWS" /Fp"Release/mysql_upgrade.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c /O2 /G2 /EHsc /D"_IA64_" /Zi /D"WIN64" /D"WIN32" /D"_AFX_NO_DAO_SUPPORT" /Wp64 /Zm600 # 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
# ADD BASE RSC /l 0x416 /d "NDEBUG" # SUBTRACT CPP /YX
# ADD RSC /l 0x416 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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:IA64 # 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 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 zlib.lib /nologo /subsystem:console /pdb:"release/mysql_upgrade.pdb" /machine:IA64 /out:"../client_release/mysql_upgrade.exe" /libpath:"..\lib_release\\" /incremental:no # 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
# SUBTRACT LINK32
!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 !ENDIF
# Begin Target # Begin Target
# Name "mysql_upgrade - WinIA64 Release" # Name "mysql_upgrade - WinIA64 Release"
# Begin Group "Source Files" # Name "mysql_upgrade - WinIA64 Debug"
# Name "mysql_upgrade - WinIA64 classic"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File # Begin Source File
SOURCE=.\mysql_upgrade.c SOURCE=.\mysql_upgrade.c
# End Source File # 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 Target
# End Project # End Project

View file

@ -364,6 +364,10 @@ SOURCE=..\sql-common\my_time.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\sql-common\my_user.c
# End Source File
# Begin Source File
SOURCE=..\sql\net_serv.cpp SOURCE=..\sql\net_serv.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View file

@ -338,6 +338,10 @@ SOURCE="..\sql-common\my_time.c"
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE="..\sql-common\my_user.c"
# End Source File
# Begin Source File
SOURCE=..\sql\net_serv.cpp SOURCE=..\sql\net_serv.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File

View file

@ -446,6 +446,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
@ -530,6 +533,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>

View file

@ -157,6 +157,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}
@ -249,6 +257,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}") = "mysqlmanager", "server-tools\instance-manager\mysqlmanager.vcproj", "{6D524B3E-210A-4FCD-8D41-FEC0D21E83AC}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysqlmanager", "server-tools\instance-manager\mysqlmanager.vcproj", "{6D524B3E-210A-4FCD-8D41-FEC0D21E83AC}"

View file

@ -528,6 +528,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
@ -600,6 +603,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>

View file

@ -3232,6 +3232,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

View file

@ -136,7 +136,7 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
tty_password= 0, opt_nobeep=0, opt_reconnect=1, tty_password= 0, opt_nobeep=0, opt_reconnect=1,
default_charset_used= 0, opt_secure_auth= 0, default_charset_used= 0, opt_secure_auth= 0,
default_pager_set= 0, opt_sigint_ignore= 0, default_pager_set= 0, opt_sigint_ignore= 0,
show_warnings = 0; show_warnings= 0, executing_query= 0, interrupted_query= 0;
static ulong opt_max_allowed_packet, opt_net_buffer_length; static ulong opt_max_allowed_packet, opt_net_buffer_length;
static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0;
static my_string opt_mysql_unix_port=0; static my_string opt_mysql_unix_port=0;
@ -338,7 +338,7 @@ static void end_timer(ulong start_time,char *buff);
static void mysql_end_timer(ulong start_time,char *buff); static void mysql_end_timer(ulong start_time,char *buff);
static void nice_time(double sec,char *buff,bool part_second); static void nice_time(double sec,char *buff,bool part_second);
static sig_handler mysql_end(int sig); static sig_handler mysql_end(int sig);
static sig_handler handle_sigint(int sig);
int main(int argc,char *argv[]) int main(int argc,char *argv[])
{ {
@ -420,7 +420,7 @@ int main(int argc,char *argv[])
if (opt_sigint_ignore) if (opt_sigint_ignore)
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
else else
signal(SIGINT, mysql_end); // Catch SIGINT to clean up signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
/* /*
@ -523,6 +523,35 @@ sig_handler mysql_end(int sig)
} }
/*
This function handles sigint calls
If query is in process, kill query
no query in process, terminate like previous behavior
*/
sig_handler handle_sigint(int sig)
{
char kill_buffer[40];
MYSQL *kill_mysql= NULL;
/* terminate if no query being executed, or we already tried interrupting */
if (!executing_query || interrupted_query)
mysql_end(sig);
kill_mysql= mysql_init(kill_mysql);
if (!mysql_real_connect(kill_mysql,current_host, current_user, opt_password,
"", opt_mysql_port, opt_mysql_unix_port,0))
mysql_end(sig);
/* kill_buffer is always big enough because max length of %lu is 15 */
sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql));
mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
mysql_close(kill_mysql);
tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
interrupted_query= 1;
}
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
{ {
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
@ -1932,6 +1961,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
uint error= 0; uint error= 0;
int err= 0; int err= 0;
interrupted_query= 0;
if (!status.batch) if (!status.batch)
{ {
old_buffer= *buffer; // Save for edit command old_buffer= *buffer; // Save for edit command
@ -1967,7 +1997,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
} }
timer=start_timer(); timer=start_timer();
executing_query= 1;
error= mysql_real_query_for_lazy(buffer->ptr(),buffer->length()); error= mysql_real_query_for_lazy(buffer->ptr(),buffer->length());
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
@ -1981,6 +2011,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
if (error) if (error)
{ {
executing_query= 0;
buffer->length(0); // Remove query on error buffer->length(0); // Remove query on error
return error; return error;
} }
@ -1992,14 +2023,20 @@ com_go(String *buffer,char *line __attribute__((unused)))
if (quick) if (quick)
{ {
if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql)) if (!(result=mysql_use_result(&mysql)) && mysql_field_count(&mysql))
{
executing_query= 0;
return put_error(&mysql); return put_error(&mysql);
} }
}
else else
{ {
error= mysql_store_result_for_lazy(&result); error= mysql_store_result_for_lazy(&result);
if (error) if (error)
{
executing_query= 0;
return error; return error;
} }
}
if (verbose >= 3 || !opt_silent) if (verbose >= 3 || !opt_silent)
mysql_end_timer(timer,time_buff); mysql_end_timer(timer,time_buff);
@ -2073,6 +2110,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
(mysql.server_status & SERVER_STATUS_DB_DROPPED)) (mysql.server_status & SERVER_STATUS_DB_DROPPED))
get_current_db(); get_current_db();
executing_query= 0;
return error; /* New command follows */ return error; /* New command follows */
} }
@ -2286,6 +2324,8 @@ print_table_data(MYSQL_RES *result)
while ((cur= mysql_fetch_row(result))) while ((cur= mysql_fetch_row(result)))
{ {
if (interrupted_query)
break;
ulong *lengths= mysql_fetch_lengths(result); ulong *lengths= mysql_fetch_lengths(result);
(void) tee_fputs("| ", PAGER); (void) tee_fputs("| ", PAGER);
mysql_field_seek(result, 0); mysql_field_seek(result, 0);
@ -2393,6 +2433,8 @@ print_table_data_html(MYSQL_RES *result)
} }
while ((cur = mysql_fetch_row(result))) while ((cur = mysql_fetch_row(result)))
{ {
if (interrupted_query)
break;
ulong *lengths=mysql_fetch_lengths(result); ulong *lengths=mysql_fetch_lengths(result);
(void) tee_fputs("<TR>", PAGER); (void) tee_fputs("<TR>", PAGER);
for (uint i=0; i < mysql_num_fields(result); i++) for (uint i=0; i < mysql_num_fields(result); i++)
@ -2422,6 +2464,8 @@ print_table_data_xml(MYSQL_RES *result)
fields = mysql_fetch_fields(result); fields = mysql_fetch_fields(result);
while ((cur = mysql_fetch_row(result))) while ((cur = mysql_fetch_row(result)))
{ {
if (interrupted_query)
break;
ulong *lengths=mysql_fetch_lengths(result); ulong *lengths=mysql_fetch_lengths(result);
(void) tee_fputs("\n <row>\n", PAGER); (void) tee_fputs("\n <row>\n", PAGER);
for (uint i=0; i < mysql_num_fields(result); i++) for (uint i=0; i < mysql_num_fields(result); i++)
@ -2456,6 +2500,8 @@ print_table_data_vertically(MYSQL_RES *result)
mysql_field_seek(result,0); mysql_field_seek(result,0);
for (uint row_count=1; (cur= mysql_fetch_row(result)); row_count++) for (uint row_count=1; (cur= mysql_fetch_row(result)); row_count++)
{ {
if (interrupted_query)
break;
mysql_field_seek(result,0); mysql_field_seek(result,0);
tee_fprintf(PAGER, tee_fprintf(PAGER,
"*************************** %d. row ***************************\n", row_count); "*************************** %d. row ***************************\n", row_count);

View file

@ -135,7 +135,9 @@ static int create_check_file(const char *path)
if (check_file < 0) if (check_file < 0)
return 1; return 1;
error= my_write(check_file, VERSION, strlen(VERSION), MYF(MY_WME | MY_FNABP)); error= my_write(check_file,
MYSQL_SERVER_VERSION, strlen(MYSQL_SERVER_VERSION),
MYF(MY_WME | MY_FNABP));
error= my_close(check_file, MYF(MY_FAE | MY_WME)) || error; error= my_close(check_file, MYF(MY_FAE | MY_WME)) || error;
return error; return error;
} }
@ -243,7 +245,7 @@ int main(int argc, char **argv)
&& (test_file_exists("./bin", "mysqld") || && (test_file_exists("./bin", "mysqld") ||
test_file_exists("./libexec", "mysqld"))) test_file_exists("./libexec", "mysqld")))
{ {
getcwd(bindir, sizeof(bindir)); my_getwd(bindir, sizeof(bindir), MYF(0));
bindir_end= bindir + strlen(bindir); bindir_end= bindir + strlen(bindir);
} }
else else
@ -305,7 +307,7 @@ int main(int argc, char **argv)
b_read= my_read(check_file, chf_buffer, sizeof(chf_buffer)-1, MYF(0)); b_read= my_read(check_file, chf_buffer, sizeof(chf_buffer)-1, MYF(0));
chf_buffer[b_read]= 0; chf_buffer[b_read]= 0;
my_close(check_file, MYF(0)); my_close(check_file, MYF(0));
if (!strcmp(chf_buffer, VERSION)) if (!strcmp(chf_buffer, MYSQL_SERVER_VERSION))
{ {
if (opt_verbose) if (opt_verbose)
puts("mysql_upgrade already done for this version"); puts("mysql_upgrade already done for this version");

View file

@ -457,8 +457,8 @@ static struct my_option my_long_options[] =
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
0}, 0},
{"preserve-schema", OPT_MYSQL_PRESERVE_SCHEMA, {"preserve-schema", OPT_MYSQL_PRESERVE_SCHEMA,
"Preserve the schema from the mysqlslap run, this happens unless \ "Preserve the schema from the mysqlslap run, this happens unless "
--auto-generate-sql or --create are used.", "--auto-generate-sql or --create are used.",
(gptr*) &opt_preserve, (gptr*) &opt_preserve, 0, GET_BOOL, (gptr*) &opt_preserve, (gptr*) &opt_preserve, 0, GET_BOOL,
NO_ARG, TRUE, 0, 0, 0, 0, 0}, NO_ARG, TRUE, 0, 0, 0, 0, 0},
{"protocol", OPT_MYSQL_PROTOCOL, {"protocol", OPT_MYSQL_PROTOCOL,

View file

@ -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="./";
const char *opt_include= 0; const char *opt_include= 0;
@ -688,10 +688,11 @@ static void die(const char *fmt, ...)
/* Note that we will get some memory leaks when calling this! */ /* Note that we will get some memory leaks when calling this! */
static void abort_not_supported_test() static void abort_not_supported_test(const char *fname)
{ {
DBUG_ENTER("abort_not_supported_test"); DBUG_ENTER("abort_not_supported_test");
fprintf(stderr, "This test is not supported by this installation\n"); fprintf(stderr, "The test '%s' is not supported by this installation\n",
fname);
if (!silent) if (!silent)
printf("skipped\n"); printf("skipped\n");
free_used_memory(); free_used_memory();
@ -814,7 +815,7 @@ static void check_result(DYNAMIC_STRING* ds, const char *fname,
DBUG_ENTER("check_result"); DBUG_ENTER("check_result");
if (res && require_option) if (res && require_option)
abort_not_supported_test(); abort_not_supported_test(fname);
switch (res) { switch (res) {
case RESULT_OK: case RESULT_OK:
break; /* ok */ break; /* ok */
@ -1036,7 +1037,7 @@ int do_wait_for_slave_to_stop(struct st_query *q __attribute__((unused)))
int do_require_manager(struct st_query *query __attribute__((unused)) ) int do_require_manager(struct st_query *query __attribute__((unused)) )
{ {
if (!manager) if (!manager)
abort_not_supported_test(); abort_not_supported_test("manager");
return 0; return 0;
} }
@ -1305,7 +1306,9 @@ int var_query_set(VAR* var, const char *query, const char** query_end)
uint i; uint i;
ulong *lengths; ulong *lengths;
char *end; char *end;
#ifdef NOT_YET
MYSQL_FIELD *fields= mysql_fetch_fields(res); MYSQL_FIELD *fields= mysql_fetch_fields(res);
#endif
init_dynamic_string(&result, "", 16384, 65536); init_dynamic_string(&result, "", 16384, 65536);
lengths= mysql_fetch_lengths(res); lengths= mysql_fetch_lengths(res);
@ -1880,10 +1883,11 @@ 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));
if (sleep_val)
my_sleep((ulong) (sleep_val * 1000000L)); my_sleep((ulong) (sleep_val * 1000000L));
query->last_argument= sleep_end; query->last_argument= sleep_end;
return 0; return 0;
@ -1919,7 +1923,7 @@ static void set_charset(struct st_query *q)
q->last_argument= p; q->last_argument= p;
charset_info= get_charset_by_csname(charset_name,MY_CS_PRIMARY,MYF(MY_WME)); charset_info= get_charset_by_csname(charset_name,MY_CS_PRIMARY,MYF(MY_WME));
if (!charset_info) if (!charset_info)
abort_not_supported_test(); abort_not_supported_test(charset_name);
} }
static uint get_errcodes(match_err *to,struct st_query *q) static uint get_errcodes(match_err *to,struct st_query *q)
@ -1956,7 +1960,13 @@ static uint get_errcodes(match_err *to,struct st_query *q)
; ;
for (; e->name; e++) for (; e->name; e++)
{ {
if (!strncmp(start, e->name, (int) (p - start))) /*
If we get a match, we need to check the length of the name we
matched against in case it was longer than what we are checking
(as in ER_WRONG_VALUE vs. ER_WRONG_VALUE_COUNT).
*/
if (!strncmp(start, e->name, (int) (p - start)) &&
(uint) strlen(e->name) == (uint) (p - start))
{ {
to[count].code.errnum= (uint) e->code; to[count].code.errnum= (uint) e->code;
to[count].type= ERR_ERRNO; to[count].type= ERR_ERRNO;
@ -3304,7 +3314,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,
@ -4322,7 +4332,7 @@ static void handle_error(const char *query, struct st_query *q,
if (err_errno == CR_SERVER_LOST || if (err_errno == CR_SERVER_LOST ||
err_errno == CR_SERVER_GONE_ERROR) err_errno == CR_SERVER_GONE_ERROR)
die("require query '%s' failed: %d: %s", query, err_errno, err_error); die("require query '%s' failed: %d: %s", query, err_errno, err_error);
abort_not_supported_test(); abort_not_supported_test("failed_query");
} }
if (q->abort_on_error) if (q->abort_on_error)
@ -5094,7 +5104,7 @@ static void init_var_hash(MYSQL *mysql)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
static void mark_progress(int line) static void mark_progress(int line __attribute__((unused)))
{ {
#ifdef NOT_YET #ifdef NOT_YET
static FILE* fp = NULL; static FILE* fp = NULL;

View file

@ -9,56 +9,53 @@ SET(WITH_CSV_STORAGE_ENGINE TRUE)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY) ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY)
SET(WITH_HEAP_STORAGE_ENGINE TRUE)
ADD_DEFINITIONS(-D WITH_HEAP_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_heap_plugin")
SET(WITH_MYISAM_STORAGE_ENGINE TRUE)
ADD_DEFINITIONS(-D WITH_MYISAM_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisam_plugin")
SET(WITH_MYISAMMRG_STORAGE_ENGINE TRUE)
ADD_DEFINITIONS(-D WITH_MYISAMMRG_STORAGE_ENGINE)
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_myisammrg_plugin")
IF(WITH_ARCHIVE_STORAGE_ENGINE) IF(WITH_ARCHIVE_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_ARCHIVE_STORAGE_ENGINE) ADD_DEFINITIONS(-D WITH_ARCHIVE_STORAGE_ENGINE)
SET (mysql_se_htons "${mysql_se_htons}, &archive_hton") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_archive_plugin")
SET (mysql_se_decls "${mysql_se_decls}, archive_hton")
SET (mysql_se_ha_src ${mysql_se_ha_src} "../sql/ha_archive.cc")
ENDIF(WITH_ARCHIVE_STORAGE_ENGINE) ENDIF(WITH_ARCHIVE_STORAGE_ENGINE)
IF(WITH_BLACKHOLE_STORAGE_ENGINE) IF(WITH_BLACKHOLE_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_BLACKHOLE_STORAGE_ENGINE) ADD_DEFINITIONS(-D WITH_BLACKHOLE_STORAGE_ENGINE)
SET (mysql_se_htons "${mysql_se_htons}, &blackhole_hton") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_blackhole_plugin")
SET (mysql_se_decls "${mysql_se_decls}, blackhole_hton")
SET (mysql_se_ha_src ${mysql_se_ha_src} "../sql/ha_blackhole.cc")
ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE) ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE)
IF(WITH_CSV_STORAGE_ENGINE) IF(WITH_CSV_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_CSV_STORAGE_ENGINE) ADD_DEFINITIONS(-D WITH_CSV_STORAGE_ENGINE)
SET (mysql_se_htons "${mysql_se_htons}, &tina_hton") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_csv_plugin")
SET (mysql_se_decls "${mysql_se_decls}, tina_hton")
SET (mysql_se_ha_src ${mysql_se_ha_src} "../storage/csv/ha_tina.cc")
ENDIF(WITH_CSV_STORAGE_ENGINE) ENDIF(WITH_CSV_STORAGE_ENGINE)
IF(WITH_EXAMPLE_STORAGE_ENGINE) IF(WITH_EXAMPLE_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_EXAMPLE_STORAGE_ENGINE) ADD_DEFINITIONS(-D WITH_EXAMPLE_STORAGE_ENGINE)
SET (mysql_se_htons "${mysql_se_htons}, &example_hton") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_example_plugin")
SET (mysql_se_decls "${mysql_se_decls}, example_hton")
ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) ENDIF(WITH_EXAMPLE_STORAGE_ENGINE)
IF(WITH_INNOBASE_STORAGE_ENGINE) IF(WITH_INNOBASE_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_INNOBASE_STORAGE_ENGINE) ADD_DEFINITIONS(-D WITH_INNOBASE_STORAGE_ENGINE)
SET (mysql_se_htons "${mysql_se_htons}, &innobase_hton") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_innobase_plugin")
SET (mysql_se_decls "${mysql_se_decls}, innobase_hton")
SET (mysql_se_ha_src ${mysql_se_ha_src} "../sql/ha_innodb.cc")
ENDIF(WITH_INNOBASE_STORAGE_ENGINE) ENDIF(WITH_INNOBASE_STORAGE_ENGINE)
IF(WITH_PARTITION_STORAGE_ENGINE) IF(WITH_PARTITION_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_PARTITION_STORAGE_ENGINE) ADD_DEFINITIONS(-D WITH_PARTITION_STORAGE_ENGINE)
SET (mysql_se_htons "${mysql_se_htons}, &partition_hton") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_partition_plugin")
SET (mysql_se_decls "${mysql_se_decls}, partition_hton")
SET (mysql_se_ha_src ${mysql_se_ha_src} "../sql/ha_partition.cc")
ENDIF(WITH_PARTITION_STORAGE_ENGINE) ENDIF(WITH_PARTITION_STORAGE_ENGINE)
IF(WITH_FEDERATED_STORAGE_ENGINE) IF(WITH_FEDERATED_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_FEDERATED_STORAGE_ENGINE) ADD_DEFINITIONS(-D WITH_FEDERATED_STORAGE_ENGINE)
SET (mysql_se_htons "${mysql_se_htons}, &federated_hton") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_federated_plugin")
SET (mysql_se_decls "${mysql_se_decls}, federated_hton")
SET (mysql_se_ha_src ${mysql_se_ha_src} "../sql/ha_federated.cc")
ENDIF(WITH_FEDERATED_STORAGE_ENGINE) ENDIF(WITH_FEDERATED_STORAGE_ENGINE)
IF(WITH_BERKELEY_STORAGE_ENGINE) IF(WITH_BERKELEY_STORAGE_ENGINE)
ADD_DEFINITIONS(-D WITH_BERKELEY_STORAGE_ENGINE) ADD_DEFINITIONS(-D WITH_BERKELEY_STORAGE_ENGINE)
SET (mysql_se_htons "${mysql_se_htons}, &berkeley_hton") SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_berkeley_plugin")
SET (mysql_se_decls "${mysql_se_decls}, berkeley_hton")
SET (mysql_se_ha_src ${mysql_se_ha_src} "../sql/ha_berkeley.cc")
ENDIF(WITH_BERKELEY_STORAGE_ENGINE) ENDIF(WITH_BERKELEY_STORAGE_ENGINE)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/handlerton.cc.in CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
${CMAKE_SOURCE_DIR}/sql/handlerton.cc @ONLY) ${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc @ONLY)
SET(localstatedir "C:\\mysql\\data") SET(localstatedir "C:\\mysql\\data")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-huge.cnf.sh CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-huge.cnf.sh
@ -137,6 +134,12 @@ ENDIF(WITH_ARCHIVE_STORAGE_ENGINE)
IF(WITH_BERKELEY_STORAGE_ENGINE) IF(WITH_BERKELEY_STORAGE_ENGINE)
ADD_SUBDIRECTORY(storage/bdb) ADD_SUBDIRECTORY(storage/bdb)
ENDIF(WITH_BERKELEY_STORAGE_ENGINE) ENDIF(WITH_BERKELEY_STORAGE_ENGINE)
IF(WITH_BLACKHOLE_STORAGE_ENGINE)
ADD_SUBDIRECTORY(storage/blackhole)
ENDIF(WITH_BLACKHOLE_STORAGE_ENGINE)
IF(WITH_CSV_STORAGE_ENGINE)
ADD_SUBDIRECTORY(storage/csv)
ENDIF(WITH_CSV_STORAGE_ENGINE)
IF(WITH_EXAMPLE_STORAGE_ENGINE) IF(WITH_EXAMPLE_STORAGE_ENGINE)
ADD_SUBDIRECTORY(storage/example) ADD_SUBDIRECTORY(storage/example)
ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) ENDIF(WITH_EXAMPLE_STORAGE_ENGINE)

View file

@ -1,29 +0,0 @@
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_ARCHIVEDB
dnl Sets HAVE_ARCHIVE_DB if --with-archive-storage-engine is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_ARCHIVEDB], [
AC_ARG_WITH([archive-storage-engine],
[
--with-archive-storage-engine
Enable the Archive Storage Engine],
[archivedb="$withval"],
[archivedb=no])
AC_MSG_CHECKING([for archive storage engine])
case "$archivedb" in
yes )
AC_DEFINE([HAVE_ARCHIVE_DB], [1], [Builds Archive Storage Engine])
AC_MSG_RESULT([yes])
[archivedb=yes]
;;
* )
AC_MSG_RESULT([no])
[archivedb=no]
;;
esac
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_ARCHIVE SECTION
dnl ---------------------------------------------------------------------------

View file

@ -8,23 +8,20 @@ dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_SETUP_BERKELEY_DB], [ AC_DEFUN([MYSQL_SETUP_BERKELEY_DB], [
AC_ARG_WITH([berkeley-db], AC_ARG_WITH([berkeley-db],
[ AS_HELP_STRING([--with-berkeley-db[[[[[=DIR]]]]]],
--with-berkeley-db[=DIR] [Use BerkeleyDB located in DIR]),
Use BerkeleyDB located in DIR],
[bdb="$withval"], [bdb="$withval"],
[bdb=yes]) [bdb=yes])
AC_ARG_WITH([berkeley-db-includes], AC_ARG_WITH([berkeley-db-includes],
[ AS_HELP_STRING([--with-berkeley-db-includes=DIR],
--with-berkeley-db-includes=DIR [Find Berkeley DB headers in DIR]),
Find Berkeley DB headers in DIR],
[bdb_includes="$withval"], [bdb_includes="$withval"],
[bdb_includes=default]) [bdb_includes=default])
AC_ARG_WITH([berkeley-db-libs], AC_ARG_WITH([berkeley-db-libs],
[ AS_HELP_STRING([--with-berkeley-db-libs=DIR],
--with-berkeley-db-libs=DIR [Find Berkeley DB libraries in DIR]),
Find Berkeley DB libraries in DIR],
[bdb_libs="$withval"], [bdb_libs="$withval"],
[bdb_libs=default]) [bdb_libs=default])
@ -120,12 +117,9 @@ AC_DEFUN([MYSQL_SETUP_BERKELEY_DB], [
sh $rel_srcdir/$bdb/dist/configure $bdb_conf_flags) || \ sh $rel_srcdir/$bdb/dist/configure $bdb_conf_flags) || \
AC_MSG_ERROR([could not configure Berkeley DB]) AC_MSG_ERROR([could not configure Berkeley DB])
mysql_se_libs="$mysql_se_libs $bdb_libs_with_path"
AC_SUBST(bdb_includes) AC_SUBST(bdb_includes)
AC_SUBST(bdb_libs) AC_SUBST(bdb_libs)
AC_SUBST(bdb_libs_with_path) AC_SUBST(bdb_libs_with_path)
AC_CONFIG_FILES(storage/bdb/Makefile)
]) ])
AC_DEFUN([MYSQL_CHECK_INSTALLED_BDB], [ AC_DEFUN([MYSQL_CHECK_INSTALLED_BDB], [

View file

@ -1,29 +0,0 @@
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_BLACKHOLEDB
dnl Sets HAVE_BLACKHOLE_DB if --with-blackhole-storage-engine is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_BLACKHOLEDB], [
AC_ARG_WITH([blackhole-storage-engine],
[
--with-blackhole-storage-engine
Enable the Blackhole Storage Engine],
[blackholedb="$withval"],
[blackholedb=no])
AC_MSG_CHECKING([for blackhole storage engine])
case "$blackholedb" in
yes )
AC_DEFINE([HAVE_BLACKHOLE_DB], [1], [Builds Blackhole Storage Engine])
AC_MSG_RESULT([yes])
[blackholedb=yes]
;;
* )
AC_MSG_RESULT([no])
[blackholedb=no]
;;
esac
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_BLACKHOLE SECTION
dnl ---------------------------------------------------------------------------

View file

@ -1,30 +0,0 @@
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_EXAMPLEDB
dnl Sets HAVE_EXAMPLE_DB if --with-example-storage-engine is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_EXAMPLEDB], [
AC_ARG_WITH([example-storage-engine],
[
--with-example-storage-engine
Enable the Example Storage Engine],
[exampledb="$withval"],
[exampledb=no])
AC_MSG_CHECKING([for example storage engine])
case "$exampledb" in
yes )
AC_DEFINE([HAVE_EXAMPLE_DB], [1], [Builds Example DB])
AC_MSG_RESULT([yes])
[exampledb=yes]
;;
* )
AC_MSG_RESULT([no])
[exampledb=no]
;;
esac
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_EXAMPLE SECTION
dnl ---------------------------------------------------------------------------

View file

@ -1,29 +0,0 @@
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_FEDERATED
dnl Sets HAVE_FEDERATED if --with-federated-storage-engine is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_FEDERATED], [
AC_ARG_WITH([federated-storage-engine],
[
--with-federated-storage-engine
Enable the MySQL Federated Storage Engine],
[federateddb="$withval"],
[federateddb=no])
AC_MSG_CHECKING([for MySQL federated storage engine])
case "$federateddb" in
yes )
AC_DEFINE([HAVE_FEDERATED_DB], [1], [Define to enable Federated Handler])
AC_MSG_RESULT([yes])
[federateddb=yes]
;;
* )
AC_MSG_RESULT([no])
[federateddb=no]
;;
esac
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_FEDERATED SECTION
dnl ---------------------------------------------------------------------------

View file

@ -1,77 +0,0 @@
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_INNODB
dnl Sets HAVE_INNOBASE_DB if --with-innodb is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_INNODB], [
AC_ARG_WITH([innodb],
[
--without-innodb Do not include the InnoDB table handler],
[innodb="$withval"],
[innodb=yes])
AC_MSG_CHECKING([for Innodb])
have_innodb=no
innodb_includes=
innodb_libs=
case "$innodb" in
yes )
AC_MSG_RESULT([Using Innodb])
AC_DEFINE([HAVE_INNOBASE_DB], [1], [Using Innobase DB])
have_innodb="yes"
innodb_includes="-I\$(top_builddir)/innobase/include"
innodb_system_libs=""
dnl Some libs are listed several times, in order for gcc to sort out
dnl circular references.
innodb_libs="\
\$(top_builddir)/storage/innobase/usr/libusr.a\
\$(top_builddir)/storage/innobase/srv/libsrv.a\
\$(top_builddir)/storage/innobase/dict/libdict.a\
\$(top_builddir)/storage/innobase/que/libque.a\
\$(top_builddir)/storage/innobase/srv/libsrv.a\
\$(top_builddir)/storage/innobase/ibuf/libibuf.a\
\$(top_builddir)/storage/innobase/row/librow.a\
\$(top_builddir)/storage/innobase/pars/libpars.a\
\$(top_builddir)/storage/innobase/btr/libbtr.a\
\$(top_builddir)/storage/innobase/trx/libtrx.a\
\$(top_builddir)/storage/innobase/read/libread.a\
\$(top_builddir)/storage/innobase/usr/libusr.a\
\$(top_builddir)/storage/innobase/buf/libbuf.a\
\$(top_builddir)/storage/innobase/ibuf/libibuf.a\
\$(top_builddir)/storage/innobase/eval/libeval.a\
\$(top_builddir)/storage/innobase/log/liblog.a\
\$(top_builddir)/storage/innobase/fsp/libfsp.a\
\$(top_builddir)/storage/innobase/fut/libfut.a\
\$(top_builddir)/storage/innobase/fil/libfil.a\
\$(top_builddir)/storage/innobase/lock/liblock.a\
\$(top_builddir)/storage/innobase/mtr/libmtr.a\
\$(top_builddir)/storage/innobase/page/libpage.a\
\$(top_builddir)/storage/innobase/rem/librem.a\
\$(top_builddir)/storage/innobase/thr/libthr.a\
\$(top_builddir)/storage/innobase/sync/libsync.a\
\$(top_builddir)/storage/innobase/data/libdata.a\
\$(top_builddir)/storage/innobase/mach/libmach.a\
\$(top_builddir)/storage/innobase/ha/libha.a\
\$(top_builddir)/storage/innobase/dyn/libdyn.a\
\$(top_builddir)/storage/innobase/mem/libmem.a\
\$(top_builddir)/storage/innobase/sync/libsync.a\
\$(top_builddir)/storage/innobase/ut/libut.a\
\$(top_builddir)/storage/innobase/os/libos.a\
\$(top_builddir)/storage/innobase/ut/libut.a"
AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
;;
* )
AC_MSG_RESULT([Not using Innodb])
;;
esac
AC_SUBST(innodb_includes)
AC_SUBST(innodb_libs)
AC_SUBST(innodb_system_libs)
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_INNODB SECTION
dnl ---------------------------------------------------------------------------

View file

@ -191,7 +191,6 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
ndbcluster_libs="\$(top_builddir)/storage/ndb/src/.libs/libndbclient.a" ndbcluster_libs="\$(top_builddir)/storage/ndb/src/.libs/libndbclient.a"
ndbcluster_system_libs="" ndbcluster_system_libs=""
ndb_mgmclient_libs="\$(top_builddir)/storage/ndb/src/mgmclient/libndbmgmclient.la" ndb_mgmclient_libs="\$(top_builddir)/storage/ndb/src/mgmclient/libndbmgmclient.la"
mysql_se_objs="$mysql_se_objs ha_ndbcluster_binlog.o"
MYSQL_CHECK_NDB_OPTIONS MYSQL_CHECK_NDB_OPTIONS
NDBCLUSTER_WORKAROUNDS NDBCLUSTER_WORKAROUNDS
@ -282,9 +281,6 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
ndb_bin_am_ldflags="" ndb_bin_am_ldflags=""
fi fi
mysql_se_libs="$mysql_se_libs $ndbcluster_libs $ndbcluster_system_libs"
mysql_se_libs="$mysql_se_libs $NDB_SCI_LIBS"
AC_SUBST(NDB_VERSION_MAJOR) AC_SUBST(NDB_VERSION_MAJOR)
AC_SUBST(NDB_VERSION_MINOR) AC_SUBST(NDB_VERSION_MINOR)
AC_SUBST(NDB_VERSION_BUILD) AC_SUBST(NDB_VERSION_BUILD)
@ -302,6 +298,7 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
AC_SUBST(ndbcluster_libs) AC_SUBST(ndbcluster_libs)
AC_SUBST(ndbcluster_system_libs) AC_SUBST(ndbcluster_system_libs)
AC_SUBST(ndb_mgmclient_libs) AC_SUBST(ndb_mgmclient_libs)
AC_SUBST(NDB_SCI_LIBS)
AC_SUBST(ndb_transporter_opt_objs) AC_SUBST(ndb_transporter_opt_objs)
AC_SUBST(ndb_port) AC_SUBST(ndb_port)
@ -311,7 +308,7 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
AC_SUBST(NDB_DEFS) AC_SUBST(NDB_DEFS)
AC_SUBST(ndb_cxxflags_fix) AC_SUBST(ndb_cxxflags_fix)
AC_CONFIG_FILES(storage/ndb/Makefile storage/ndb/include/Makefile dnl AC_CONFIG_FILES(storage/ndb/include/Makefile dnl
storage/ndb/src/Makefile storage/ndb/src/common/Makefile dnl storage/ndb/src/Makefile storage/ndb/src/common/Makefile dnl
storage/ndb/docs/Makefile dnl storage/ndb/docs/Makefile dnl
storage/ndb/tools/Makefile dnl storage/ndb/tools/Makefile dnl

View file

@ -1,33 +0,0 @@
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_PARTITIONDB
dnl Sets HAVE_PARTITION_DB if --with-partition is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_PARTITIONDB], [
AC_ARG_WITH([partition],
[
--with-partition
Enable the Partition Storage Engine],
[partitiondb="$withval"],
[partitiondb=no])
AC_MSG_CHECKING([for partition])
dnl case "$partitiondb" in
dnl yes )
dnl AC_DEFINE([HAVE_PARTITION_DB], [1], [Builds Partition DB])
dnl AC_MSG_RESULT([yes])
dnl [partitiondb=yes]
dnl ;;
dnl * )
dnl AC_MSG_RESULT([no])
dnl [partitiondb=no]
dnl ;;
dnl esac
AC_DEFINE([HAVE_PARTITION_DB], [1], [Builds Partition DB])
AC_MSG_RESULT([yes])
[partitiondb=yes]
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_PARTITION SECTION
dnl ---------------------------------------------------------------------------

View file

@ -1,29 +0,0 @@
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_CSVDB
dnl Sets HAVE_CSV_DB if --with-csv-storage-engine is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_CSVDB], [
AC_ARG_WITH([csv-storage-engine],
[
--with-csv-storage-engine
Enable the CSV Storage Engine],
[csvdb="$withval"],
[csvdb=no])
AC_MSG_CHECKING([for csv storage engine])
case "$csvdb" in
yes )
AC_DEFINE([HAVE_CSV_DB], [1], [Builds the CSV Storage Engine])
AC_MSG_RESULT([yes])
[csvdb=yes]
;;
* )
AC_MSG_RESULT([no])
[csvdb=no]
;;
esac
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_CSV SECTION
dnl ---------------------------------------------------------------------------

View file

@ -675,8 +675,8 @@ dnl Sets BIG_TABLES if --with-big-tables is used
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_BIG_TABLES], [ AC_DEFUN([MYSQL_CHECK_BIG_TABLES], [
AC_ARG_WITH([big-tables], AC_ARG_WITH([big-tables],
[ AS_HELP_STRING([--with-big-tables],
--with-big-tables Support tables with more than 4 G rows even on 32 bit platforms], [Support tables with more than 4 G rows even on 32 bit platforms]),
[bigtables="$withval"], [bigtables="$withval"],
[bigtables=no]) [bigtables=no])
AC_MSG_CHECKING([for big tables support]) AC_MSG_CHECKING([for big tables support])
@ -703,8 +703,8 @@ dnl Sets MAX_INDEXES
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_MAX_INDEXES], [ AC_DEFUN([MYSQL_CHECK_MAX_INDEXES], [
AC_ARG_WITH([max-indexes], AC_ARG_WITH([max-indexes],
[ AS_HELP_STRING([--with-max-indexes=N],
--with-max-indexes=\# Sets the maximum number of indexes per table, default 64], [Sets the maximum number of indexes per table, default 64]),
[max_indexes="$withval"], [max_indexes="$withval"],
[max_indexes=64]) [max_indexes=64])
AC_MSG_CHECKING([max indexes per table]) AC_MSG_CHECKING([max indexes per table])

View file

@ -1,6 +1,7 @@
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], [
/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], [
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
;; ;;

733
config/ac-macros/plugins.m4 Normal file
View file

@ -0,0 +1,733 @@
dnl ===========================================================================
dnl Support for mysql server plugins
dnl ===========================================================================
dnl
dnl WorkLog#3201
dnl
dnl Framework for pluggable static and dynamic plugins for mysql
dnl
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_PLUGIN
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN([name],[Plugin name],
dnl [Plugin description],
dnl [group,group...])
dnl
dnl DESCRIPTION
dnl First declaration for a plugin (mandatory).
dnl Adds plugin as member to configuration groups (if specified)
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_PLUGIN],[
_MYSQL_PLUGIN(
[$1],
[__MYSQL_PLUGIN_]AS_TR_CPP([$1])[__],
m4_default([$2], [$1 plugin]),
m4_default([$3], [plugin for $1]),
m4_default([$4], []),
)
])
AC_DEFUN([_MYSQL_PLUGIN],[
m4_ifdef([$2], [
AC_FATAL([Duplicate MYSQL_PLUGIN declaration for $3])
],[
m4_define([$2], [$1])
_MYSQL_PLUGAPPEND([__mysql_plugin_list__],[$1])
m4_define([MYSQL_PLUGIN_NAME_]AS_TR_CPP([$1]), [$3])
m4_define([MYSQL_PLUGIN_DESC_]AS_TR_CPP([$1]), [$4])
_MYSQL_PLUGAPPEND_META([$1], $5)
])
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_STORAGE_ENGINE
dnl
dnl SYNOPSIS
dnl MYSQL_STORAGE_ENGINE([name],[legacy-option],[Storage engine name],
dnl [Storage engine description],[group,group...])
dnl
dnl DESCRIPTION
dnl Short cut for storage engine declarations
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_STORAGE_ENGINE],[
MYSQL_PLUGIN([$1], [$3], [$4], [[$5]])
MYSQL_PLUGIN_DEFINE([$1], [WITH_]AS_TR_CPP([$1])[_STORAGE_ENGINE])
ifelse([$2],[no],[],[
_MYSQL_LEGACY_STORAGE_ENGINE(
m4_bpatsubst([$1], -, _),
m4_bpatsubst(m4_default([$2], [$1-storage-engine]), -, _))
])
])
AC_DEFUN([_MYSQL_LEGACY_STORAGE_ENGINE],[
if test "[${with_]$2[+set}]" = set; then
[with_plugin_]$1="[$with_]$2"
fi
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_PLUGIN_DEFINE
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN_DEFINE([name],[MYSQL_CPP_DEFINE])
dnl
dnl DESCRIPTION
dnl When a plugin is to be statically linked, define the C macro
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_PLUGIN_DEFINE],[
MYSQL_REQUIRE_PLUGIN([$1])
m4_define([MYSQL_PLUGIN_DEFINE_]AS_TR_CPP([$1]), [$2])
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_PLUGIN_DIRECTORY
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN_DIRECTORY([name],[plugin/dir])
dnl
dnl DESCRIPTION
dnl Adds a directory to the build process
dnl if it contains 'configure' it will be picked up automatically
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_PLUGIN_DIRECTORY],[
MYSQL_REQUIRE_PLUGIN([$1])
m4_define([MYSQL_PLUGIN_DIRECTORY_]AS_TR_CPP([$1]), [$2])
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_PLUGIN_STATIC
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN_STATIC([name],[libmyplugin.a])
dnl
dnl DESCRIPTION
dnl Declare the name for the static library
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_PLUGIN_STATIC],[
MYSQL_REQUIRE_PLUGIN([$1])
m4_define([MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]), [$2])
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_PLUGIN_DYNAMIC
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN_DYNAMIC([name],[myplugin.la])
dnl
dnl DESCRIPTION
dnl Declare the name for the shared library
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_PLUGIN_DYNAMIC],[
MYSQL_REQUIRE_PLUGIN([$1])
m4_define([MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]), [$2])
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_PLUGIN_MANDATORY
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN_MANDATORY([name])
dnl
dnl DESCRIPTION
dnl Marks the specified plugin as a mandatory plugin
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_PLUGIN_MANDATORY],[
MYSQL_REQUIRE_PLUGIN([$1])
_MYSQL_PLUGIN_MANDATORY([$1],
[MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1])
)
])
AC_DEFUN([_MYSQL_PLUGIN_MANDATORY],[
m4_define([$2], [yes])
m4_ifdef([$3], [
AC_FATAL([mandatory plugin $1 has been disabled])
m4_undefine([$2])
])
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_PLUGIN_DISABLED
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN_DISABLED([name])
dnl
dnl DESCRIPTION
dnl Marks the specified plugin as a disabled plugin
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_PLUGIN_DISABLED],[
MYSQL_REQUIRE_PLUGIN([$1])
_MYSQL_PLUGIN_DISABLED([$1],
[MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1])
)
])
AC_DEFUN([_MYSQL_PLUGIN_DISABLED],[
m4_define([$2], [yes])
m4_ifdef([$3], [
AC_FATAL([attempt to disable mandatory plugin $1])
m4_undefine([$2])
])
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_PLUGIN_DEPENDS
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN_DEPENDS([name],[prereq,prereq...])
dnl
dnl DESCRIPTION
dnl Enables other plugins neccessary for the named plugin
dnl Dependency checking is not recursive so if any
dnl required plugin requires further plugins, list them
dnl here too!
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_PLUGIN_DEPENDS],[
MYSQL_REQUIRE_PLUGIN([$1])
ifelse($#, 2, [
_MYSQL_PLUGIN_DEPEND([$1], $2)
], [
AC_FATAL([bad number of arguments])
])
])
AC_DEFUN([_MYSQL_PLUGIN_DEPEND],[
ifelse($#, 1, [], [$#:$2], [2:], [], [
MYSQL_REQUIRE_PLUGIN([$2])
_MYSQL_PLUGAPPEND([__mysql_plugdepends_$1__],[$2])
_MYSQL_PLUGIN_DEPEND([$1], m4_shift(m4_shift($@)))
])
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_PLUGIN_ACTIONS
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN_ACTIONS([name],[PLUGIN_CONFIGURE_STUFF])
dnl
dnl DESCRIPTION
dnl Declares additional autoconf actions required to configure the plugin
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_PLUGIN_ACTIONS],[
MYSQL_REQUIRE_PLUGIN([$1])
m4_ifdef([$2],[
m4_define([MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]),m4_defn([$2]))
],[
m4_define([MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]), [$2])
])
])
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CONFIGURE_PLUGINS
dnl
dnl SYNOPSIS
dnl MYSQL_PLUGIN_DEPENDS([name,name...])
dnl
dnl DESCRIPTION
dnl Used last, emits all required shell code to configure the plugins
dnl Argument is a list of default plugins or meta-plugin
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CONFIGURE_PLUGINS],[
m4_ifdef([__mysql_plugin_configured__],[
AC_FATAL([cannot use [MYSQL_CONFIGURE_PLUGINS] multiple times])
],[
m4_define([__mysql_plugin_configured__],[done])
m4_ifdef([__mysql_plugin_list__],[
_MYSQL_CHECK_PLUGIN_ARGS([$1])
_MYSQL_CONFIGURE_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
_MYSQL_EMIT_PLUGIN_ACTIONS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
AC_SUBST([mysql_se_dirs])
AC_SUBST([mysql_pg_dirs])
])
])
])
AC_DEFUN([_MYSQL_CONFIGURE_PLUGINS],[
ifelse($#, 0, [], $#, 1, [
_MYSQL_EMIT_CHECK_PLUGIN([$1])
],[
_MYSQL_EMIT_CHECK_PLUGIN([$1])
_MYSQL_CONFIGURE_PLUGINS(m4_shift($@))
])
])
AC_DEFUN([_MYSQL_EMIT_CHECK_PLUGIN],[
__MYSQL_EMIT_CHECK_PLUGIN(
[$1],
m4_bpatsubst([$1], -, _),
[MYSQL_PLUGIN_NAME_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DESC_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DEFINE_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DIRECTORY_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
)
])
AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
m4_ifdef([$5],[
AH_TEMPLATE($5, [Include ]$4[ into mysqld])
])
AC_MSG_CHECKING([whether to use ]$3)
mysql_use_plugin_dir=""
m4_ifdef([$10],[
if test "X[$mysql_plugin_]$2" = Xyes -a \
"X[$with_plugin_]$2" != Xno -o \
"X[$with_plugin_]$2" = Xyes; then
AC_MSG_RESULT([error])
AC_MSG_ERROR([disabled])
fi
AC_MSG_RESULT([no])
],[
m4_ifdef([$9],[
if test "X[$with_plugin_]$2" = Xno; then
AC_MSG_RESULT([error])
AC_MSG_ERROR([cannot disable mandatory plugin])
fi
[mysql_plugin_]$2=yes
])
if test "X[$with_plugin_]$2" = Xno; then
AC_MSG_RESULT([no])
else
m4_ifdef([$8],m4_ifdef([$7],[],[[with_plugin_]$2='']))
if test "X[$mysql_plugin_]$2" != Xyes -a \
"X[$with_plugin_]$2" != Xyes; then
m4_ifdef([$8],[
m4_ifdef([$6],[
if test -d "$srcdir/$6" ; then
mysql_use_plugin_dir="$6"
])
AC_SUBST([plugin_]$2[_shared_target], "$8")
AC_SUBST([plugin_]$2[_static_target], [""])
[with_plugin_]$2=yes
AC_MSG_RESULT([plugin])
m4_ifdef([$6],[
else
[mysql_plugin_]$2=no
AC_MSG_RESULT([no])
fi
])
],[
[with_plugin_]$2=no
AC_MSG_RESULT([no])
])
else
m4_ifdef([$7],[
ifelse(m4_bregexp($7, [^lib[^.]+\.a$]), -2, [
dnl change above "-2" to "0" to enable this section
dnl Although this is "pretty", it breaks libmysqld build
m4_ifdef([$6],[
mysql_use_plugin_dir="$6"
mysql_plugin_libs="$mysql_plugin_libs -L[\$(top_builddir)]/$6"
])
mysql_plugin_libs="$mysql_plugin_libs dnl
[-l]m4_bregexp($7, [^lib\([^.]+\)], [\1])"
], m4_bregexp($7, [^\\\$]), 0, [
m4_ifdef([$6],[
mysql_use_plugin_dir="$6"
])
mysql_plugin_libs="$mysql_plugin_libs $7"
], [
m4_ifdef([$6],[
mysql_use_plugin_dir="$6"
mysql_plugin_libs="$mysql_plugin_libs \$(top_builddir)/$6/$7"
],[
mysql_plugin_libs="$mysql_plugin_libs $7"
])
])
m4_ifdef([$5],[
AC_DEFINE($5)
])
AC_SUBST([plugin_]$2[_static_target], "$7")
AC_SUBST([plugin_]$2[_shared_target], [""])
],[
m4_ifdef([$6],[
AC_MSG_RESULT([error])
AC_MSG_ERROR([Plugin $1 does not support static linking])
],[
m4_ifdef([$5],[
AC_DEFINE($5)
AC_SUBST([plugin_]$2[_static_target], ["yes"])
AC_SUBST([plugin_]$2[_shared_target], [""])
])
])
])
mysql_plugin_defs="$mysql_plugin_defs, [builtin_]$2[_plugin]"
[with_plugin_]$2=yes
AC_MSG_RESULT([yes])
fi
m4_ifdef([$6],[
if test -n "$mysql_use_plugin_dir" ; then
mysql_plugin_dirs="$mysql_plugin_dirs $6"
if test -f "$srcdir/$6/configure" ; then
other_configures="$other_configures $6/configure"
else
AC_CONFIG_FILES($6/Makefile)
fi
ifelse(m4_substr($6, 0, 8), [storage/],
[mysql_se_dirs="$mysql_se_dirs ]m4_substr($6, 8)",
m4_substr($6, 0, 7), [plugin/],
[mysql_pg_dirs="$mysql_pg_dirs ]m4_substr($6, 7)",
[AC_FATAL([don't know how to handle plugin dir ]$6)])
fi
])
fi
])
])
AC_DEFUN([_MYSQL_EMIT_PLUGIN_ACTIONS],[
ifelse($#, 0, [], $#, 1, [
_MYSQL_EMIT_PLUGIN_ACTION([$1])
],[
_MYSQL_EMIT_PLUGIN_ACTION([$1])
_MYSQL_EMIT_PLUGIN_ACTIONS(m4_shift($@))
])
])
AC_DEFUN([_MYSQL_EMIT_PLUGIN_ACTION],[
__MYSQL_EMIT_PLUGIN_ACTION(
[$1],
m4_bpatsubst([$1], -, _),
[MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
)
])
AC_DEFUN([__MYSQL_EMIT_PLUGIN_ACTION],[
m4_ifdef([$3], [], [
if test "X[$with_plugin_]$2" = Xyes; then
if test "X[$plugin_]$2[_static_target]" = X -a \
"X[$plugin_]$2[_shared_target]" = X; then
AC_MSG_ERROR([that's strange, $1 failed sanity check])
fi
$4
fi
])
])
dnl ===========================================================================
dnl Private helper macros
dnl ===========================================================================
dnl SYNOPSIS
dnl MYSQL_REQUIRE_PLUGIN([name])
dnl
dnl DESCRIPTION
dnl Checks that the specified plugin does exist
AC_DEFUN([MYSQL_REQUIRE_PLUGIN],[
_MYSQL_REQUIRE_PLUGIN([$1], [__MYSQL_PLUGIN_]AS_TR_CPP([$1])[__])
])
define([_MYSQL_REQUIRE_PLUGIN],[
ifdef([$2],[
ifelse($2, [$1], [], [
AC_FATAL([Misspelt MYSQL_PLUGIN declaration for $1])
])
],[
AC_FATAL([Missing MYSQL_PLUGIN declaration for $1])
])
])
dnl ---------------------------------------------------------------------------
dnl SYNOPSIS
dnl _MYSQL_EMIT_METAPLUGINS([name,name...])
dnl
dnl DESCRIPTION
dnl Emits shell code for metaplugins
AC_DEFUN([_MYSQL_EMIT_METAPLUGINS], [ifelse($#, 0, [], $#, 1,
[_MYSQL_EMIT_METAPLUGIN([$1], [__mysql_]m4_bpatsubst($1, -, _)[_plugins__])
],
[_MYSQL_EMIT_METAPLUGIN([$1], [__mysql_]m4_bpatsubst($1, -, _)[_plugins__])
_MYSQL_EMIT_METAPLUGINS(m4_shift($@))])
])
AC_DEFUN([_MYSQL_EMIT_METAPLUGIN], [
[$1] )
m4_ifdef([$2], [
mysql_plugins='m4_bpatsubst($2, :, [ ])'
],[
mysql_plugins=''
])
;;
])
dnl ---------------------------------------------------------------------------
dnl SYNOPSIS
dnl _MYSQL_PLUGAPPEND([name],[to-append])
dnl
dnl DESCRIPTION
dnl Helper macro for appending to colon-delimited lists
dnl Optinal 3rd argument is for actions only required when defining
dnl macro named for the first time.
AC_DEFUN([_MYSQL_PLUGAPPEND],[
m4_ifdef([$1],[
m4_define([__plugin_append_tmp__], m4_defn([$1]))
m4_undefine([$1])
m4_define([$1], __plugin_append_tmp__[:$2])
m4_undefine([__plugin_append_tmp__])
],[
m4_define([$1], [$2])
$3
])
])
dnl SYNOPSIS
dnl _MYSQL_PLUGAPPEND_META([name],[meta,meta...])
dnl
dnl DESCRIPTION
dnl Helper macro for adding plugins to meta plugins
AC_DEFUN([_MYSQL_PLUGAPPEND_META],[
ifelse($#, 1, [], [$#:$2], [2:], [], [$2], [all], [
AC_FATAL([protected plugin group: all])
], [$2], [none], [
AC_FATAL([protected plugin group: none])
],[
_MYSQL_PLUGAPPEND([__mysql_$1_configs__],[$2])
_MYSQL_PLUGAPPEND([__mysql_]m4_bpatsubst($2, -, _)[_plugins__],[$1], [
_MYSQL_PLUGAPPEND([__mysql_metaplugin_list__],[$2])
])
_MYSQL_PLUGAPPEND_META([$1], m4_shift(m4_shift($@)))
])
])
dnl ---------------------------------------------------------------------------
dnl SYNOPSIS
dnl MYSQL_LIST_PLUGINS
dnl
dnl DESCRIPTION
dnl Emits formatted list of declared plugins
AC_DEFUN([MYSQL_LIST_PLUGINS],[dnl
m4_ifdef([__mysql_plugin_list__],[dnl
_MYSQL_LIST_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))dnl
])dnl
])
AC_DEFUN([_MYSQL_LIST_PLUGINS],[dnl
ifelse($#, 0, [], $#, 1, [dnl
MYSQL_SHOW_PLUGIN([$1])dnl
],[dnl
MYSQL_SHOW_PLUGIN([$1])dnl
_MYSQL_LIST_PLUGINS(m4_shift($@))dnl
])dnl
])
AC_DEFUN([MYSQL_SHOW_PLUGIN],[
_MYSQL_SHOW_PLUGIN(
[$1],
[$1-plugin],
[MYSQL_PLUGIN_NAME_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DESC_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DEFINE_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DIRECTORY_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]),
__mysql_[$1]_configs__,
)
])
AC_DEFUN([_MYSQL_SHOW_PLUGIN],[dnl
=== $3 ===
Plugin Name: [$1]
Description: $4
Supports build: _PLUGIN_BUILD_TYPE([$7],[$8])[]dnl
m4_ifdef([$12],[
Configurations: m4_bpatsubst($12, :, [, ])])[]dnl
m4_ifdef([$10],[
Status: disabled])[]dnl
m4_ifdef([$9],[
Status: mandatory])[]dnl
])
AC_DEFUN([_PLUGIN_BUILD_TYPE],
[m4_ifdef([$1],[static ]m4_ifdef([$2],[and dnl
]))[]m4_ifdef([$2],[dynamic],[m4_ifdef([$1],[],[static])])])
dnl ---------------------------------------------------------------------------
AC_DEFUN([_MYSQL_EMIT_PLUGINS],[
ifelse($#, 0, [], [$#:$1], [1:], [], [
m4_ifdef([MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]), [], [
m4_define([MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]),[ ])
])
[$1] )
m4_ifdef([MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),[
AC_MSG_ERROR([plugin $1 is disabled])
],[
_MYSQL_EMIT_PLUGIN_ENABLE([$1], m4_bpatsubst([$1], -, _),
[MYSQL_PLUGIN_NAME_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]),
[MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]))
])
;;
_MYSQL_EMIT_PLUGINS(m4_shift($@))
])
])
AC_DEFUN([_MYSQL_EMIT_PLUGIN_ENABLE],[
m4_ifdef([$5],m4_ifdef([$4],[
[mysql_plugin_]$2=yes
],[
AC_MSG_WARN([$3 can only be built as a plugin])
]),[
[mysql_plugin_]$2=yes
])
])
AC_DEFUN([_MYSQL_EMIT_PLUGIN_DEPENDS], [
ifelse($#, 0, [], [$#:$1], [1:], [], [
_MYSQL_EMIT_CHECK_DEPENDS(m4_bpatsubst([$1], -, _),
[__mysql_plugdepends_$1__])
_MYSQL_EMIT_PLUGIN_DEPENDS(m4_shift($@))
])
])
AC_DEFUN([_MYSQL_EMIT_CHECK_DEPENDS], [
m4_ifdef([$2], [
if test "X[$mysql_plugin_]$1" = Xyes -a \
"X[$with_plugin_]$1" != Xno -o \
"X[$with_plugin_]$1" = Xyes; then
_MYSQL_EMIT_PLUGIN_DEPENDENCIES(m4_bpatsubst($2, :, [,]))
fi
])
])
AC_DEFUN([_MYSQL_EMIT_PLUGIN_DEPENDENCIES], [
ifelse([$1], [], [], [
m4_ifdef([MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),[
AC_MSG_ERROR([depends upon disabled plugin $1])
],[
[mysql_plugin_]m4_bpatsubst([$1], -, _)=yes
if test "X[$with_plugin_]m4_bpatsubst([$1], -, _)" = Xno; then
AC_MSG_ERROR([depends upon disabled plugin $1])
fi
])
_MYSQL_EMIT_PLUGIN_DEPENDENCIES(m4_shift($@))
])
])
dnl SYNOPSIS
dnl _MYSQL_CHECK_PLUGIN_ARGS([plugin],[plugin]...)
dnl
dnl DESCRIPTION
dnl Emits shell script for checking configure arguments
dnl Arguments to this macro is default value for selected plugins
AC_DEFUN([_MYSQL_CHECK_PLUGIN_ARGS],[
__MYSQL_CHECK_PLUGIN_ARGS(m4_default([$1], [none]))
])
AC_DEFUN([__MYSQL_CHECK_PLUGIN_ARGS],[
AC_ARG_WITH([plugins],
AS_HELP_STRING([--with-plugins=PLUGIN[[[[[,PLUGIN..]]]]]],
[Plugins to include in mysqld. (default is: $1) Must be a
configuration name or a comma separated list of plugins.])
AS_HELP_STRING([],
[Available configurations are:] dnl
m4_bpatsubst([none:]m4_ifdef([__mysql_metaplugin_list__],
__mysql_metaplugin_list__:)[all], :, [ ])[.])
AS_HELP_STRING([],
[Available plugins are:] dnl
m4_bpatsubst(__mysql_plugin_list__, :, [ ])[.])
AS_HELP_STRING([--without-plugin-PLUGIN],
[Disable the named plugin from being built. Otherwise, for
plugins which are not selected for inclusion in mysqld will be
built dynamically (if supported)])
AS_HELP_STRING([--with-plugin-PLUGIN],
[Forces the named plugin to be linked into mysqld statically.]),
[mysql_plugins="`echo $withval | tr ',.:;*[]' ' '`"],
[mysql_plugins=['$1']])
m4_divert_once([HELP_VAR_END],[
Description of plugins:
MYSQL_LIST_PLUGINS])
case "$mysql_plugins" in
all )
mysql_plugins='m4_bpatsubst(__mysql_plugin_list__, :, [ ])'
;;
none )
mysql_plugins=''
;;
m4_ifdef([__mysql_metaplugin_list__],[
_MYSQL_EMIT_METAPLUGINS(m4_bpatsubst(__mysql_metaplugin_list__, :, [,]))
])
esac
for plugin in $mysql_plugins; do
case "$plugin" in
all | none )
AC_MSG_ERROR([bad plugin name: $plugin])
;;
_MYSQL_EMIT_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
* )
AC_MSG_ERROR([unknown plugin: $plugin])
;;
esac
done
_MYSQL_EMIT_PLUGIN_DEPENDS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
])
dnl ===========================================================================

View file

@ -1,55 +0,0 @@
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_STORAGE_ENGINE
dnl
dnl What it does:
dnl creates --with-xxx configure option
dnl adds HAVE_XXX to config.h
dnl appends &xxx_hton, to the list of hanldertons
dnl appends a dir to the list of source directories
dnl appends ha_xxx.cc to the list of handler files
dnl
dnl all names above are configurable with reasonable defaults.
dnl
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_STORAGE_ENGINE],
[_MYSQL_STORAGE_ENGINE(
[$1], dnl name
m4_default([$2], [$1 storage engine]), dnl verbose name
m4_default([$3], [$1-storage-engine]), dnl with-name
m4_default([$4], no), dnl default
m4_default([$5], [WITH_]AS_TR_CPP([$1])[_STORAGE_ENGINE]),
m4_default([$6], $1[_hton]), dnl hton
m4_default([$7], []), dnl path to the code
m4_default([$8], [ha_$1.o]), dnl path to the handler in
m4_default([$9], []), dnl path to extra libraries
[$10], dnl code-if-set
)])
AC_DEFUN([_MYSQL_STORAGE_ENGINE],
[
AC_ARG_WITH([$3], AS_HELP_STRING([--with-$3], [enable $2 (default is $4)]),
[], [ [with_]m4_bpatsubst([$3], -, _)=['$4']])
AC_CACHE_CHECK([whether to use $2], [mysql_cv_use_]m4_bpatsubst([$3], -, _),
[mysql_cv_use_]m4_bpatsubst([$3], -, _)=[$with_]m4_bpatsubst([$3], -, _))
AH_TEMPLATE([$5], [Build $2])
if test "[$mysql_cv_use_]m4_bpatsubst([$3], -, _)" != no; then
if test "$6" != "no"
then
AC_DEFINE([$5])
mysql_se_decls="${mysql_se_decls},$6"
mysql_se_htons="${mysql_se_htons},&$6"
if test "$8" != "no"
then
mysql_se_objs="$mysql_se_objs $8"
fi
mysql_se_dirs="$mysql_se_dirs $7"
mysql_se_libs="$mysql_se_libs $9"
else
mysql_se_plugins="$mysql_se_plugins $7"
fi
$10
fi
])
dnl ---------------------------------------------------------------------------

View file

@ -11,8 +11,11 @@ AC_DEFUN([MYSQL_CHECK_YASSL], [
AC_MSG_RESULT([using bundled yaSSL]) AC_MSG_RESULT([using bundled yaSSL])
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/benchmark/Makefile dnl
extra/yassl/taocrypt/src/Makefile dnl extra/yassl/taocrypt/src/Makefile dnl
extra/yassl/src/Makefile) extra/yassl/taocrypt/test/Makefile dnl
extra/yassl/src/Makefile dnl
extra/yassl/testsuite/Makefile)
yassl_dir="yassl" yassl_dir="yassl"
yassl_libs="-L\$(top_srcdir)/extra/yassl/src -lyassl -L\$(top_srcdir)/extra/yassl/taocrypt/src -ltaocrypt" yassl_libs="-L\$(top_srcdir)/extra/yassl/src -lyassl -L\$(top_srcdir)/extra/yassl/taocrypt/src -ltaocrypt"
yassl_includes="-I\$(top_srcdir)/extra/yassl/include" yassl_includes="-I\$(top_srcdir)/extra/yassl/include"

View file

@ -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"

View file

@ -31,7 +31,7 @@ sinclude(config/ac-macros/alloca.m4)
sinclude(config/ac-macros/check_cpu.m4) sinclude(config/ac-macros/check_cpu.m4)
sinclude(config/ac-macros/character_sets.m4) sinclude(config/ac-macros/character_sets.m4)
sinclude(config/ac-macros/compiler_flag.m4) sinclude(config/ac-macros/compiler_flag.m4)
sinclude(config/ac-macros/storage.m4) sinclude(config/ac-macros/plugins.m4)
sinclude(config/ac-macros/ha_berkeley.m4) sinclude(config/ac-macros/ha_berkeley.m4)
sinclude(config/ac-macros/ha_ndbcluster.m4) sinclude(config/ac-macros/ha_ndbcluster.m4)
sinclude(config/ac-macros/large_file.m4) sinclude(config/ac-macros/large_file.m4)
@ -51,7 +51,6 @@ romanian russian serbian slovak spanish swedish ukrainian"
##### #####
##### #####
AC_SUBST(MYSQL_NO_DASH_VERSION) AC_SUBST(MYSQL_NO_DASH_VERSION)
AC_SUBST(MYSQL_BASE_VERSION) AC_SUBST(MYSQL_BASE_VERSION)
AC_SUBST(MYSQL_VERSION_ID) AC_SUBST(MYSQL_VERSION_ID)
@ -196,6 +195,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
@ -207,6 +207,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
@ -482,7 +489,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=""
@ -705,9 +712,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))
@ -1616,7 +1622,7 @@ fi
# If we should allow error injection tests # If we should allow error injection tests
AC_ARG_WITH(error-inject, AC_ARG_WITH(error-inject,
[ --with-error-inject Enable error injection in MySQL Server], AC_HELP_STRING([--with-error-inject],[Enable error injection in MySQL Server]),
[ with_error_inject=$withval ], [ with_error_inject=$withval ],
[ with_error_inject=no ]) [ with_error_inject=no ])
@ -2189,6 +2195,102 @@ then
fi fi
AC_MSG_RESULT("$netinet_inc") AC_MSG_RESULT("$netinet_inc")
#--------------------------------------------------------------------
# Check for requested features
#--------------------------------------------------------------------
MYSQL_CHECK_BIG_TABLES
MYSQL_CHECK_MAX_INDEXES
MYSQL_CHECK_REPLICATION
MYSQL_CHECK_VIO
MYSQL_CHECK_OPENSSL
MYSQL_CHECK_YASSL
#--------------------------------------------------------------------
# Declare our plugin modules
# Has to be done late, as the plugin may need to check for existence of
# functions tested above
#--------------------------------------------------------------------
MYSQL_STORAGE_ENGINE(archive,, [Archive Storage Engine],
[Archive Storage Engine], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(archive, [storage/archive])
MYSQL_PLUGIN_STATIC(archive, [libarchive.a])
MYSQL_PLUGIN_DYNAMIC(archive, [ha_archive.la])
MYSQL_STORAGE_ENGINE(berkeley, berkeley-db, [BerkeleyDB Storage Engine],
[Transactional Tables using BerkeleyDB], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(berkeley,[storage/bdb])
MYSQL_PLUGIN_STATIC(berkeley, [[\$(bdb_libs_with_path)]])
MYSQL_PLUGIN_ACTIONS(berkeley, [MYSQL_SETUP_BERKELEY_DB])
MYSQL_STORAGE_ENGINE(blackhole,,[Blackhole Storage Engine],
[Basic Write-only Read-never tables], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(blackhole, [storage/blackhole])
MYSQL_PLUGIN_STATIC(blackhole, [libblackhole.a])
MYSQL_PLUGIN_DYNAMIC(blackhole, [ha_blackhole.la])
MYSQL_STORAGE_ENGINE(csv,, [CSV Storage Engine],
[Stores tables in text CSV format])
MYSQL_PLUGIN_DIRECTORY(csv, [storage/csv])
MYSQL_PLUGIN_STATIC(csv, [libcsv.a])
MYSQL_PLUGIN_MANDATORY(csv) dnl Used for logging
MYSQL_STORAGE_ENGINE(example,, [Example Storage Engine],
[Skeleton for Storage Engines for developers], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(example, [storage/example])
MYSQL_PLUGIN_STATIC(example, [libexample.a])
MYSQL_PLUGIN_DYNAMIC(example, [ha_example.la])
MYSQL_STORAGE_ENGINE(federated,,[Federated Storage Engine],
[Connects to tables on remote MySQL servers], [max,max-no-ndb])
MYSQL_PLUGIN(ftexample, [Simple Parser],
[Simple full-text parser plugin])
MYSQL_PLUGIN_DIRECTORY(ftexample, [plugin/fulltext])
MYSQL_PLUGIN_DYNAMIC(ftexample, [mypluglib.la])
MYSQL_STORAGE_ENGINE(heap,no, [Memory Storage Engine],
[Volatile memory based tables])
MYSQL_PLUGIN_DIRECTORY(heap, [storage/heap])
MYSQL_PLUGIN_STATIC(heap, [libheap.a])
MYSQL_PLUGIN_MANDATORY(heap) dnl Memory tables
MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
[Transactional Tables using InnoDB], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase])
MYSQL_PLUGIN_STATIC(innobase, [libinnobase.a])
MYSQL_PLUGIN_ACTIONS(innobase, [
AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
AC_SUBST(innodb_system_libs)
])
MYSQL_STORAGE_ENGINE(myisam,no, [MyISAM Storage Engine],
[Traditional non-transactional MySQL tables])
MYSQL_PLUGIN_DIRECTORY(myisam, [storage/myisam])
MYSQL_PLUGIN_STATIC(myisam, [libmyisam.a])
MYSQL_PLUGIN_MANDATORY(myisam) dnl Default
MYSQL_STORAGE_ENGINE(myisammrg,no,[MyISAM MERGE Engine],
[Merge multiple MySQL tables into one])
MYSQL_PLUGIN_DIRECTORY(myisammrg,[storage/myisammrg])
MYSQL_PLUGIN_STATIC(myisammrg, [libmyisammrg.a])
MYSQL_PLUGIN_MANDATORY(myisammrg)
MYSQL_STORAGE_ENGINE(ndbcluster, ndbcluster, [Cluster Storage Engine],
[High Availability Clustered tables], [max])
MYSQL_PLUGIN_DIRECTORY(ndbcluster,[storage/ndb])
MYSQL_PLUGIN_STATIC(ndbcluster, [[\$(ndbcluster_libs) \$(ndbcluster_system_libs) \$(NDB_SCI_LIBS)]])
MYSQL_PLUGIN_ACTIONS(ndbcluster,[MYSQL_SETUP_NDBCLUSTER])
MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support],
[MySQL Partitioning Support], [max,max-no-ndb])
dnl -- ndbcluster requires partition to be enabled
MYSQL_PLUGIN_DEPENDS(ndbcluster, [partition])
MYSQL_CONFIGURE_PLUGINS([none])
# Only build client code? # Only build client code?
AC_ARG_WITH(server, AC_ARG_WITH(server,
[ --without-server Only build the client.], [ --without-server Only build the client.],
@ -2242,21 +2344,18 @@ fi
tools_dirs="" tools_dirs=""
AC_ARG_WITH([mysqlmanager], AC_ARG_WITH([mysqlmanager],
AC_HELP_STRING([--with-mysqlmanager], [Build the mysqlmanager binary: yes/no (default: build if server is built.)]), AC_HELP_STRING([--with-mysqlmanager], [Build the mysqlmanager binary: yes/no (default: build if server is built.)]),,)
[if test "x${withval}" != "xno"; then
if test "$with_mysqlmanager" = "yes" -o \
'(' "$with_mysqlmanager:$with_server" = ":yes" -a \
-d "$srcdir/server-tools" ')' ; then
tools_dirs="$tools_dirs server-tools" tools_dirs="$tools_dirs server-tools"
fi], AC_CONFIG_FILES(server-tools/Makefile server-tools/instance-manager/Makefile)
[if test "x${with_server}" = "xyes"; then fi
tools_dirs="$tools_dirs server-tools"
fi]
)
AC_SUBST(tools_dirs) AC_SUBST(tools_dirs)
#MYSQL_CHECK_CPU #MYSQL_CHECK_CPU
MYSQL_CHECK_VIO
MYSQL_CHECK_OPENSSL
MYSQL_CHECK_YASSL
libmysqld_dirs= libmysqld_dirs=
linked_libmysqld_targets= linked_libmysqld_targets=
@ -2421,73 +2520,6 @@ AC_SUBST(readline_basedir)
AC_SUBST(readline_link) AC_SUBST(readline_link)
AC_SUBST(readline_h_ln_cmd) AC_SUBST(readline_h_ln_cmd)
MYSQL_CHECK_BIG_TABLES
MYSQL_CHECK_MAX_INDEXES
MYSQL_CHECK_REPLICATION
MYSQL_STORAGE_ENGINE(innobase,,innodb,,,,innobase,ha_innodb.o,[ dnl
\$(top_builddir)/storage/innobase/usr/libusr.a dnl
\$(top_builddir)/storage/innobase/srv/libsrv.a dnl
\$(top_builddir)/storage/innobase/dict/libdict.a dnl
\$(top_builddir)/storage/innobase/que/libque.a dnl
\$(top_builddir)/storage/innobase/srv/libsrv.a dnl
\$(top_builddir)/storage/innobase/ibuf/libibuf.a dnl
\$(top_builddir)/storage/innobase/row/librow.a dnl
\$(top_builddir)/storage/innobase/pars/libpars.a dnl
\$(top_builddir)/storage/innobase/btr/libbtr.a dnl
\$(top_builddir)/storage/innobase/trx/libtrx.a dnl
\$(top_builddir)/storage/innobase/read/libread.a dnl
\$(top_builddir)/storage/innobase/usr/libusr.a dnl
\$(top_builddir)/storage/innobase/buf/libbuf.a dnl
\$(top_builddir)/storage/innobase/ibuf/libibuf.a dnl
\$(top_builddir)/storage/innobase/eval/libeval.a dnl
\$(top_builddir)/storage/innobase/log/liblog.a dnl
\$(top_builddir)/storage/innobase/fsp/libfsp.a dnl
\$(top_builddir)/storage/innobase/fut/libfut.a dnl
\$(top_builddir)/storage/innobase/fil/libfil.a dnl
\$(top_builddir)/storage/innobase/lock/liblock.a dnl
\$(top_builddir)/storage/innobase/mtr/libmtr.a dnl
\$(top_builddir)/storage/innobase/page/libpage.a dnl
\$(top_builddir)/storage/innobase/rem/librem.a dnl
\$(top_builddir)/storage/innobase/thr/libthr.a dnl
\$(top_builddir)/storage/innobase/sync/libsync.a dnl
\$(top_builddir)/storage/innobase/data/libdata.a dnl
\$(top_builddir)/storage/innobase/mach/libmach.a dnl
\$(top_builddir)/storage/innobase/ha/libha.a dnl
\$(top_builddir)/storage/innobase/dyn/libdyn.a dnl
\$(top_builddir)/storage/innobase/mem/libmem.a dnl
\$(top_builddir)/storage/innobase/sync/libsync.a dnl
\$(top_builddir)/storage/innobase/ut/libut.a dnl
\$(top_builddir)/storage/innobase/os/libos.a dnl
\$(top_builddir)/storage/innobase/ut/libut.a],[
AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
AC_SUBST(innodb_includes)
AC_SUBST(innodb_libs)
AC_SUBST(innodb_system_libs)
other_configures="$other_configures storage/innobase/configure"
])
MYSQL_STORAGE_ENGINE(berkeley,,berkeley-db,,,,bdb,,,[
MYSQL_SETUP_BERKELEY_DB
])
MYSQL_STORAGE_ENGINE(example,,,,,,example,no,
\$(top_builddir)/storage/example/libexample.a,[
AC_CONFIG_FILES(storage/example/Makefile)
])
MYSQL_STORAGE_ENGINE(archive,,,,,,archive,,
\$(top_builddir)/storage/archive/libarchive.a, [
AC_CONFIG_FILES(storage/archive/Makefile)
])
MYSQL_STORAGE_ENGINE(csv,,,"yes",,tina_hton,csv,no,
\$(top_builddir)/storage/csv/libcsv.a,[
AC_CONFIG_FILES(storage/csv/Makefile)
])
MYSQL_STORAGE_ENGINE(blackhole)
MYSQL_STORAGE_ENGINE(federated)
MYSQL_STORAGE_ENGINE(ndbcluster,,ndbcluster,,,,ndb,,,[
MYSQL_SETUP_NDBCLUSTER
])
MYSQL_STORAGE_ENGINE(partition,,partition)
# If we have threads generate some library functions and test programs # If we have threads generate some library functions and test programs
sql_server_dirs= sql_server_dirs=
@ -2544,7 +2576,7 @@ then
AC_SUBST(THREAD_LOBJECTS) AC_SUBST(THREAD_LOBJECTS)
server_scripts="mysqld_safe mysql_install_db" server_scripts="mysqld_safe mysql_install_db"
sql_server_dirs="strings mysys dbug extra regex" sql_server_dirs="strings mysys dbug extra regex"
mysql_se_dirs="myisam myisammrg heap $mysql_se_dirs"
sql_server="$sql_server vio sql" sql_server="$sql_server vio sql"
fi fi
@ -2560,12 +2592,9 @@ AC_SUBST(sql_server)
AC_SUBST(thread_dirs) AC_SUBST(thread_dirs)
AC_SUBST(server_scripts) AC_SUBST(server_scripts)
AC_SUBST(mysql_se_dirs) AC_SUBST(mysql_plugin_dirs)
AC_SUBST(mysql_se_libs) AC_SUBST(mysql_plugin_libs)
AC_SUBST(mysql_se_objs) AC_SUBST(mysql_plugin_defs)
AC_SUBST(mysql_se_htons)
AC_SUBST(mysql_se_decls)
AC_SUBST(mysql_se_plugins)
# Now that sql_client_dirs and sql_server_dirs are stable, determine the union. # Now that sql_client_dirs and sql_server_dirs are stable, determine the union.
@ -2607,25 +2636,18 @@ AC_SUBST(MAKE_BINARY_DISTRIBUTION_OPTIONS)
# Output results # Output results
AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl
unittest/Makefile dnl unittest/Makefile unittest/mytap/Makefile unittest/mytap/t/Makefile dnl
unittest/mytap/Makefile unittest/mytap/t/Makefile dnl
unittest/mysys/Makefile unittest/examples/Makefile dnl unittest/mysys/Makefile unittest/examples/Makefile dnl
strings/Makefile regex/Makefile storage/Makefile storage/heap/Makefile dnl strings/Makefile regex/Makefile storage/Makefile dnl
storage/myisam/Makefile storage/myisammrg/Makefile dnl
man/Makefile BUILD/Makefile vio/Makefile dnl man/Makefile BUILD/Makefile vio/Makefile dnl
libmysql/Makefile client/Makefile dnl libmysql/Makefile client/Makefile dnl
pstack/Makefile pstack/aout/Makefile sql/Makefile sql/share/Makefile dnl pstack/Makefile pstack/aout/Makefile sql/Makefile sql/share/Makefile dnl
sql/handlerton.cc sql-common/Makefile dnl sql/sql_builtin.cc sql-common/Makefile dnl
dbug/Makefile scripts/Makefile dnl dbug/Makefile scripts/Makefile include/Makefile dnl
include/Makefile dnl
server-tools/Makefile server-tools/instance-manager/Makefile dnl
tests/Makefile Docs/Makefile support-files/Makefile dnl tests/Makefile Docs/Makefile support-files/Makefile dnl
support-files/MacOSX/Makefile mysql-test/Makefile dnl support-files/MacOSX/Makefile mysql-test/Makefile dnl
mysql-test/ndb/Makefile netware/Makefile dnl mysql-test/ndb/Makefile netware/Makefile dnl
include/mysql_version.h dnl include/mysql_version.h plugin/Makefile win/Makefile)
plugin/Makefile dnl
plugin/fulltext/Makefile dnl
win/Makefile)
AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h) AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h)
AC_OUTPUT AC_OUTPUT

View file

@ -1,3 +1,3 @@
SUBDIRS = taocrypt src SUBDIRS = taocrypt src testsuite
EXTRA_DIST = yassl.dsp yassl.dsw yassl.vcproj $(wildcard mySTL/*.hpp) \ EXTRA_DIST = yassl.dsp yassl.dsw yassl.vcproj $(wildcard mySTL/*.hpp) \
cmakelists.txt cmakelists.txt

View file

@ -1,4 +1,137 @@
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

View file

@ -0,0 +1,96 @@
/* 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

View file

@ -0,0 +1,102 @@
# 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

View file

@ -0,0 +1,89 @@
/* 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

View file

@ -0,0 +1,102 @@
# 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

View file

@ -0,0 +1,93 @@
/* 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;
}

View file

@ -0,0 +1,2 @@
quit

View file

@ -0,0 +1,126 @@
/* 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;
}

View file

@ -0,0 +1,102 @@
# 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

View file

@ -0,0 +1,73 @@
/* 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

View file

@ -0,0 +1,109 @@
# 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

View file

@ -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:
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:

View file

@ -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:
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;

View file

@ -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" {
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*);
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,

View file

@ -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);

View file

@ -0,0 +1,88 @@
/* 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

View file

@ -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 {

View file

@ -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);

View file

@ -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();
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:
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:
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&);

View file

@ -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> template<typename T>
void ysDelete(T* ptr) 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)
(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
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

View file

@ -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 @@
typedef Dummy* yassl_pointer; typedef Dummy* yassl_pointer;
namespace mySTL { namespace mySTL {

View file

@ -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()
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()
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
} }
// 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()
// 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)
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;
} }

View file

@ -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()
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()
//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
} }
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()
} }
void CertManager::setVerifyNone()
{
verifyNone_ = true;
}
void CertManager::setFailNoCert() void CertManager::setFailNoCert()
{ {
failNoCert_ = true; failNoCert_ = true;
@ -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)
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()
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()
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()
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;

View file

@ -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 {
}; };
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 {
}; };
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 {
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 {
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 {
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 {
}; };
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 {
}; };
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 {
}; };
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 {
}; };
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 {
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)
// 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)
// 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 {
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 {
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 {
/* /*
// 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)
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,
// 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_); }
// 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)
} }
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)
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);

View file

@ -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,
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,
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,
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)
} }
// 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)
// 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)
buffered = tmp; buffered = tmp;
else else
break; break;
if (ssl.GetError()) return;
} }
} }
@ -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)
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)
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)
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)
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)
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)
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)
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)
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);

27
extra/yassl/src/make.bat Normal file
View file

@ -0,0 +1,27 @@
# 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

View file

@ -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
@ -101,7 +103,7 @@ uint Socket::get_ready() const
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
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);
} }

View file

@ -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()
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()
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)
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)
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)
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)
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)
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)
} }
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)
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*/)
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
{} {}
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)
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*/)
} }
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 */)
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;
} }

View file

@ -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*>;

View file

@ -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 {
#else // _WIN32 #else // _WIN32
#include <sys/time.h>
timer_d timer() timer_d timer()
{ {
struct timeval tv; struct timeval tv;

244
extra/yassl/src/yassl.cpp Normal file
View file

@ -0,0 +1,244 @@
/* 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

View file

@ -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
} }
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

View file

@ -29,6 +29,7 @@
#include "asn.hpp" // provide crypto wrapper?? #include "asn.hpp" // provide crypto wrapper??
namespace yaSSL { namespace yaSSL {
@ -111,10 +112,14 @@ void ClientDiffieHellmanPublic::build(SSL& ssl)
uint keyLength = dhClient.get_agreedKeyLength(); // pub and agree same uint keyLength = dhClient.get_agreedKeyLength(); // pub and agree same
alloc(keyLength, true); alloc(keyLength, true);
dhClient.makeAgreement(dhServer.get_publicKey()); dhClient.makeAgreement(dhServer.get_publicKey(), keyLength);
c16toa(keyLength, Yc_); c16toa(keyLength, Yc_);
memcpy(Yc_ + KEY_OFFSET, dhClient.get_publicKey(), keyLength); memcpy(Yc_ + KEY_OFFSET, dhClient.get_publicKey(), keyLength);
// because of encoding first byte might be zero, don't use it for preMaster
if (*dhClient.get_agreedKey() == 0)
ssl.set_preMaster(dhClient.get_agreedKey() + 1, keyLength - 1);
else
ssl.set_preMaster(dhClient.get_agreedKey(), keyLength); ssl.set_preMaster(dhClient.get_agreedKey(), keyLength);
} }
@ -134,10 +139,10 @@ void DH_Server::build(SSL& ssl)
const CertManager& cert = ssl.getCrypto().get_certManager(); const CertManager& cert = ssl.getCrypto().get_certManager();
if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo)
auth.reset(new (ys) RSA(cert.get_privateKey(), auth.reset(NEW_YS RSA(cert.get_privateKey(),
cert.get_privateKeyLength(), false)); cert.get_privateKeyLength(), false));
else { else {
auth.reset(new (ys) DSS(cert.get_privateKey(), auth.reset(NEW_YS DSS(cert.get_privateKey(),
cert.get_privateKeyLength(), false)); cert.get_privateKeyLength(), false));
sigSz += DSS_ENCODED_EXTRA; sigSz += DSS_ENCODED_EXTRA;
} }
@ -168,7 +173,7 @@ void DH_Server::build(SSL& ssl)
byte hash[FINISHED_SZ]; byte hash[FINISHED_SZ];
MD5 md5; MD5 md5;
SHA sha; SHA sha;
signature_ = new (ys) byte[sigSz]; signature_ = NEW_YS byte[sigSz];
const Connection& conn = ssl.getSecurity().get_connection(); const Connection& conn = ssl.getSecurity().get_connection();
// md5 // md5
@ -199,7 +204,7 @@ void DH_Server::build(SSL& ssl)
tmp.write(signature_, sigSz); tmp.write(signature_, sigSz);
// key message // key message
keyMessage_ = new (ys) opaque[length_]; keyMessage_ = NEW_YS opaque[length_];
memcpy(keyMessage_, tmp.get_buffer(), tmp.get_size()); memcpy(keyMessage_, tmp.get_buffer(), tmp.get_size());
} }
@ -253,7 +258,7 @@ opaque* EncryptedPreMasterSecret::get_clientKey() const
void EncryptedPreMasterSecret::alloc(int sz) void EncryptedPreMasterSecret::alloc(int sz)
{ {
length_ = sz; length_ = sz;
secret_ = new (ys) opaque[sz]; secret_ = NEW_YS opaque[sz];
} }
@ -269,10 +274,14 @@ void ClientDiffieHellmanPublic::read(SSL& ssl, input_buffer& input)
ato16(tmp, keyLength); ato16(tmp, keyLength);
alloc(keyLength); alloc(keyLength);
input.read(Yc_, length_); input.read(Yc_, keyLength);
dh.makeAgreement(Yc_); dh.makeAgreement(Yc_, keyLength);
ssl.set_preMaster(dh.get_agreedKey(), keyLength); // because of encoding, first byte might be 0, don't use for preMaster
if (*dh.get_agreedKey() == 0)
ssl.set_preMaster(dh.get_agreedKey() + 1, dh.get_agreedKeyLength() - 1);
else
ssl.set_preMaster(dh.get_agreedKey(), dh.get_agreedKeyLength());
ssl.makeMasterSecret(); ssl.makeMasterSecret();
} }
@ -303,7 +312,7 @@ opaque* ClientDiffieHellmanPublic::get_clientKey() const
void ClientDiffieHellmanPublic::alloc(int sz, bool offset) void ClientDiffieHellmanPublic::alloc(int sz, bool offset)
{ {
length_ = sz + (offset ? KEY_OFFSET : 0); length_ = sz + (offset ? KEY_OFFSET : 0);
Yc_ = new (ys) opaque[length_]; Yc_ = NEW_YS opaque[length_];
} }
@ -348,7 +357,7 @@ void DH_Server::read(SSL& ssl, input_buffer& input)
tmp[1] = input[AUTO]; tmp[1] = input[AUTO];
ato16(tmp, length); ato16(tmp, length);
signature_ = new (ys) byte[length]; signature_ = NEW_YS byte[length];
input.read(signature_, length); input.read(signature_, length);
// verify signature // verify signature
@ -386,7 +395,7 @@ void DH_Server::read(SSL& ssl, input_buffer& input)
} }
// save input // save input
ssl.useCrypto().SetDH(new (ys) DiffieHellman(parms_.get_p(), ssl.useCrypto().SetDH(NEW_YS DiffieHellman(parms_.get_p(),
parms_.get_pSize(), parms_.get_g(), parms_.get_gSize(), parms_.get_pSize(), parms_.get_g(), parms_.get_gSize(),
parms_.get_pub(), parms_.get_pubSize(), parms_.get_pub(), parms_.get_pubSize(),
ssl.getCrypto().get_random())); ssl.getCrypto().get_random()));
@ -438,7 +447,7 @@ void Parameters::SetSuites(ProtocolVersion pv)
int i = 0; int i = 0;
// available suites, best first // available suites, best first
// when adding more, make sure cipher_names is updated and // when adding more, make sure cipher_names is updated and
// MAX_CIPHER_LIST is big enough // MAX_CIPHERS is big enough
if (isTLS(pv)) { if (isTLS(pv)) {
suites_[i++] = 0x00; suites_[i++] = 0x00;
@ -510,13 +519,10 @@ void Parameters::SetCipherNames()
for (int j = 0; j < suites; j++) { for (int j = 0; j < suites; j++) {
int index = suites_[j*2 + 1]; // every other suite is suite id int index = suites_[j*2 + 1]; // every other suite is suite id
int len = strlen(cipher_names[index]); int len = strlen(cipher_names[index]) + 1;
memcpy(&cipher_list_[pos], cipher_names[index], len); strncpy(cipher_list_[pos++], cipher_names[index], len);
pos += len;
cipher_list_[pos++] = ':';
} }
if (suites) cipher_list_[pos][0] = 0;
cipher_list_[--pos] = 0;
} }
@ -928,7 +934,7 @@ void Data::Process(input_buffer& input, SSL& ssl)
// read data // read data
if (dataSz) { if (dataSz) {
input_buffer* data; input_buffer* data;
ssl.addData(data = new (ys) input_buffer(dataSz)); ssl.addData(data = NEW_YS input_buffer(dataSz));
input.read(data->get_buffer(), dataSz); input.read(data->get_buffer(), dataSz);
data->add_size(dataSz); data->add_size(dataSz);
@ -1025,7 +1031,7 @@ void Certificate::Process(input_buffer& input, SSL& ssl)
c24to32(tmp, cert_sz); c24to32(tmp, cert_sz);
x509* myCert; x509* myCert;
cm.AddPeerCert(myCert = new (ys) x509(cert_sz)); cm.AddPeerCert(myCert = NEW_YS x509(cert_sz));
input.read(myCert->use_buffer(), myCert->get_length()); input.read(myCert->use_buffer(), myCert->get_length());
list_sz -= cert_sz + CERT_HEADER; list_sz -= cert_sz + CERT_HEADER;
@ -1111,21 +1117,21 @@ const opaque* ServerDHParams::get_pub() const
opaque* ServerDHParams::alloc_p(int sz) opaque* ServerDHParams::alloc_p(int sz)
{ {
p_ = new (ys) opaque[pSz_ = sz]; p_ = NEW_YS opaque[pSz_ = sz];
return p_; return p_;
} }
opaque* ServerDHParams::alloc_g(int sz) opaque* ServerDHParams::alloc_g(int sz)
{ {
g_ = new (ys) opaque[gSz_ = sz]; g_ = NEW_YS opaque[gSz_ = sz];
return g_; return g_;
} }
opaque* ServerDHParams::alloc_pub(int sz) opaque* ServerDHParams::alloc_pub(int sz)
{ {
Ys_ = new (ys) opaque[pubSz_ = sz]; Ys_ = NEW_YS opaque[pubSz_ = sz];
return Ys_; return Ys_;
} }
@ -1323,6 +1329,7 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello)
// Compression // Compression
hello.comp_len_ = input[AUTO]; hello.comp_len_ = input[AUTO];
while (hello.comp_len_--) // ignore for now
hello.compression_methods_ = CompressionMethod(input[AUTO]); hello.compression_methods_ = CompressionMethod(input[AUTO]);
return input; return input;
@ -1537,7 +1544,7 @@ void CertificateRequest::Build()
for (int j = 0; j < authCount; j++) { for (int j = 0; j < authCount; j++) {
int sz = REQUEST_HEADER + MIN_DIS_SIZE; int sz = REQUEST_HEADER + MIN_DIS_SIZE;
DistinguishedName dn; DistinguishedName dn;
certificate_authorities_.push_back(dn = new (ys) byte[sz]); certificate_authorities_.push_back(dn = NEW_YS byte[sz]);
opaque tmp[REQUEST_HEADER]; opaque tmp[REQUEST_HEADER];
c16toa(MIN_DIS_SIZE, tmp); c16toa(MIN_DIS_SIZE, tmp);
@ -1584,7 +1591,7 @@ input_buffer& operator>>(input_buffer& input, CertificateRequest& request)
ato16(tmp, dnSz); ato16(tmp, dnSz);
DistinguishedName dn; DistinguishedName dn;
request.certificate_authorities_.push_back(dn = new (ys) request.certificate_authorities_.push_back(dn = NEW_YS
byte[REQUEST_HEADER + dnSz]); byte[REQUEST_HEADER + dnSz]);
memcpy(dn, tmp, REQUEST_HEADER); memcpy(dn, tmp, REQUEST_HEADER);
input.read(&dn[REQUEST_HEADER], dnSz); input.read(&dn[REQUEST_HEADER], dnSz);
@ -1630,7 +1637,11 @@ output_buffer& operator<<(output_buffer& output,
// CertificateRequest processing handler // CertificateRequest processing handler
void CertificateRequest::Process(input_buffer&, SSL& ssl) void CertificateRequest::Process(input_buffer&, SSL& ssl)
{ {
ssl.useCrypto().use_certManager().setSendVerify(); CertManager& cm = ssl.useCrypto().use_certManager();
// make sure user provided cert and key before sending and using
if (cm.get_cert() && cm.get_privateKey())
cm.setSendVerify();
} }
@ -1665,7 +1676,7 @@ void CertificateVerify::Build(SSL& ssl)
RSA rsa(cert.get_privateKey(), cert.get_privateKeyLength(), false); RSA rsa(cert.get_privateKey(), cert.get_privateKeyLength(), false);
sz = rsa.get_cipherLength() + VERIFY_HEADER; sz = rsa.get_cipherLength() + VERIFY_HEADER;
sig.reset(new (ys) byte[sz]); sig.reset(NEW_YS byte[sz]);
c16toa(sz - VERIFY_HEADER, len); c16toa(sz - VERIFY_HEADER, len);
memcpy(sig.get(), len, VERIFY_HEADER); memcpy(sig.get(), len, VERIFY_HEADER);
@ -1676,7 +1687,7 @@ void CertificateVerify::Build(SSL& ssl)
DSS dss(cert.get_privateKey(), cert.get_privateKeyLength(), false); DSS dss(cert.get_privateKey(), cert.get_privateKeyLength(), false);
sz = DSS_SIG_SZ + DSS_ENCODED_EXTRA + VERIFY_HEADER; sz = DSS_SIG_SZ + DSS_ENCODED_EXTRA + VERIFY_HEADER;
sig.reset(new (ys) byte[sz]); sig.reset(NEW_YS byte[sz]);
c16toa(sz - VERIFY_HEADER, len); c16toa(sz - VERIFY_HEADER, len);
memcpy(sig.get(), len, VERIFY_HEADER); memcpy(sig.get(), len, VERIFY_HEADER);
@ -1714,7 +1725,7 @@ input_buffer& operator>>(input_buffer& input, CertificateVerify& request)
ato16(tmp, sz); ato16(tmp, sz);
request.set_length(sz); request.set_length(sz);
request.signature_ = new (ys) byte[sz]; request.signature_ = NEW_YS byte[sz];
input.read(request.signature_, sz); input.read(request.signature_, sz);
return input; return input;
@ -1975,7 +1986,7 @@ Connection::~Connection()
void Connection::AllocPreSecret(uint sz) void Connection::AllocPreSecret(uint sz)
{ {
pre_master_secret_ = new (ys) opaque[pre_secret_len_ = sz]; pre_master_secret_ = NEW_YS opaque[pre_secret_len_ = sz];
} }
@ -2011,35 +2022,35 @@ void Connection::CleanPreMaster()
// Create functions for message factory // Create functions for message factory
Message* CreateCipherSpec() { return new (ys) ChangeCipherSpec; } Message* CreateCipherSpec() { return NEW_YS ChangeCipherSpec; }
Message* CreateAlert() { return new (ys) Alert; } Message* CreateAlert() { return NEW_YS Alert; }
Message* CreateHandShake() { return new (ys) HandShakeHeader; } Message* CreateHandShake() { return NEW_YS HandShakeHeader; }
Message* CreateData() { return new (ys) Data; } Message* CreateData() { return NEW_YS Data; }
// Create functions for handshake factory // Create functions for handshake factory
HandShakeBase* CreateHelloRequest() { return new (ys) HelloRequest; } HandShakeBase* CreateHelloRequest() { return NEW_YS HelloRequest; }
HandShakeBase* CreateClientHello() { return new (ys) ClientHello; } HandShakeBase* CreateClientHello() { return NEW_YS ClientHello; }
HandShakeBase* CreateServerHello() { return new (ys) ServerHello; } HandShakeBase* CreateServerHello() { return NEW_YS ServerHello; }
HandShakeBase* CreateCertificate() { return new (ys) Certificate; } HandShakeBase* CreateCertificate() { return NEW_YS Certificate; }
HandShakeBase* CreateServerKeyExchange() { return new (ys) ServerKeyExchange;} HandShakeBase* CreateServerKeyExchange() { return NEW_YS ServerKeyExchange;}
HandShakeBase* CreateCertificateRequest() { return new (ys) HandShakeBase* CreateCertificateRequest() { return NEW_YS
CertificateRequest; } CertificateRequest; }
HandShakeBase* CreateServerHelloDone() { return new (ys) ServerHelloDone; } HandShakeBase* CreateServerHelloDone() { return NEW_YS ServerHelloDone; }
HandShakeBase* CreateCertificateVerify() { return new (ys) CertificateVerify;} HandShakeBase* CreateCertificateVerify() { return NEW_YS CertificateVerify;}
HandShakeBase* CreateClientKeyExchange() { return new (ys) ClientKeyExchange;} HandShakeBase* CreateClientKeyExchange() { return NEW_YS ClientKeyExchange;}
HandShakeBase* CreateFinished() { return new (ys) Finished; } HandShakeBase* CreateFinished() { return NEW_YS Finished; }
// Create functions for server key exchange factory // Create functions for server key exchange factory
ServerKeyBase* CreateRSAServerKEA() { return new (ys) RSA_Server; } ServerKeyBase* CreateRSAServerKEA() { return NEW_YS RSA_Server; }
ServerKeyBase* CreateDHServerKEA() { return new (ys) DH_Server; } ServerKeyBase* CreateDHServerKEA() { return NEW_YS DH_Server; }
ServerKeyBase* CreateFortezzaServerKEA() { return new (ys) Fortezza_Server; } ServerKeyBase* CreateFortezzaServerKEA() { return NEW_YS Fortezza_Server; }
// Create functions for client key exchange factory // Create functions for client key exchange factory
ClientKeyBase* CreateRSAClient() { return new (ys) ClientKeyBase* CreateRSAClient() { return NEW_YS
EncryptedPreMasterSecret; } EncryptedPreMasterSecret; }
ClientKeyBase* CreateDHClient() { return new (ys) ClientKeyBase* CreateDHClient() { return NEW_YS
ClientDiffieHellmanPublic; } ClientDiffieHellmanPublic; }
ClientKeyBase* CreateFortezzaClient() { return new (ys) FortezzaKeys; } ClientKeyBase* CreateFortezzaClient() { return NEW_YS FortezzaKeys; }
// Constructor calls this to Register compile time callbacks // Constructor calls this to Register compile time callbacks

View file

@ -31,40 +31,41 @@
#include "openssl/ssl.h" // for DH #include "openssl/ssl.h" // for DH
void* operator new(size_t sz, yaSSL::new_t)
{
#ifdef YASSL_PURE_C #ifdef YASSL_PURE_C
void* operator new(size_t sz, yaSSL::new_t)
{
void* ptr = malloc(sz ? sz : 1); void* ptr = malloc(sz ? sz : 1);
if (!ptr) abort(); if (!ptr) abort();
return ptr; return ptr;
#else }
return ::operator new(sz);
#endif
}
void operator delete(void* ptr, yaSSL::new_t) void operator delete(void* ptr, yaSSL::new_t)
{ {
#ifdef YASSL_PURE_C
if (ptr) free(ptr); if (ptr) free(ptr);
#else }
::operator delete(ptr);
#endif
}
void* operator new[](size_t sz, yaSSL::new_t nt) void* operator new[](size_t sz, yaSSL::new_t nt)
{ {
return ::operator new(sz, nt); return ::operator new(sz, nt);
} }
void operator delete[](void* ptr, yaSSL::new_t nt) void operator delete[](void* ptr, yaSSL::new_t nt)
{ {
::operator delete(ptr, nt); ::operator delete(ptr, nt);
} }
namespace yaSSL {
new_t ys; // for yaSSL library new
}
#endif // YASSL_PURE_C
namespace yaSSL { namespace yaSSL {
@ -72,7 +73,6 @@ namespace yaSSL {
using mySTL::min; using mySTL::min;
new_t ys; // for yaSSL library new
@ -286,6 +286,8 @@ SSL::SSL(SSL_CTX* ctx)
if (ctx->getMethod()->verifyPeer()) if (ctx->getMethod()->verifyPeer())
cm.setVerifyPeer(); cm.setVerifyPeer();
if (ctx->getMethod()->verifyNone())
cm.setVerifyNone();
if (ctx->getMethod()->failNoCert()) if (ctx->getMethod()->failNoCert())
cm.setFailNoCert(); cm.setFailNoCert();
@ -321,8 +323,8 @@ void SSL::set_pending(Cipher suite)
parms.key_size_ = AES_256_KEY_SZ; parms.key_size_ = AES_256_KEY_SZ;
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));
strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_256_CBC_SHA], strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_256_CBC_SHA],
MAX_SUITE_NAME); MAX_SUITE_NAME);
break; break;
@ -335,8 +337,8 @@ void SSL::set_pending(Cipher suite)
parms.key_size_ = AES_128_KEY_SZ; parms.key_size_ = AES_128_KEY_SZ;
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) AES); crypto_.setCipher(NEW_YS AES);
strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_128_CBC_SHA], strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_128_CBC_SHA],
MAX_SUITE_NAME); MAX_SUITE_NAME);
break; break;
@ -349,8 +351,8 @@ void SSL::set_pending(Cipher suite)
parms.key_size_ = DES_EDE_KEY_SZ; parms.key_size_ = DES_EDE_KEY_SZ;
parms.iv_size_ = DES_IV_SZ; parms.iv_size_ = DES_IV_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) DES_EDE); crypto_.setCipher(NEW_YS DES_EDE);
strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_3DES_EDE_CBC_SHA] strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_3DES_EDE_CBC_SHA]
, MAX_SUITE_NAME); , MAX_SUITE_NAME);
break; break;
@ -363,8 +365,8 @@ void SSL::set_pending(Cipher suite)
parms.key_size_ = DES_KEY_SZ; parms.key_size_ = DES_KEY_SZ;
parms.iv_size_ = DES_IV_SZ; parms.iv_size_ = DES_IV_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) DES); crypto_.setCipher(NEW_YS DES);
strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_DES_CBC_SHA], strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_DES_CBC_SHA],
MAX_SUITE_NAME); MAX_SUITE_NAME);
break; break;
@ -377,8 +379,8 @@ void SSL::set_pending(Cipher suite)
parms.key_size_ = RC4_KEY_SZ; parms.key_size_ = RC4_KEY_SZ;
parms.iv_size_ = 0; parms.iv_size_ = 0;
parms.cipher_type_ = stream; parms.cipher_type_ = stream;
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) RC4); crypto_.setCipher(NEW_YS RC4);
strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_SHA], strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_SHA],
MAX_SUITE_NAME); MAX_SUITE_NAME);
break; break;
@ -391,8 +393,8 @@ void SSL::set_pending(Cipher suite)
parms.key_size_ = RC4_KEY_SZ; parms.key_size_ = RC4_KEY_SZ;
parms.iv_size_ = 0; parms.iv_size_ = 0;
parms.cipher_type_ = stream; parms.cipher_type_ = stream;
crypto_.setDigest(new (ys) MD5); crypto_.setDigest(NEW_YS MD5);
crypto_.setCipher(new (ys) RC4); crypto_.setCipher(NEW_YS RC4);
strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_MD5], strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_MD5],
MAX_SUITE_NAME); MAX_SUITE_NAME);
break; break;
@ -407,8 +409,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = DES_IV_SZ; parms.iv_size_ = DES_IV_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) DES); crypto_.setCipher(NEW_YS DES);
strncpy(parms.cipher_name_, cipher_names[SSL_DHE_RSA_WITH_DES_CBC_SHA], strncpy(parms.cipher_name_, cipher_names[SSL_DHE_RSA_WITH_DES_CBC_SHA],
MAX_SUITE_NAME); MAX_SUITE_NAME);
break; break;
@ -423,8 +425,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = DES_IV_SZ; parms.iv_size_ = DES_IV_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) DES_EDE); crypto_.setCipher(NEW_YS DES_EDE);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME); cipher_names[SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME);
break; break;
@ -439,8 +441,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME); cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME);
break; break;
@ -455,8 +457,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) AES); crypto_.setCipher(NEW_YS AES);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME); cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME);
break; break;
@ -471,8 +473,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = DES_IV_SZ; parms.iv_size_ = DES_IV_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) DES); crypto_.setCipher(NEW_YS DES);
strncpy(parms.cipher_name_, cipher_names[SSL_DHE_DSS_WITH_DES_CBC_SHA], strncpy(parms.cipher_name_, cipher_names[SSL_DHE_DSS_WITH_DES_CBC_SHA],
MAX_SUITE_NAME); MAX_SUITE_NAME);
break; break;
@ -487,8 +489,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = DES_IV_SZ; parms.iv_size_ = DES_IV_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) DES_EDE); crypto_.setCipher(NEW_YS DES_EDE);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME); cipher_names[SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME);
break; break;
@ -503,8 +505,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME); cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME);
break; break;
@ -519,8 +521,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) SHA); crypto_.setDigest(NEW_YS SHA);
crypto_.setCipher(new (ys) AES); crypto_.setCipher(NEW_YS AES);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME); cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME);
break; break;
@ -533,8 +535,8 @@ void SSL::set_pending(Cipher suite)
parms.key_size_ = AES_256_KEY_SZ; parms.key_size_ = AES_256_KEY_SZ;
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
crypto_.setDigest(new (ys) RMD); crypto_.setDigest(NEW_YS RMD);
crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_RSA_WITH_AES_256_CBC_RMD160], MAX_SUITE_NAME); cipher_names[TLS_RSA_WITH_AES_256_CBC_RMD160], MAX_SUITE_NAME);
break; break;
@ -547,8 +549,8 @@ void SSL::set_pending(Cipher suite)
parms.key_size_ = AES_128_KEY_SZ; parms.key_size_ = AES_128_KEY_SZ;
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
crypto_.setDigest(new (ys) RMD); crypto_.setDigest(NEW_YS RMD);
crypto_.setCipher(new (ys) AES); crypto_.setCipher(NEW_YS AES);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_RSA_WITH_AES_128_CBC_RMD160], MAX_SUITE_NAME); cipher_names[TLS_RSA_WITH_AES_128_CBC_RMD160], MAX_SUITE_NAME);
break; break;
@ -561,8 +563,8 @@ void SSL::set_pending(Cipher suite)
parms.key_size_ = DES_EDE_KEY_SZ; parms.key_size_ = DES_EDE_KEY_SZ;
parms.iv_size_ = DES_IV_SZ; parms.iv_size_ = DES_IV_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
crypto_.setDigest(new (ys) RMD); crypto_.setDigest(NEW_YS RMD);
crypto_.setCipher(new (ys) DES_EDE); crypto_.setCipher(NEW_YS DES_EDE);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_RSA_WITH_3DES_EDE_CBC_RMD160], MAX_SUITE_NAME); cipher_names[TLS_RSA_WITH_3DES_EDE_CBC_RMD160], MAX_SUITE_NAME);
break; break;
@ -577,8 +579,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = DES_IV_SZ; parms.iv_size_ = DES_IV_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) RMD); crypto_.setDigest(NEW_YS RMD);
crypto_.setCipher(new (ys) DES_EDE); crypto_.setCipher(NEW_YS DES_EDE);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160], cipher_names[TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160],
MAX_SUITE_NAME); MAX_SUITE_NAME);
@ -594,8 +596,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) RMD); crypto_.setDigest(NEW_YS RMD);
crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_RMD160], cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_RMD160],
MAX_SUITE_NAME); MAX_SUITE_NAME);
@ -611,8 +613,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) RMD); crypto_.setDigest(NEW_YS RMD);
crypto_.setCipher(new (ys) AES); crypto_.setCipher(NEW_YS AES);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_RMD160], cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_RMD160],
MAX_SUITE_NAME); MAX_SUITE_NAME);
@ -628,8 +630,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = DES_IV_SZ; parms.iv_size_ = DES_IV_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) RMD); crypto_.setDigest(NEW_YS RMD);
crypto_.setCipher(new (ys) DES_EDE); crypto_.setCipher(NEW_YS DES_EDE);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160], cipher_names[TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160],
MAX_SUITE_NAME); MAX_SUITE_NAME);
@ -645,8 +647,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) RMD); crypto_.setDigest(NEW_YS RMD);
crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_RMD160], cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_RMD160],
MAX_SUITE_NAME); MAX_SUITE_NAME);
@ -662,8 +664,8 @@ void SSL::set_pending(Cipher suite)
parms.iv_size_ = AES_BLOCK_SZ; parms.iv_size_ = AES_BLOCK_SZ;
parms.cipher_type_ = block; parms.cipher_type_ = block;
secure_.use_connection().send_server_key_ = true; // eph secure_.use_connection().send_server_key_ = true; // eph
crypto_.setDigest(new (ys) RMD); crypto_.setDigest(NEW_YS RMD);
crypto_.setCipher(new (ys) AES); crypto_.setCipher(NEW_YS AES);
strncpy(parms.cipher_name_, strncpy(parms.cipher_name_,
cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_RMD160], cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_RMD160],
MAX_SUITE_NAME); MAX_SUITE_NAME);
@ -830,7 +832,7 @@ void SSL::deriveKeys()
int length = 2 * secure_.get_parms().hash_size_ + int length = 2 * secure_.get_parms().hash_size_ +
2 * secure_.get_parms().key_size_ + 2 * secure_.get_parms().key_size_ +
2 * secure_.get_parms().iv_size_; 2 * secure_.get_parms().iv_size_;
int rounds = length / MD5_LEN + ((length % MD5_LEN) ? 1 : 0); int rounds = (length + MD5_LEN - 1 ) / MD5_LEN;
input_buffer key_data(rounds * MD5_LEN); input_buffer key_data(rounds * MD5_LEN);
opaque sha_output[SHA_LEN]; opaque sha_output[SHA_LEN];
@ -1366,17 +1368,16 @@ static Sessions* sessionsInstance = 0;
Sessions& GetSessions() Sessions& GetSessions()
{ {
if (!sessionsInstance) if (!sessionsInstance)
sessionsInstance = new (ys) Sessions; sessionsInstance = NEW_YS Sessions;
return *sessionsInstance; return *sessionsInstance;
} }
static sslFactory* sslFactoryInstance = 0; static sslFactory* sslFactoryInstance = 0;
sslFactory& GetSSL_Factory() sslFactory& GetSSL_Factory(){
{
if (!sslFactoryInstance) if (!sslFactoryInstance)
sslFactoryInstance = new (ys) sslFactory; sslFactoryInstance = NEW_YS sslFactory;
return *sslFactoryInstance; return *sslFactoryInstance;
} }
@ -1395,7 +1396,7 @@ typedef Mutex::Lock Lock;
void Sessions::add(const SSL& ssl) void Sessions::add(const SSL& ssl)
{ {
Lock guard(mutex_); Lock guard(mutex_);
list_.push_back(new (ys) SSL_SESSION(ssl, random_)); list_.push_back(NEW_YS SSL_SESSION(ssl, random_));
} }
@ -1462,7 +1463,8 @@ void Sessions::remove(const opaque* id)
SSL_METHOD::SSL_METHOD(ConnectionEnd ce, ProtocolVersion pv) SSL_METHOD::SSL_METHOD(ConnectionEnd ce, ProtocolVersion pv)
: version_(pv), side_(ce), verifyPeer_(false), failNoCert_(false) : version_(pv), side_(ce), verifyPeer_(false), verifyNone_(false),
failNoCert_(false)
{} {}
@ -1484,6 +1486,12 @@ void SSL_METHOD::setVerifyPeer()
} }
void SSL_METHOD::setVerifyNone()
{
verifyNone_ = true;
}
void SSL_METHOD::setFailNoCert() void SSL_METHOD::setFailNoCert()
{ {
failNoCert_ = true; failNoCert_ = true;
@ -1496,6 +1504,12 @@ bool SSL_METHOD::verifyPeer() const
} }
bool SSL_METHOD::verifyNone() const
{
return verifyNone_;
}
bool SSL_METHOD::failNoCert() const bool SSL_METHOD::failNoCert() const
{ {
return failNoCert_; return failNoCert_;
@ -1572,6 +1586,12 @@ void SSL_CTX::setVerifyPeer()
} }
void SSL_CTX::setVerifyNone()
{
method_->setVerifyNone();
}
void SSL_CTX::setFailNoCert() void SSL_CTX::setFailNoCert()
{ {
method_->setFailNoCert(); method_->setFailNoCert();
@ -1794,7 +1814,7 @@ void Crypto::SetDH(DiffieHellman* dh)
void Crypto::SetDH(const DH_Parms& dh) void Crypto::SetDH(const DH_Parms& dh)
{ {
if (dh.set_) if (dh.set_)
dh_ = new (ys) DiffieHellman(dh.p_, dh.g_, random_); dh_ = NEW_YS DiffieHellman(dh.p_, dh.g_, random_);
} }
@ -1961,7 +1981,7 @@ X509_NAME::X509_NAME(const char* n, size_t sz)
: name_(0) : name_(0)
{ {
if (sz) { if (sz) {
name_ = new (ys) char[sz]; name_ = NEW_YS char[sz];
memcpy(name_, n, sz); memcpy(name_, n, sz);
} }
} }

View file

@ -1,2 +1,2 @@
SUBDIRS = src SUBDIRS = src test benchmark
EXTRA_DIST = taocrypt.dsw taocrypt.dsp taocrypt.vcproj cmakelists.txt EXTRA_DIST = taocrypt.dsw taocrypt.dsp taocrypt.vcproj cmakelists.txt

View file

@ -0,0 +1,8 @@
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

View file

@ -0,0 +1,440 @@
// benchmark.cpp
// TaoCrypt benchmark
#include <string.h>
#include <stdio.h>
#include "runtime.hpp"
#include "des.hpp"
#include "aes.hpp"
#include "twofish.hpp"
#include "blowfish.hpp"
#include "arc4.hpp"
#include "md5.hpp"
#include "sha.hpp"
#include "ripemd.hpp"
#include "rsa.hpp"
#include "dh.hpp"
#include "dsa.hpp"
using namespace TaoCrypt;
void bench_aes(bool show);
void bench_des();
void bench_blowfish();
void bench_twofish();
void bench_arc4();
void bench_md5();
void bench_sha();
void bench_ripemd();
void bench_rsa();
void bench_dh();
void bench_dsa();
double current_time();
int main(int argc, char** argv)
{
bench_aes(false);
bench_aes(true);
bench_blowfish();
bench_twofish();
bench_arc4();
bench_des();
printf("\n");
bench_md5();
bench_sha();
bench_ripemd();
printf("\n");
bench_rsa();
bench_dh();
bench_dsa();
return 0;
}
const int megs = 5; // how much to test
const byte key[] =
{
0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
0xfe,0xde,0xba,0x98,0x76,0x54,0x32,0x10,
0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67
};
const byte iv[] =
{
0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x11,0x21,0x31,0x41,0x51,0x61,0x71,0x81
};
byte plain [1024*1024];
byte cipher[1024*1024];
void bench_des()
{
DES_EDE3_CBC_Encryption enc;
enc.SetKey(key, 16, iv);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(plain, cipher, sizeof(plain));
double total = current_time() - start;
double persec = 1 / total * megs;
printf("3DES %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
persec);
}
void bench_aes(bool show)
{
AES_CBC_Encryption enc;
enc.SetKey(key, 16, iv);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(plain, cipher, sizeof(plain));
double total = current_time() - start;
double persec = 1 / total * megs;
if (show)
printf("AES %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
persec);
}
void bench_twofish()
{
Twofish_CBC_Encryption enc;
enc.SetKey(key, 16, iv);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(plain, cipher, sizeof(plain));
double total = current_time() - start;
double persec = 1 / total * megs;
printf("Twofish %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
persec);
}
void bench_blowfish()
{
Blowfish_CBC_Encryption enc;
enc.SetKey(key, 16, iv);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(plain, cipher, sizeof(plain));
double total = current_time() - start;
double persec = 1 / total * megs;
printf("Blowfish %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
persec);
}
void bench_arc4()
{
ARC4 enc;
enc.SetKey(key, 16);
double start = current_time();
for(int i = 0; i < megs; i++)
enc.Process(cipher, plain, sizeof(plain));
double total = current_time() - start;
double persec = 1 / total * megs;
printf("ARC4 %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
persec);
}
void bench_md5()
{
MD5 hash;
byte digest[MD5::DIGEST_SIZE];
double start = current_time();
for(int i = 0; i < megs; i++)
hash.Update(plain, sizeof(plain));
hash.Final(digest);
double total = current_time() - start;
double persec = 1 / total * megs;
printf("MD5 %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
persec);
}
void bench_sha()
{
SHA hash;
byte digest[SHA::DIGEST_SIZE];
double start = current_time();
for(int i = 0; i < megs; i++)
hash.Update(plain, sizeof(plain));
hash.Final(digest);
/*
for(int i = 0; i < megs; i++)
hash.AsmTransform(plain, 16384);
*/
double total = current_time() - start;
double persec = 1 / total * megs;
printf("SHA %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
persec);
}
void bench_ripemd()
{
RIPEMD160 hash;
byte digest[RIPEMD160::DIGEST_SIZE];
double start = current_time();
for(int i = 0; i < megs; i++)
hash.Update(plain, sizeof(plain));
hash.Final(digest);
double total = current_time() - start;
double persec = 1 / total * megs;
printf("RIPEMD %d megs took %5.3f seconds, %5.2f MB/s\n", megs, total,
persec);
}
RandomNumberGenerator rng;
void bench_rsa()
{
const int times = 100;
Source source;
FileSource("./rsa1024.der", source);
if (source.size() == 0) {
printf("can't find ./rsa1024.der\n");
return;
}
RSA_PrivateKey priv(source);
RSAES_Encryptor enc(priv);
byte message[] = "Everyone gets Friday off.";
byte cipher[128]; // for 1024 bit
byte plain[128]; // for 1024 bit
const int len = strlen((char*)message);
int i;
double start = current_time();
for (i = 0; i < times; i++)
enc.Encrypt(message, len, cipher, rng);
double total = current_time() - start;
double each = total / times; // per second
double milliEach = each * 1000; // milliseconds
printf("RSA 1024 encryption took %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
RSAES_Decryptor dec(priv);
start = current_time();
for (i = 0; i < times; i++)
dec.Decrypt(cipher, 128, plain, rng);
total = current_time() - start;
each = total / times; // per second
milliEach = each * 1000; // milliseconds
printf("RSA 1024 decryption took %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
}
void bench_dh()
{
const int times = 100;
Source source;
FileSource("./dh1024.der", source);
if (source.size() == 0) {
printf("can't find ./dh1024.der\n");
return;
}
DH dh(source);
byte pub[128]; // for 1024 bit
byte priv[128]; // for 1024 bit
int i;
double start = current_time();
for (i = 0; i < times; i++)
dh.GenerateKeyPair(rng, priv, pub);
double total = current_time() - start;
double each = total / times; // per second
double milliEach = each * 1000; // milliseconds
printf("DH 1024 key generation %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
DH dh2(dh);
byte pub2[128]; // for 1024 bit
byte priv2[128]; // for 1024 bit
dh2.GenerateKeyPair(rng, priv2, pub2);
unsigned char key[256];
start = current_time();
for (i = 0; i < times; i++)
dh.Agree(key, priv, pub2);
total = current_time() - start;
each = total / times; // per second
milliEach = each * 1000; // in milliseconds
printf("DH 1024 key agreement %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
}
void bench_dsa()
{
const int times = 100;
Source source;
FileSource("./dsa1024.der", source);
if (source.size() == 0) {
printf("can't find ./dsa1024.der\n");
return;
}
DSA_PrivateKey key(source);
DSA_Signer signer(key);
SHA sha;
byte digest[SHA::DIGEST_SIZE];
byte signature[40];
const char msg[] = "this is the message";
sha.Update((byte*)msg, sizeof(msg));
sha.Final(digest);
int i;
double start = current_time();
for (i = 0; i < times; i++)
signer.Sign(digest, signature, rng);
double total = current_time() - start;
double each = total / times; // per second
double milliEach = each * 1000; // milliseconds
printf("DSA 1024 sign took %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
DSA_Verifier verifier(key);
start = current_time();
for (i = 0; i < times; i++)
verifier.Verify(digest, signature);
total = current_time() - start;
each = total / times; // per second
milliEach = each * 1000; // in milliseconds
printf("DSA 1024 verify took %6.2f milliseconds, avg over %d"
" iterations\n", milliEach, times);
}
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
double current_time()
{
static bool init(false);
static LARGE_INTEGER freq;
if (!init) {
QueryPerformanceFrequency(&freq);
init = true;
}
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
return static_cast<double>(count.QuadPart) / freq.QuadPart;
}
#else
#include <sys/time.h>
double current_time()
{
struct timeval tv;
gettimeofday(&tv, 0);
return static_cast<double>(tv.tv_sec)
+ static_cast<double>(tv.tv_usec) / 1000000;
}
#endif // _WIN32

View file

@ -0,0 +1,101 @@
# 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

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,10 @@
# 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

Binary file not shown.

View file

@ -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:
: 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

View file

@ -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_;

View file

@ -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:
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:
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();

View file

@ -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)

View file

@ -0,0 +1,79 @@
/* 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

View file

@ -27,73 +27,87 @@
#ifndef TAO_CRYPT_DES_HPP #ifndef TAO_CRYPT_DES_HPP
#define TAO_CRYPT_DES_HPP #define TAO_CRYPT_DES_HPP
#include <string.h>
#include "misc.hpp" #include "misc.hpp"
#include "modes.hpp" #include "modes.hpp"
namespace TaoCrypt { namespace TaoCrypt {
enum { DES_BLOCK_SIZE = 8 };
// Base for all DES types enum { DES_BLOCK_SIZE = 8, DES_KEY_SIZE = 32 };
class DES_BASE : public Mode_BASE {
class BasicDES {
public: public:
enum { BLOCK_SIZE = DES_BLOCK_SIZE, KEY_SIZE = 32, BOXES = 8, void SetKey(const byte*, word32, CipherDir dir);
BOX_SIZE = 64 }; void RawProcessBlock(word32&, word32&) const;
DES_BASE(CipherDir DIR, Mode MODE)
: Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
void Process(byte*, const byte*, word32);
protected: protected:
CipherDir dir_; word32 k_[DES_KEY_SIZE];
Mode mode_;
private:
DES_BASE(const DES_BASE&); // hide copy
DES_BASE& operator=(const DES_BASE&); // and assign
}; };
// DES // DES
class DES : public DES_BASE { class DES : public Mode_BASE, public BasicDES {
public: public:
DES(CipherDir DIR, Mode MODE) : DES_BASE(DIR, MODE) {} DES(CipherDir DIR, Mode MODE)
: Mode_BASE(DES_BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
void SetKey(const byte*, word32, CipherDir dir); void Process(byte*, const byte*, word32);
void RawProcessBlock(word32&, word32&) const;
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
private: private:
word32 k_[KEY_SIZE]; CipherDir dir_;
Mode mode_;
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
DES(const DES&); // hide copy
DES& operator=(const DES&); // and assign
}; };
// DES_EDE2 // DES_EDE2
class DES_EDE2 : public DES_BASE { class DES_EDE2 : public Mode_BASE {
public: public:
DES_EDE2(CipherDir DIR, Mode MODE) DES_EDE2(CipherDir DIR, Mode MODE)
: DES_BASE(DIR, MODE), des1_(DIR, MODE), des2_(DIR, MODE) {} : Mode_BASE(DES_BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
void SetKey(const byte*, word32, CipherDir dir); void SetKey(const byte*, word32, CipherDir dir);
void ProcessAndXorBlock(const byte*, const byte*, byte*) const; void Process(byte*, const byte*, word32);
private: private:
DES des1_; CipherDir dir_;
DES des2_; Mode mode_;
BasicDES des1_;
BasicDES des2_;
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
DES_EDE2(const DES_EDE2&); // hide copy
DES_EDE2& operator=(const DES_EDE2&); // and assign
}; };
// DES_EDE3 // DES_EDE3
class DES_EDE3 : public DES_BASE { class DES_EDE3 : public Mode_BASE {
public: public:
DES_EDE3(CipherDir DIR, Mode MODE) DES_EDE3(CipherDir DIR, Mode MODE)
: DES_BASE(DIR, MODE), des1_(DIR, MODE), des2_(DIR, MODE), : Mode_BASE(DES_BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
des3_(DIR, MODE) {}
void SetKey(const byte*, word32, CipherDir dir); void SetKey(const byte*, word32, CipherDir dir);
void ProcessAndXorBlock(const byte*, const byte*, byte*) const; void SetIV(const byte* iv) { memcpy(r_, iv, DES_BLOCK_SIZE); }
void Process(byte*, const byte*, word32);
private: private:
DES des1_; CipherDir dir_;
DES des2_; Mode mode_;
DES des3_;
BasicDES des1_;
BasicDES des2_;
BasicDES des3_;
void AsmProcess(const byte* in, byte* out, void* box) const;
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
DES_EDE3(const DES_EDE3&); // hide copy
DES_EDE3& operator=(const DES_EDE3&); // and assign
}; };

View file

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

View file

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

View file

@ -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();

View file

@ -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)

View file

@ -0,0 +1,49 @@
/* 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

View file

@ -45,10 +45,13 @@ public:
MD5(const MD5&); MD5(const MD5&);
MD5& operator= (const MD5&); MD5& operator= (const MD5&);
void Update(const byte*, word32);
void Init(); void Init();
void Swap(MD5&); void Swap(MD5&);
private: private:
void Transform(); void Transform();
void AsmTransform(const byte* data, word32 times);
}; };
inline void swap(MD5& a, MD5& b) inline void swap(MD5& a, MD5& b)

View file

@ -24,9 +24,15 @@
#ifndef TAO_CRYPT_MISC_HPP #ifndef TAO_CRYPT_MISC_HPP
#define TAO_CRYPT_MISC_HPP #define TAO_CRYPT_MISC_HPP
#include <stdlib.h>
#include <assert.h> #if !defined(DO_TAOCRYPT_KERNEL_MODE)
#include <string.h> #include <stdlib.h>
#include <assert.h>
#include <string.h>
#else
#include "kernelc.hpp"
#endif
#include "types.hpp" #include "types.hpp"
#include "type_traits.hpp" #include "type_traits.hpp"
@ -39,31 +45,33 @@ namespace TaoCrypt {
void CleanUp(); void CleanUp();
// library allocation #ifdef YASSL_PURE_C
struct new_t {}; // TaoCrypt New type
extern new_t tc; // pass in parameter
} // namespace TaoCrypt // library allocation
struct new_t {}; // TaoCrypt New type
extern new_t tc; // pass in parameter
void* operator new (size_t, TaoCrypt::new_t); } // namespace TaoCrypt
void* operator new[](size_t, TaoCrypt::new_t);
void operator delete (void*, TaoCrypt::new_t); void* operator new (size_t, TaoCrypt::new_t);
void operator delete[](void*, TaoCrypt::new_t); void* operator new[](size_t, TaoCrypt::new_t);
void operator delete (void*, TaoCrypt::new_t);
void operator delete[](void*, TaoCrypt::new_t);
namespace TaoCrypt { namespace TaoCrypt {
template<typename T> template<typename T>
void tcDelete(T* ptr) void tcDelete(T* ptr)
{ {
if (ptr) ptr->~T(); if (ptr) ptr->~T();
::operator delete(ptr, TaoCrypt::tc); ::operator delete(ptr, TaoCrypt::tc);
} }
template<typename T> template<typename T>
void tcArrayDelete(T* ptr) void tcArrayDelete(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
@ -71,15 +79,39 @@ void tcArrayDelete(T* ptr)
(void)sizeof(builtin); (void)sizeof(builtin);
::operator delete[](ptr, TaoCrypt::tc); ::operator delete[](ptr, TaoCrypt::tc);
} }
#define NEW_TC new (TaoCrypt::tc)
// 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 tcDelete(T* ptr)
{
delete ptr;
}
template<typename T>
void tcArrayDelete(T* ptr)
{
delete[] ptr;
}
#define NEW_TC new
class virtual_base {};
#endif // YASSL_PURE_C
#if defined(_MSC_VER) || defined(__BCPLUSPLUS__) #if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
@ -100,15 +132,13 @@ public:
#define TAOCRYPT_DISABLE_X86ASM #define TAOCRYPT_DISABLE_X86ASM
#endif #endif
// icc problem with -03 and integer, disable for now
// Disable assmebler when compiling with icc
// Temporary workaround for bug12717
#if defined(__INTEL_COMPILER) #if defined(__INTEL_COMPILER)
#define TAOCRYPT_DISABLE_X86ASM #define TAOCRYPT_DISABLE_X86ASM
#endif #endif
// Turn on ia32 ASM for Big Integer
// CodeWarrior defines _MSC_VER // CodeWarrior defines _MSC_VER
#if !defined(TAOCRYPT_DISABLE_X86ASM) && ((defined(_MSC_VER) && \ #if !defined(TAOCRYPT_DISABLE_X86ASM) && ((defined(_MSC_VER) && \
!defined(__MWERKS__) && defined(_M_IX86)) || \ !defined(__MWERKS__) && defined(_M_IX86)) || \
@ -117,6 +147,20 @@ public:
#endif #endif
// Turn on ia32 ASM for Ciphers and Message Digests
// Seperate define since these are more complex, use member offsets
// and user may want to turn off while leaving Big Integer optos on
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && !defined(DISABLE_TAO_ASM)
#define TAO_ASM
#endif
// Extra word in older vtable implementations, for ASM member offset
#if defined(__GNUC__) && __GNUC__ < 3
#define OLD_GCC_OFFSET
#endif
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define TAOCRYPT_MALLOC_ALIGNMENT_IS_16 # define TAOCRYPT_MALLOC_ALIGNMENT_IS_16
#endif #endif
@ -437,6 +481,58 @@ inline void ByteReverseIf(T* out, const T* in, word32 bc, ByteOrder order)
} }
// do Asm Reverse is host is Little and x86asm
#ifdef LITTLE_ENDIAN_ORDER
#ifdef TAOCRYPT_X86ASM_AVAILABLE
#define LittleReverse AsmReverse
#else
#define LittleReverse ByteReverse
#endif
#else
#define LittleReverse
#endif
// do Asm Reverse is host is Big and x86asm
#ifdef BIG_ENDIAN_ORDER
#ifdef TAOCRYPT_X86ASM_AVAILABLE
#define BigReverse AsmReverse
#else
#define BigReverse ByteReverse
#endif
#else
#define BigReverse
#endif
#ifdef TAOCRYPT_X86ASM_AVAILABLE
// faster than rotate, use bswap
inline word32 AsmReverse(word32 wd)
{
#ifdef __GNUC__
__asm__
(
"bswap %1"
: "=r"(wd)
: "0"(wd)
);
#else
__asm
{
mov eax, wd
bswap eax
mov wd, eax
}
#endif
return wd;
}
#endif
template <class T> template <class T>
inline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in, inline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in,
word32 inlen) word32 inlen)

View file

@ -26,7 +26,6 @@
#ifndef TAO_CRYPT_MODES_HPP #ifndef TAO_CRYPT_MODES_HPP
#define TAO_CRYPT_MODES_HPP #define TAO_CRYPT_MODES_HPP
#include <string.h>
#include "misc.hpp" #include "misc.hpp"
namespace TaoCrypt { namespace TaoCrypt {
@ -68,14 +67,8 @@ public:
} }
virtual ~Mode_BASE() {} virtual ~Mode_BASE() {}
virtual void ProcessAndXorBlock(const byte*, const byte*, byte*) const = 0;
void ECB_Process(byte*, const byte*, word32);
void CBC_Encrypt(byte*, const byte*, word32);
void CBC_Decrypt(byte*, const byte*, word32);
void SetIV(const byte* iv) { memcpy(reg_, iv, blockSz_); } void SetIV(const byte* iv) { memcpy(reg_, iv, blockSz_); }
private: protected:
int blockSz_; int blockSz_;
byte* reg_; byte* reg_;
byte* tmp_; byte* tmp_;
@ -83,9 +76,15 @@ private:
word32 r_[MaxBlockSz / sizeof(word32)]; // align reg_ on word32 word32 r_[MaxBlockSz / sizeof(word32)]; // align reg_ on word32
word32 t_[MaxBlockSz / sizeof(word32)]; // align tmp_ on word32 word32 t_[MaxBlockSz / sizeof(word32)]; // align tmp_ on word32
void ECB_Process(byte*, const byte*, word32);
void CBC_Encrypt(byte*, const byte*, word32);
void CBC_Decrypt(byte*, const byte*, word32);
Mode_BASE(const Mode_BASE&); // hide copy Mode_BASE(const Mode_BASE&); // hide copy
Mode_BASE& operator=(const Mode_BASE&); // and assign Mode_BASE& operator=(const Mode_BASE&); // and assign
private:
virtual void ProcessAndXorBlock(const byte*, const byte*, byte*) const = 0;
}; };

View file

@ -0,0 +1,93 @@
/* pwdbased.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
*/
/* pwdbased.hpp defines PBKDF2 from PKCS #5
*/
#ifndef TAO_CRYPT_PWDBASED_HPP
#define TAO_CRYPT_PWDBASED_HPP
#include <string.h>
#include "misc.hpp"
#include "block.hpp"
#include "hmac.hpp"
namespace TaoCrypt {
// From PKCS #5, T must be type suitable for HMAC<T>
template <class T>
class PBKDF2_HMAC {
public:
word32 MaxDerivedKeyLength() const { return 0xFFFFFFFFU;} // avoid overflow
word32 DeriveKey(byte* derived, word32 dLen, const byte* pwd, word32 pLen,
const byte* salt, word32 sLen, word32 iterations) const;
};
template <class T>
word32 PBKDF2_HMAC<T>::DeriveKey(byte* derived, word32 dLen, const byte* pwd,
word32 pLen, const byte* salt, word32 sLen,
word32 iterations) const
{
assert(dLen <= MaxDerivedKeyLength());
assert(iterations > 0);
ByteBlock buffer(T::DIGEST_SIZE);
HMAC<T> hmac;
hmac.SetKey(pwd, pLen);
word32 i = 1;
while (dLen > 0) {
hmac.Update(salt, sLen);
word32 j;
for (j = 0; j < 4; j++) {
byte b = i >> ((3-j)*8);
hmac.Update(&b, 1);
}
hmac.Final(buffer.get_buffer());
word32 segmentLen = mySTL::min(dLen, buffer.size());
memcpy(derived, buffer.get_buffer(), segmentLen);
for (j = 1; j < iterations; j++) {
hmac.Update(buffer.get_buffer(), buffer.size());
hmac.Final(buffer.get_buffer());
xorbuf(derived, buffer.get_buffer(), segmentLen);
}
derived += segmentLen;
dLen -= segmentLen;
i++;
}
return iterations;
}
} // naemspace
#endif // TAO_CRYPT_PWDBASED_HPP

View file

@ -45,10 +45,12 @@ public:
RIPEMD160(const RIPEMD160&); RIPEMD160(const RIPEMD160&);
RIPEMD160& operator= (const RIPEMD160&); RIPEMD160& operator= (const RIPEMD160&);
void Update(const byte*, word32);
void Init(); void Init();
void Swap(RIPEMD160&); void Swap(RIPEMD160&);
private: private:
void Transform(); void Transform();
void AsmTransform(const byte* data, word32 times);
}; };
inline void swap(RIPEMD160& a, RIPEMD160& b) inline void swap(RIPEMD160& a, RIPEMD160& b)

View file

@ -49,7 +49,11 @@ namespace __Crun {
#if __GNUC__ > 2 #if __GNUC__ > 2
extern "C" { extern "C" {
#include <assert.h> #if !defined(DO_TAOCRYPT_KERNEL_MODE)
#include <assert.h>
#else
#include "kernelc.hpp"
#endif
/* Disallow inline __cxa_pure_virtual() */ /* Disallow inline __cxa_pure_virtual() */
static int __cxa_pure_virtual() __attribute__((noinline, used)); static int __cxa_pure_virtual() __attribute__((noinline, used));

View file

@ -42,6 +42,7 @@ public:
word32 getDigestSize() const { return DIGEST_SIZE; } word32 getDigestSize() const { return DIGEST_SIZE; }
word32 getPadSize() const { return PAD_SIZE; } word32 getPadSize() const { return PAD_SIZE; }
void Update(const byte* data, word32 len);
void Init(); void Init();
SHA(const SHA&); SHA(const SHA&);
@ -50,6 +51,7 @@ public:
void Swap(SHA&); void Swap(SHA&);
private: private:
void Transform(); void Transform();
void AsmTransform(const byte* data, word32 times);
}; };

View file

@ -0,0 +1,86 @@
/* twofish.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
*/
/* twofish.hpp defines Twofish
*/
#ifndef TAO_CRYPT_TWOFISH_HPP
#define TAO_CRYPT_TWOFISH_HPP
#include "misc.hpp"
#include "modes.hpp"
#include "algorithm.hpp"
namespace TaoCrypt {
enum { TWOFISH_BLOCK_SIZE = 16 };
// Twofish encryption and decryption, see
class Twofish : public Mode_BASE {
public:
enum { BLOCK_SIZE = TWOFISH_BLOCK_SIZE };
Twofish(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 byte q_[2][256];
static const word32 mds_[4][256];
word32 k_[40];
word32 s_[4][256];
static word32 h0(word32 x, const word32 *key, unsigned int kLen);
static word32 h(word32 x, const word32 *key, unsigned int kLen);
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
void encrypt(const byte*, const byte*, byte*) const;
void decrypt(const byte*, const byte*, byte*) const;
void AsmEncrypt(const byte* inBlock, byte* outBlock) const;
void AsmDecrypt(const byte* inBlock, byte* outBlock) const;
Twofish(const Twofish&); // hide copy
Twofish& operator=(const Twofish&); // and assign
};
typedef BlockCipher<ENCRYPTION, Twofish, ECB> Twofish_ECB_Encryption;
typedef BlockCipher<DECRYPTION, Twofish, ECB> Twofish_ECB_Decryption;
typedef BlockCipher<ENCRYPTION, Twofish, CBC> Twofish_CBC_Encryption;
typedef BlockCipher<DECRYPTION, Twofish, CBC> Twofish_CBC_Decryption;
} // naemspace
#endif // TAO_CRYPT_TWOFISH_HPP

View file

@ -61,10 +61,11 @@ typedef unsigned int word32;
// compilers we've found 64-bit multiply insructions for // compilers we've found 64-bit multiply insructions for
#if defined(__GNUC__) || defined(_MSC_VER) || defined(__DECCXX) #if defined(__GNUC__) || defined(_MSC_VER) || defined(__DECCXX)
#if !(defined(__ICC) || defined(__INTEL_COMPILER)) #if !(defined(__ICC) || defined(__INTEL_COMPILER))
#define HAVE_64_MULTIPLY #define HAVE_64_MULTIPLY
#endif
#endif #endif
#endif
#if defined(HAVE_64_MULTIPLY) && (defined(__alpha__) || defined(__ia64__) \ #if defined(HAVE_64_MULTIPLY) && (defined(__alpha__) || defined(__ia64__) \
|| defined(_ARCH_PPC64) || defined(__mips64) || defined(__x86_64__)) || defined(_ARCH_PPC64) || defined(__mips64) || defined(__x86_64__))

View file

@ -2,10 +2,12 @@ INCLUDES = -I../include -I../../mySTL
noinst_LTLIBRARIES = libtaocrypt.la noinst_LTLIBRARIES = libtaocrypt.la
libtaocrypt_la_SOURCES = aes.cpp aestables.cpp algebra.cpp arc4.cpp asn.cpp \ libtaocrypt_la_SOURCES = aes.cpp aestables.cpp algebra.cpp arc4.cpp \
coding.cpp dh.cpp des.cpp dsa.cpp file.cpp hash.cpp \ asn.cpp bftables.cpp blowfish.cpp coding.cpp des.cpp dh.cpp \
md2.cpp md5.cpp misc.cpp random.cpp ripemd.cpp rsa.cpp sha.cpp \ dsa.cpp file.cpp hash.cpp integer.cpp md2.cpp md5.cpp misc.cpp \
template_instnt.cpp integer.cpp random.cpp ripemd.cpp rsa.cpp sha.cpp template_instnt.cpp \
tftables.cpp twofish.cpp
libtaocrypt_la_CXXFLAGS = @yassl_taocrypt_extra_cxxflags@ -DYASSL_PURE_C libtaocrypt_la_CXXFLAGS = @yassl_taocrypt_extra_cxxflags@ -DYASSL_PURE_C
EXTRA_DIST = $(wildcard ../include/*.hpp) EXTRA_DIST = $(wildcard ../include/*.hpp)

File diff suppressed because it is too large Load diff

View file

@ -28,689 +28,6 @@
namespace TaoCrypt { namespace TaoCrypt {
/*
Te0[x] = S [x].[02, 01, 01, 03];
Te1[x] = S [x].[03, 02, 01, 01];
Te2[x] = S [x].[01, 03, 02, 01];
Te3[x] = S [x].[01, 01, 03, 02];
Te4[x] = S [x].[01, 01, 01, 01];
Td0[x] = Si[x].[0e, 09, 0d, 0b];
Td1[x] = Si[x].[0b, 0e, 09, 0d];
Td2[x] = Si[x].[0d, 0b, 0e, 09];
Td3[x] = Si[x].[09, 0d, 0b, 0e];
Td4[x] = Si[x].[01, 01, 01, 01];
*/
const word32 AES::Te0[256] = {
0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,
0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,
0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,
0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,
0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,
0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,
0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,
0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,
0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,
0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,
0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,
0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,
0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,
0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,
0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,
0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,
0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,
0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,
0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,
0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,
0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,
0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,
0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,
0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,
0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,
0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,
0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,
0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,
0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,
0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,
0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,
0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,
0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,
0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,
0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,
0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,
0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,
0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,
0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,
0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,
0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,
0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,
0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,
0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,
0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,
0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,
0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,
0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,
0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,
0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,
0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,
0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,
0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,
0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,
0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,
0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,
0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,
0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,
0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,
0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,
0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,
0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,
0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,
};
const word32 AES::Te1[256] = {
0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,
0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,
0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,
0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,
0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,
0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,
0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,
0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,
0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,
0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,
0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,
0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,
0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,
0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,
0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,
0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,
0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,
0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,
0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,
0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,
0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,
0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,
0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,
0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,
0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,
0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,
0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,
0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,
0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,
0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,
0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,
0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,
0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,
0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,
0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,
0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,
0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,
0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,
0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,
0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,
0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,
0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,
0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,
0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,
0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,
0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,
0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,
0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,
0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,
0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,
0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,
0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,
0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,
0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,
0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,
0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,
0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,
0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,
0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,
0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,
0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,
0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,
0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,
0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,
};
const word32 AES::Te2[256] = {
0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,
0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,
0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,
0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,
0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,
0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,
0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,
0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,
0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,
0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,
0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,
0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,
0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,
0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,
0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,
0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,
0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,
0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,
0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,
0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,
0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,
0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,
0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,
0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,
0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,
0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,
0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,
0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,
0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,
0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,
0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,
0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,
0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,
0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,
0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,
0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,
0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,
0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,
0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,
0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,
0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,
0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,
0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,
0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,
0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,
0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,
0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,
0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,
0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,
0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,
0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,
0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,
0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,
0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,
0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,
0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,
0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,
0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,
0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,
0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,
0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,
0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,
0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,
0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,
};
const word32 AES::Te3[256] = {
0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,
0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,
0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,
0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,
0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,
0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,
0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,
0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,
0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,
0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,
0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,
0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,
0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,
0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,
0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,
0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,
0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,
0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,
0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,
0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,
0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,
0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,
0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,
0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,
0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,
0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,
0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,
0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,
0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,
0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,
0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,
0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,
0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,
0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,
0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,
0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,
0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,
0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,
0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,
0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,
0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,
0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,
0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,
0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,
0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,
0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,
0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,
0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,
0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,
0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,
0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,
0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,
0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,
0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,
0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,
0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,
0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,
0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,
0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,
0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,
0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,
0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,
0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,
0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,
};
const word32 AES::Te4[256] = {
0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,
0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,
0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,
0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,
0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,
0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,
0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,
0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,
0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,
0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,
0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,
0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,
0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,
0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,
0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,
0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,
0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,
0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,
0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,
0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,
0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,
0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,
0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,
0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,
0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,
0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,
0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,
0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,
0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,
0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,
0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,
0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,
0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,
0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,
0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,
0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,
0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,
0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,
0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,
0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,
0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,
0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,
0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,
0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,
0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,
0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,
0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,
0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,
0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,
0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,
0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,
0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,
0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,
0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,
0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,
0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,
0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,
0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,
0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,
0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,
0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,
0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,
0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,
0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,
};
const word32 AES::Td0[256] = {
0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,
0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,
0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,
0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,
0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,
0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,
0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,
0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,
0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,
0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,
0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,
0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,
0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,
0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,
0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,
0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,
0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,
0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,
0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,
0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,
0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,
0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,
0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,
0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,
0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,
0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,
0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,
0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,
0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,
0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,
0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,
0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,
0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,
0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,
0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,
0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,
0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,
0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,
0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,
0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,
0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,
0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,
0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,
0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,
0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,
0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,
0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,
0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,
0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,
0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,
0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,
0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,
0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,
0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,
0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,
0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,
0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,
0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,
0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,
0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,
0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,
0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,
0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,
0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,
};
const word32 AES::Td1[256] = {
0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,
0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,
0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,
0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,
0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,
0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,
0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,
0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,
0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,
0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,
0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,
0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,
0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,
0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,
0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,
0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,
0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,
0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,
0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,
0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,
0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,
0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,
0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,
0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,
0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,
0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,
0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,
0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,
0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,
0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,
0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,
0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,
0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,
0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,
0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,
0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,
0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,
0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,
0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,
0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,
0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,
0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,
0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,
0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,
0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,
0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,
0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,
0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,
0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,
0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,
0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,
0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,
0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,
0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,
0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,
0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,
0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,
0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,
0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,
0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,
0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,
0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,
0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,
0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,
};
const word32 AES::Td2[256] = {
0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,
0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,
0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,
0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,
0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,
0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,
0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,
0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,
0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,
0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,
0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,
0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,
0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,
0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,
0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,
0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,
0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,
0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,
0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,
0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,
0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,
0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,
0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,
0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,
0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,
0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,
0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,
0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,
0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,
0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,
0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,
0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,
0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,
0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,
0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,
0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,
0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,
0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,
0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,
0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,
0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,
0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,
0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,
0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,
0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,
0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,
0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,
0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,
0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,
0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,
0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,
0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,
0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,
0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,
0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,
0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,
0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,
0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,
0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,
0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,
0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,
0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,
0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,
0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,
};
const word32 AES::Td3[256] = {
0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,
0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,
0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,
0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,
0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,
0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,
0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,
0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,
0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,
0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,
0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,
0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,
0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,
0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,
0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,
0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,
0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,
0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,
0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,
0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,
0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,
0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,
0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,
0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,
0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,
0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,
0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,
0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,
0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,
0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,
0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,
0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,
0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,
0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,
0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,
0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,
0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,
0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,
0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,
0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,
0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,
0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,
0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,
0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,
0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,
0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,
0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,
0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,
0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,
0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,
0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,
0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,
0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,
0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,
0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,
0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,
0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,
0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,
0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,
0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,
0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,
0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,
0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,
0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,
};
const word32 AES::Td4[256] = {
0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,
0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,
0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,
0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,
0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,
0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,
0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,
0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,
0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,
0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,
0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,
0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,
0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,
0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,
0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,
0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,
0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,
0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,
0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,
0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,
0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,
0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,
0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,
0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,
0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,
0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,
0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,
0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,
0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,
0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,
0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,
0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,
0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,
0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,
0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,
0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,
0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,
0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,
0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,
0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,
0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,
0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,
0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,
0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,
0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,
0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,
0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,
0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,
0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,
0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,
0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,
0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,
0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,
0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,
0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,
0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,
0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,
0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,
0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,
0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,
0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,
0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,
0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,
0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,
};
const word32 AES::rcon_[] = { const word32 AES::rcon_[] = {
0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x01000000, 0x02000000, 0x04000000, 0x08000000,
0x10000000, 0x20000000, 0x40000000, 0x80000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000,

View file

@ -20,6 +20,8 @@
*/ */
/* based on Wei Dai's algebra.cpp from CryptoPP */ /* based on Wei Dai's algebra.cpp from CryptoPP */
#undef NDEBUG
#define DEBUG // GCC 4.0 bug if NDEBUG and Optimize > 1
#include "runtime.hpp" #include "runtime.hpp"
#include "algebra.hpp" #include "algebra.hpp"

Some files were not shown because too many files have changed in this diff Show more