mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-13 03:22:40 -04:00
Dep/MySQL: Updated MySQL sources to version 5.5.9 (current GA)
This commit is contained in:
@@ -26,7 +26,7 @@ MersenneTwister (a very fast random number generator)
|
||||
|
||||
MySQL (the world's most popular open source database software)
|
||||
http://www.mysql.com/
|
||||
Version: 5.1.50 (GA)
|
||||
Version: 5.5.9 (GA)
|
||||
|
||||
SFMT (SIMD-oriented Fast Mersenne Twister)
|
||||
Based on http://agner.org/random/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Copyright (C) 2006 MySQL AB
|
||||
# Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
||||
# Copyright (C) 2008-2011 Trinity <http://www.trinitycore.org/>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
@@ -9,274 +9,253 @@
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
set(COMPILATION_COMMENT "Source distribution lite for Trinity Core")
|
||||
set(PROTOCOL_VERSION "10")
|
||||
set(DOT_FRM_VERSION "6")
|
||||
set(MYSQL_TCP_PORT_DEFAULT "0")
|
||||
set(MYSQL_TCP_PORT "3306")
|
||||
set(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
|
||||
set(VERSION "5.1.50")
|
||||
set(MYSQL_BASE_VERSION "5.1")
|
||||
set(MYSQL_VERSION_ID "50150")
|
||||
# Include the platform-specific file.
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/os/Windows.cmake)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h.in
|
||||
${CMAKE_BINARY_DIR}/mysql_version.h @ONLY)
|
||||
# Add macros
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/character_sets.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mysql_version.cmake)
|
||||
|
||||
# Advanced options (mostly useless, but usually still in config.h, so they need to be set...)
|
||||
set(CYBOZU OFF)
|
||||
set(BACKUP_TEST OFF)
|
||||
set(ENABLED_LOCAL_INFILE ON)
|
||||
set(WITH_FAST_MUTEXES OFF)
|
||||
|
||||
# Handle useful options - hardcode to ON/OFF
|
||||
set(ENABLED_PROFILING OFF)
|
||||
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG ENABLED_DEBUG_SYNC)
|
||||
|
||||
# Set DBUG_OFF and other optional release-only flags for non-debug project types
|
||||
foreach(BUILD_TYPE RELEASE RELWITHDEBINFO MINSIZEREL)
|
||||
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_${BUILD_TYPE} DBUG_OFF)
|
||||
if(WITH_FAST_MUTEXES)
|
||||
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_${BUILD_TYPE} "MY_PTHREAD_FASTMUTEX=1")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Set commonly used variables
|
||||
set(DEFAULT_MYSQL_HOME "C:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}" )
|
||||
set(SHAREDIR share)
|
||||
set(DEFAULT_BASEDIR "${DEFAULT_MYSQL_HOME}")
|
||||
set(MYSQL_DATADIR "${DEFAULT_MYSQL_HOME}/data")
|
||||
set(DEFAULT_CHARSET_HOME "${DEFAULT_MYSQL_HOME}")
|
||||
set(PLUGINDIR "${DEFAULT_MYSQL_HOME}/lib/plugin")
|
||||
|
||||
set(COMPILATION_COMMENT "Source distribution lite for TrinityCore")
|
||||
|
||||
# Run platform tests
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake)
|
||||
|
||||
# Use system openssl.
|
||||
add_definitions(-DHAVE_OPENSSL)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/dep/zlib
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/internal
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dbug
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/mySTL
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql
|
||||
)
|
||||
|
||||
# FIXME only needed if build type is "Debug", but CMAKE_BUILD_TYPE is not set during configure time.
|
||||
set(DBUG_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dbug/dbug.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dbug/factorial.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dbug/sanity.c
|
||||
)
|
||||
|
||||
set(TAOCRYPT_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/aes.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/aestables.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/algebra.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/arc4.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/asn.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/coding.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/des.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/dh.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/dsa.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/file.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/hash.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/integer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/md2.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/md4.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/md5.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/misc.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/random.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/ripemd.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/rsa.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/src/sha.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/aes.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/algebra.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/arc4.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/asn.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/block.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/coding.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/des.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/dh.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/dsa.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/dsa.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/error.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/file.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/hash.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/hmac.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/integer.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/md2.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/md5.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/misc.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/modarith.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/modes.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/random.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/ripemd.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/rsa.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/taocrypt/include/sha.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dbug/dbug.c
|
||||
)
|
||||
|
||||
set(YASSL_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/buffer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/cert_wrapper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/crypto_wrapper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/handshake.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/lock.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/log.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/socket_wrapper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/ssl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/timer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/yassl_error.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/yassl_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extra/yassl/src/yassl_int.cpp
|
||||
)
|
||||
|
||||
set(LIB_SOURCES
|
||||
${DBUG_SOURCES}
|
||||
${TAOCRYPT_SOURCES}
|
||||
${YASSL_SOURCES}
|
||||
)
|
||||
|
||||
set(CLIENT_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql/errmsg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql/get_password.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql/libmysql.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql/manager.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql/dll.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/array.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/default.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/errors.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/hash.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_sleep.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/default_modify.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/charset-def.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/charset.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/list.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_arr_appstr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_cache.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_dirname.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_fn_ext.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_format.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_iocache.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_iocache2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_loadpath.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_pack.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_path.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_tempfile.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_unixpath.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_wcomp.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mulalloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_access.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_alloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_chsize.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_compress.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_create.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_delete.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_div.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_error.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_file.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_fopen.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_fstream.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_gethostbyname.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_getopt.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_getwd.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_init.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_lib.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_malloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_messnc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_net.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_once.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_open.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_pread.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_pthread.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_read.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_realloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_rename.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_seek.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_static.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_symlink.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_symlink2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_thr_init.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_wincond.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_winthread.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_write.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/safemalloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/sha1.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/string.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/thr_mutex.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/typelib.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_qsort.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_getsystime.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_sync.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql-common/client.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql-common/my_time.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql-common/pack.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql/net_serv.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql/password.c
|
||||
set(STRINGS_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/bchange.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/bmove.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/bmove_upp.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-big5.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-bin.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-bin.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-cp932.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-czech.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-euc_kr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-eucjpms.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-euc_kr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-extra.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-gb2312.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-gbk.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-latin1.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-mb.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-mb.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-simple.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-sjis.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-tis620.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-tis620.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-uca.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-ucs2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-ujis.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-utf8.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype-win1250ch.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/ctype.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/decimal.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/dtoa.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/int2str.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/is_prefix.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/llstr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/longlong2str.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strinstr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strmake.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strmov.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strnlen.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strnmov.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strtod.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strtoll.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strtoull.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strxmov.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strxnmov.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/my_strtoll10.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/my_vsnprintf.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/str2int.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/str_alloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strcend.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strcont.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strend.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strend.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strfill.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strmake.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strmov.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strnmov.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strxmov.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strxnmov.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/xml.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/my_strchr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strcont.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/strings/strappend.c
|
||||
)
|
||||
if(NOT HAVE_STRNLEN)
|
||||
# OSX does not have strnlen
|
||||
set(STRINGS_SOURCES ${STRINGS_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/strings/strnlen.c)
|
||||
endif()
|
||||
|
||||
set(VIO_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vio/vio.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vio/viosocket.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vio/viosocket.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vio/viossl.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vio/viosslfactories.c
|
||||
${LIB_SOURCES}
|
||||
)
|
||||
|
||||
add_library(libmysql SHARED ${CLIENT_SOURCES} libmysql/libmysql.def)
|
||||
set(MYSYS_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/array.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/charset-def.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/charset.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/checksum.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/default.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/errors.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/hash.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/list.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/md5.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_cache.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_dirname.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_fn_ext.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_format.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_getdate.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_iocache.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_iocache2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_keycache.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_keycaches.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_loadpath.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_pack.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_path.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_qsort.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_qsort2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_radix.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_same.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_sort.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_soundex.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_arr_appstr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_tempdir.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_tempfile.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_unixpath.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mf_wcomp.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/mulalloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_access.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_aes.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_alloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_bit.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_bitmap.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_chsize.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_compress.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_copy.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_create.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_delete.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_div.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_error.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_file.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_fopen.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_fstream.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_gethostbyname.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_gethwaddr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_getopt.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_getsystime.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_getwd.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_handler.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_init.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_lib.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_lock.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_malloc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_mess.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_mkdir.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_mmap.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_once.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_open.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_pread.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_pthread.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_quick.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_read.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_redel.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_rename.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_seek.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_sleep.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_static.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_symlink.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_symlink2.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_sync.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_thr_init.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_write.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/ptr_cmp.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/queues.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/stacktrace.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/rijndael.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/sha1.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/string.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/thr_alarm.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/thr_lock.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/thr_mutex.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/thr_rwlock.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/tree.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/typelib.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/base64.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_memmem.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_getpagesize.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/lf_alloc-pin.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/lf_dynarray.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/lf_hash.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_atomic.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_getncpus.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_rdtsc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_winthread.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_wincond.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_winerr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_winfile.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_windac.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_conio.c
|
||||
)
|
||||
if(HAVE_ALARM)
|
||||
set(MYSYS_SOURCES ${MYSYS_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_alarm.c)
|
||||
endif()
|
||||
if(HAVE_LARGE_PAGES)
|
||||
set(MYSYS_SOURCES ${MYSYS_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_largepage.c)
|
||||
endif()
|
||||
if(HAVE_MLOCK)
|
||||
set(MYSYS_SOURCES ${MYSYS_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/mysys/my_lockmem.c)
|
||||
endif()
|
||||
|
||||
# Need to set USE_TLS for building the DLL, since __declspec(thread)
|
||||
# approach to thread local storage does not work properly in DLLs.
|
||||
set(mysql_COMPILE_DEFINITIONS
|
||||
USE_TLS
|
||||
HAVE_YASSL
|
||||
YASSL_THREAD_SAFE
|
||||
YASSL_PREFIX
|
||||
CMAKE_CONFIGD
|
||||
DEFAULT_BASEDIR="c:/Program Files/MySQL/"
|
||||
DEFAULT_CHARSET_HOME="c:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}/"
|
||||
PACKAGE="mysql"
|
||||
SHAREDIR="share"
|
||||
__NT__
|
||||
set(CLIENT_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql/get_password.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql/libmysql.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libmysql/errmsg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql-common/client.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql-common/my_time.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql-common/client_plugin.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql/net_serv.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql-common/pack.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sql/password.c
|
||||
)
|
||||
|
||||
if(ENABLED_DEBUG_SYNC)
|
||||
set(mysql_COMPILE_DEFINITIONS ${mysql_COMPILE_DEFINITIONS} ENABLED_DEBUG_SYNC)
|
||||
endif(ENABLED_DEBUG_SYNC)
|
||||
configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/my_config.h)
|
||||
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/internal/mysql_version.h.in ${CMAKE_BINARY_DIR}/mysql_version.h)
|
||||
|
||||
if(EXTRA_DEBUG)
|
||||
set(mysql_COMPILE_DEFINITIONS ${mysql_COMPILE_DEFINITIONS} EXTRA_DEBUG)
|
||||
endif(EXTRA_DEBUG)
|
||||
|
||||
set(mysql_COMPILE_DEFINITIONS_DEBUG
|
||||
FORCE_INIT_OF_VARS
|
||||
SAFEMALLOC
|
||||
SAFE_MUTEX
|
||||
ENABLED_DEBUG_SYNC
|
||||
)
|
||||
|
||||
set_target_properties(libmysql PROPERTIES COMPILE_DEFINITIONS "${mysql_COMPILE_DEFINITIONS}")
|
||||
set_target_properties(libmysql PROPERTIES COMPILE_DEFINITIONS_DEBUG "${mysql_COMPILE_DEFINITIONS_DEBUG}")
|
||||
set_target_properties(libmysql PROPERTIES COMPILE_DEFINITIONS_RELEASE DBUG_OFF)
|
||||
set_target_properties(libmysql PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO DBUG_OFF)
|
||||
set_target_properties(libmysql PROPERTIES COMPILE_DEFINITIONS_MINSIZEREL DBUG_OFF)
|
||||
|
||||
target_link_libraries(libmysql ${ZLIB_LIBRARIES} wsock32)
|
||||
add_version_info(libmysql CLIENT_SOURCES)
|
||||
add_library(libmysql SHARED ${CLIENT_SOURCES} ${DBUG_SOURCES} ${MYSYS_SOURCES} ${STRINGS_SOURCES} ${VIO_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/libmysql/libmysql_exports.def)
|
||||
target_link_libraries(libmysql zlib ${OPENSSL_LIBRARIES} ${OPENSSL_EXTRA_LIBRARIES} ws2_32)
|
||||
|
||||
install(TARGETS libmysql RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,119 +0,0 @@
|
||||
MySQL FLOSS License Exception
|
||||
|
||||
The MySQL AB Exception for Free/Libre and Open Source
|
||||
Software-only Applications Using MySQL Client Libraries (the
|
||||
"FLOSS Exception").
|
||||
|
||||
Version 0.6, 7 March 2007
|
||||
|
||||
Exception Intent
|
||||
|
||||
We want specified Free/Libre and Open Source Software (``FLOSS'')
|
||||
applications to be able to use specified GPL-licensed MySQL client
|
||||
libraries (the ``Program'') despite the fact that not all FLOSS
|
||||
licenses are compatible with version 2 of the GNU General Public
|
||||
License (the ``GPL'').
|
||||
|
||||
Legal Terms and Conditions
|
||||
|
||||
As a special exception to the terms and conditions of version 2.0
|
||||
of the GPL:
|
||||
|
||||
1. You are free to distribute a Derivative Work that is formed
|
||||
entirely from the Program and one or more works (each, a
|
||||
"FLOSS Work") licensed under one or more of the licenses
|
||||
listed below in section 1, as long as:
|
||||
a. You obey the GPL in all respects for the Program and the
|
||||
Derivative Work, except for identifiable sections of the
|
||||
Derivative Work which are not derived from the Program,
|
||||
and which can reasonably be considered independent and
|
||||
separate works in themselves,
|
||||
b. all identifiable sections of the Derivative Work which
|
||||
are not derived from the Program, and which can
|
||||
reasonably be considered independent and separate works
|
||||
in themselves,
|
||||
i. are distributed subject to one of the FLOSS licenses
|
||||
listed below, and
|
||||
ii. the object code or executable form of those sections
|
||||
are accompanied by the complete corresponding
|
||||
machine-readable source code for those sections on
|
||||
the same medium and under the same FLOSS license as
|
||||
the corresponding object code or executable forms of
|
||||
those sections, and
|
||||
c. any works which are aggregated with the Program or with a
|
||||
Derivative Work on a volume of a storage or distribution
|
||||
medium in accordance with the GPL, can reasonably be
|
||||
considered independent and separate works in themselves
|
||||
which are not derivatives of either the Program, a
|
||||
Derivative Work or a FLOSS Work.
|
||||
If the above conditions are not met, then the Program may only
|
||||
be copied, modified, distributed or used under the terms and
|
||||
conditions of the GPL or another valid licensing option from
|
||||
MySQL AB.
|
||||
|
||||
2. FLOSS License List
|
||||
|
||||
License name Version(s)/Copyright Date
|
||||
Academic Free License 2.0
|
||||
Apache Software License 1.0/1.1/2.0
|
||||
Apple Public Source License 2.0
|
||||
Artistic license From Perl 5.8.0
|
||||
BSD license "July 22 1999"
|
||||
Common Development and Distribution License (CDDL) 1.0
|
||||
Common Public License 1.0
|
||||
Eclipse Public License 1.0
|
||||
GNU Library or "Lesser" General Public License (LGPL) 2.0/2.1
|
||||
Jabber Open Source License 1.0
|
||||
MIT license (As listed in file MIT-License.txt) ---
|
||||
Mozilla Public License (MPL) 1.0/1.1
|
||||
Open Software License 2.0
|
||||
OpenSSL license (with original SSLeay license) "2003" ("1998")
|
||||
PHP License 3.0
|
||||
Python license (CNRI Python License) ---
|
||||
Python Software Foundation License 2.1.1
|
||||
Sleepycat License "1999"
|
||||
University of Illinois/NCSA Open Source License ---
|
||||
W3C License "2001"
|
||||
X11 License "2001"
|
||||
Zlib/libpng License ---
|
||||
Zope Public License 2.0
|
||||
|
||||
Due to the many variants of some of the above licenses, we
|
||||
require that any version follow the 2003 version of the Free
|
||||
Software Foundation's Free Software Definition
|
||||
(http://www.gnu.org/philosophy/free-sw.html) or version 1.9 of
|
||||
the Open Source Definition by the Open Source Initiative
|
||||
(http://www.opensource.org/docs/definition.php).
|
||||
|
||||
3. Definitions
|
||||
|
||||
a. Terms used, but not defined, herein shall have the
|
||||
meaning provided in the GPL.
|
||||
b. Derivative Work means a derivative work under copyright
|
||||
law.
|
||||
|
||||
4. Applicability: This FLOSS Exception applies to all Programs
|
||||
that contain a notice placed by MySQL AB saying that the
|
||||
Program may be distributed under the terms of this FLOSS
|
||||
Exception. If you create or distribute a work which is a
|
||||
Derivative Work of both the Program and any other work
|
||||
licensed under the GPL, then this FLOSS Exception is not
|
||||
available for that work; thus, you must remove the FLOSS
|
||||
Exception notice from that work and comply with the GPL in all
|
||||
respects, including by retaining all GPL notices. You may
|
||||
choose to redistribute a copy of the Program exclusively under
|
||||
the terms of the GPL by removing the FLOSS Exception notice
|
||||
from that copy of the Program, provided that the copy has
|
||||
never been modified by you or any third party.
|
||||
|
||||
Appendix A. Qualified Libraries and Packages
|
||||
|
||||
The following is a non-exhaustive list of libraries and packages
|
||||
which are covered by the FLOSS License Exception. Please note that
|
||||
this appendix is provided merely as an additional service to
|
||||
specific FLOSS projects wishing to simplify licensing information
|
||||
for their users. Compliance with one of the licenses noted under
|
||||
the "FLOSS license list" section remains a prerequisite.
|
||||
|
||||
Package Name Qualifying License and Version
|
||||
Apache Portable Runtime (APR) Apache Software License 2.0
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,289 +0,0 @@
|
||||
|
||||
2.5.9. Installing MySQL from Source on Windows
|
||||
|
||||
These instructions describe how to build binaries from source for
|
||||
MySQL 5.1 on Windows. Instructions are provided for building
|
||||
binaries from a standard source distribution or from the Bazaar
|
||||
tree that contains the latest development source.
|
||||
|
||||
Note
|
||||
|
||||
The instructions here are strictly for users who want to test
|
||||
MySQL on Microsoft Windows from the latest source distribution or
|
||||
from the Bazaar tree. For production use, we do not advise using a
|
||||
MySQL server built by yourself from source. Normally, it is best
|
||||
to use precompiled binary distributions of MySQL that are built
|
||||
specifically for optimal performance on Windows by Oracle
|
||||
Corporation. Instructions for installing binary distributions are
|
||||
available in Section 2.5, "Installing MySQL on Windows."
|
||||
|
||||
To build MySQL on Windows from source, you must satisfy the
|
||||
following system, compiler, and resource requirements:
|
||||
|
||||
* Windows 2000, Windows XP, or newer version.
|
||||
Windows Vista is supported when using Visual Studio 2005
|
||||
provided you have installed the following updates:
|
||||
|
||||
+ Microsoft Visual Studio 2005 Professional Edition - ENU
|
||||
Service Pack 1 (KB926601)
|
||||
(http://support.microsoft.com/?kbid=926601)
|
||||
|
||||
+ Security Update for Microsoft Visual Studio 2005
|
||||
Professional Edition - ENU (KB937061)
|
||||
(http://support.microsoft.com/?kbid=937061)
|
||||
|
||||
+ Update for Microsoft Visual Studio 2005 Professional
|
||||
Edition - ENU (KB932232)
|
||||
(http://support.microsoft.com/?kbid=932232)
|
||||
|
||||
* CMake, which can be downloaded from http://www.cmake.org.
|
||||
After installing, modify your path to include the cmake
|
||||
binary.
|
||||
|
||||
* Microsoft Visual C++ 2005 Express Edition, Visual Studio .Net
|
||||
2003 (7.1), or Visual Studio 2005 (8.0) compiler system.
|
||||
|
||||
* If you are using Visual C++ 2005 Express Edition, you must
|
||||
also install an appropriate Platform SDK. More information and
|
||||
links to downloads for various Windows platforms is available
|
||||
from
|
||||
http://www.microsoft.com/downloads/details.aspx?familyid=0baf2
|
||||
b35-c656-4969-ace8-e4c0c0716adb.
|
||||
|
||||
* If you are compiling from a Bazaar tree or making changes to
|
||||
the parser, you need bison for Windows, which can be
|
||||
downloaded from
|
||||
http://gnuwin32.sourceforge.net/packages/bison.htm. Download
|
||||
the package labeled "Complete package, excluding sources".
|
||||
After installing the package, modify your path to include the
|
||||
bison binary and ensure that this binary is accessible from
|
||||
Visual Studio.
|
||||
|
||||
* Cygwin might be necessary if you want to run the test script
|
||||
or package the compiled binaries and support files into a Zip
|
||||
archive. (Cygwin is needed only to test or package the
|
||||
distribution, not to build it.) Cygwin is available from
|
||||
http://cygwin.com.
|
||||
|
||||
* 3GB to 5GB of disk space.
|
||||
|
||||
The exact system requirements for Visual Studio can be found here:
|
||||
http://msdn.microsoft.com/vstudio/Previous/2003/sysreqs/default.as
|
||||
px and
|
||||
http://msdn.microsoft.com/vstudio/products/sysreqs/default.aspx
|
||||
|
||||
You also need a MySQL source distribution for Windows, which can
|
||||
be obtained two ways:
|
||||
|
||||
* Obtain a source distribution packaged by Oracle Corporation.
|
||||
These are available from http://dev.mysql.com/downloads/.
|
||||
|
||||
* Package a source distribution yourself from the latest Bazaar
|
||||
developer source tree. For instructions on pulling the latest
|
||||
source files, see Section 2.3.3, "Installing from the
|
||||
Development Source Tree."
|
||||
|
||||
If you find something not working as expected, or you have
|
||||
suggestions about ways to improve the current build process on
|
||||
Windows, please send a message to the win32 mailing list. See
|
||||
Section 1.6.1, "MySQL Mailing Lists."
|
||||
|
||||
2.5.9.1. Building MySQL from Source Using CMake and Visual Studio
|
||||
|
||||
You can build MySQL on Windows by using a combination of cmake and
|
||||
Microsoft Visual Studio .NET 2003 (7.1), Microsoft Visual Studio
|
||||
2005 (8.0), Microsoft Visual Studio 2008 (9.0) or Microsoft Visual
|
||||
C++ 2005 Express Edition. You must have the appropriate Microsoft
|
||||
Platform SDK installed.
|
||||
|
||||
Note
|
||||
|
||||
To compile from the source code on Windows you must use the
|
||||
standard source distribution (for example, mysql-5.1.50.tar.gz).
|
||||
You build from the same distribution as used to build MySQL on
|
||||
Unix, Linux and other platforms. Do not use the Windows Source
|
||||
distributions as they do not contain the necessary configuration
|
||||
script and other files.
|
||||
|
||||
Follow this procedure to build MySQL:
|
||||
|
||||
1. If you are installing from a packaged source distribution,
|
||||
create a work directory (for example, C:\workdir), and unpack
|
||||
the source distribution there using WinZip or another Windows
|
||||
tool that can read .zip files. This directory is the work
|
||||
directory in the following instructions.
|
||||
|
||||
Note
|
||||
You must run the commands in the win directory from the
|
||||
top-level source directory. Do not change into the win
|
||||
directory, as the commands will not be executed correctly.
|
||||
|
||||
2. Start a command shell. If you have not configured the PATH and
|
||||
other environment variables for all command shells, you may be
|
||||
able to start a command shell from the Start Menu within the
|
||||
Windows Visual Studio menu that contains the necessary
|
||||
environment changes.
|
||||
|
||||
3. Within the command shell, navigate to the work directory and
|
||||
run the following command:
|
||||
C:\workdir>win\configure.js options
|
||||
If you have associated the .js file extension with an
|
||||
application such as a text editor, then you may need to use
|
||||
the following command to force configure.js to be executed as
|
||||
a script:
|
||||
C:\workdir>cscript win\configure.js options
|
||||
These options are available for configure.js:
|
||||
|
||||
+ WITH_INNOBASE_STORAGE_ENGINE: Enable the InnoDB storage
|
||||
engine.
|
||||
|
||||
+ WITH_PARTITION_STORAGE_ENGINE: Enable user-defined
|
||||
partitioning.
|
||||
|
||||
+ WITH_ARCHIVE_STORAGE_ENGINE: Enable the ARCHIVE storage
|
||||
engine.
|
||||
|
||||
+ WITH_BLACKHOLE_STORAGE_ENGINE: Enable the BLACKHOLE
|
||||
storage engine.
|
||||
|
||||
+ WITH_EXAMPLE_STORAGE_ENGINE: Enable the EXAMPLE storage
|
||||
engine.
|
||||
|
||||
+ WITH_FEDERATED_STORAGE_ENGINE: Enable the FEDERATED
|
||||
storage engine.
|
||||
|
||||
+ WITH_NDBCLUSTER_STORAGE_ENGINE: Enable the NDBCLUSTER
|
||||
storage engine in the MySQL server; cause binaries for
|
||||
the MySQL Cluster management and data node, management
|
||||
client, and other programs to be built.
|
||||
This option is supported only in MySQL Cluster NDB 7.0
|
||||
(NDBCLUSTER storage engine versions 6.4.0 and later)
|
||||
using the MySQL Cluster sources. It cannot be used to
|
||||
enable clustering support in other MySQL source trees or
|
||||
distributions.
|
||||
|
||||
+ MYSQL_SERVER_SUFFIX=suffix: Server suffix, default none.
|
||||
|
||||
+ COMPILATION_COMMENT=comment: Server comment, default
|
||||
"Source distribution".
|
||||
|
||||
+ MYSQL_TCP_PORT=port: Server port, default 3306.
|
||||
|
||||
+ DISABLE_GRANT_OPTIONS: Disables the --bootstrap,
|
||||
--skip-grant-tables, and --init-file options for mysqld.
|
||||
This option is available as of MySQL 5.1.15.
|
||||
For example (type the command on one line):
|
||||
C:\workdir>win\configure.js WITH_INNOBASE_STORAGE_ENGINE
|
||||
WITH_PARTITION_STORAGE_ENGINE MYSQL_SERVER_SUFFIX=-pro
|
||||
|
||||
4. From the work directory, execute the win\build-vs9.bat
|
||||
(Windows Visual Studio 2008), win\build-vs8.bat (Windows
|
||||
Visual Studio 2005), or win\build-vs71.bat (Windows Visual
|
||||
Stidion 2003) script, depending on the version of Visual
|
||||
Studio you have installed. The script invokes CMake, which
|
||||
generates the mysql.sln solution file.
|
||||
You can also use the corresponding 64-bit file (for example
|
||||
win\build-vs8_x64.bat or win\build-vs9_x64.bat) to build the
|
||||
64-bit version of MySQL. However, you cannot build the 64-bit
|
||||
version with Visual Studio Express Edition. You must use
|
||||
Visual Studio 2005 (8.0) or higher.
|
||||
|
||||
5. From the work directory, open the generated mysql.sln file
|
||||
with Visual Studio and select the proper configuration using
|
||||
the Configuration menu. The menu provides Debug, Release,
|
||||
RelwithDebInfo, MinRelInfo options. Then select Solution >
|
||||
Build to build the solution.
|
||||
Remember the configuration that you use in this step. It is
|
||||
important later when you run the test script because that
|
||||
script needs to know which configuration you used.
|
||||
|
||||
6. Test the server. The server built using the preceding
|
||||
instructions expects that the MySQL base directory and data
|
||||
directory are C:\mysql and C:\mysql\data by default. If you
|
||||
want to test your server using the source tree root directory
|
||||
and its data directory as the base directory and data
|
||||
directory, you need to tell the server their path names. You
|
||||
can either do this on the command line with the --basedir and
|
||||
--datadir options, or by placing appropriate options in an
|
||||
option file. (See Section 4.2.3.3, "Using Option Files.") If
|
||||
you have an existing data directory elsewhere that you want to
|
||||
use, you can specify its path name instead.
|
||||
When the server is running in standalone fashion or as a
|
||||
service based on your configuration, try to connect to it from
|
||||
the mysql interactive command-line utility.
|
||||
You can also run the standard test script, mysql-test-run.pl.
|
||||
This script is written in Perl, so you'll need either Cygwin
|
||||
or ActiveState Perl to run it. You may also need to install
|
||||
the modules required by the script. To run the test script,
|
||||
change location into the mysql-test directory under the work
|
||||
directory, set the MTR_VS_CONFIG environment variable to the
|
||||
configuration you selected earlier (or use the --vs-config
|
||||
option), and invoke mysql-test-run.pl. For example (using
|
||||
Cygwin and the bash shell):
|
||||
shell> cd mysql-test
|
||||
shell> export MTR_VS_CONFIG=debug
|
||||
shell> ./mysql-test-run.pl --force --timer
|
||||
shell> ./mysql-test-run.pl --force --timer --ps-protocol
|
||||
|
||||
When you are satisfied that the programs you have built are
|
||||
working correctly, stop the server. Now you can install the
|
||||
distribution. One way to do this is to use the make_win_bin_dist
|
||||
script in the scripts directory of the MySQL source distribution
|
||||
(see Section 4.4.2, "make_win_bin_dist --- Package MySQL
|
||||
Distribution as ZIP Archive"). This is a shell script, so you must
|
||||
have Cygwin installed if you want to use it. It creates a Zip
|
||||
archive of the built executables and support files that you can
|
||||
unpack in the location at which you want to install MySQL.
|
||||
|
||||
It is also possible to install MySQL by copying directories and
|
||||
files directly:
|
||||
|
||||
1. Create the directories where you want to install MySQL. For
|
||||
example, to install into C:\mysql, use these commands:
|
||||
C:\> mkdir C:\mysql
|
||||
C:\> mkdir C:\mysql\bin
|
||||
C:\> mkdir C:\mysql\data
|
||||
C:\> mkdir C:\mysql\share
|
||||
C:\> mkdir C:\mysql\scripts
|
||||
If you want to compile other clients and link them to MySQL,
|
||||
you should also create several additional directories:
|
||||
C:\> mkdir C:\mysql\include
|
||||
C:\> mkdir C:\mysql\lib
|
||||
C:\> mkdir C:\mysql\lib\debug
|
||||
C:\> mkdir C:\mysql\lib\opt
|
||||
If you want to benchmark MySQL, create this directory:
|
||||
C:\> mkdir C:\mysql\sql-bench
|
||||
Benchmarking requires Perl support. See Section 2.15, "Perl
|
||||
Installation Notes."
|
||||
|
||||
2. From the work directory, copy into the C:\mysql directory the
|
||||
following files and directories:
|
||||
C:\> cd \workdir
|
||||
C:\workdir> mkdir C:\mysql
|
||||
C:\workdir> mkdir C:\mysql\bin
|
||||
C:\workdir> copy client\Release\*.exe C:\mysql\bin
|
||||
C:\workdir> copy sql\Release\mysqld.exe C:\mysql\bin\mysqld.exe
|
||||
C:\workdir> xcopy scripts\*.* C:\mysql\scripts /E
|
||||
C:\workdir> xcopy share\*.* C:\mysql\share /E
|
||||
If you want to compile other clients and link them to MySQL,
|
||||
you should also copy several libraries and header files:
|
||||
C:\workdir> copy lib\Release\mysqlclient.lib C:\mysql\lib\debug
|
||||
C:\workdir> copy lib\Release\libmysql.* C:\mysql\lib\debug
|
||||
C:\workdir> copy lib\Release\zlib.* C:\mysql\lib\debug
|
||||
C:\workdir> copy lib\Release\mysqlclient.lib C:\mysql\lib\opt
|
||||
C:\workdir> copy lib\Release\libmysql.* C:\mysql\lib\opt
|
||||
C:\workdir> copy lib\Release\zlib.* C:\mysql\lib\opt
|
||||
C:\workdir> copy include\*.h C:\mysql\include
|
||||
C:\workdir> copy libmysql\libmysql.def C:\mysql\include
|
||||
|
||||
Note
|
||||
If you have compiled a Debug, rather than Release solution,
|
||||
you can replace Release with Debug in the source file names
|
||||
shown above.
|
||||
If you want to benchmark MySQL, you should also do this:
|
||||
C:\workdir> xcopy sql-bench\*.* C:\mysql\bench /E
|
||||
|
||||
After installation, set up and start the server in the same way as
|
||||
for binary Windows distributions. This includes creating the
|
||||
system tables by running mysql_install_db. For more information,
|
||||
see Section 2.5, "Installing MySQL on Windows."
|
||||
1108
dep/mysqllite/README
1108
dep/mysqllite/README
File diff suppressed because it is too large
Load Diff
4
dep/mysqllite/VERSION
Normal file
4
dep/mysqllite/VERSION
Normal file
@@ -0,0 +1,4 @@
|
||||
MYSQL_VERSION_MAJOR=5
|
||||
MYSQL_VERSION_MINOR=5
|
||||
MYSQL_VERSION_PATCH=9
|
||||
MYSQL_VERSION_EXTRA=
|
||||
43
dep/mysqllite/cmake/character_sets.cmake
Normal file
43
dep/mysqllite/cmake/character_sets.cmake
Normal file
@@ -0,0 +1,43 @@
|
||||
# Copyright (C) 2009 Sun Microsystems, Inc
|
||||
#
|
||||
# This program 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; version 2 of the License.
|
||||
#
|
||||
# This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#Charsets and collations
|
||||
IF(NOT DEFAULT_CHARSET)
|
||||
SET(DEFAULT_CHARSET "latin1")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT DEFAULT_COLLATIONS)
|
||||
SET(DEFAULT_COLLATION "latin1_swedish_ci")
|
||||
ENDIF()
|
||||
|
||||
SET(CHARSETS_AVAILABLE
|
||||
binary armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257
|
||||
cp850 cp852 cp866 cp932 dec8 euckr gb2312 gbk geostd8
|
||||
greek hebrew hp8 keybcs2 koi8r koi8u
|
||||
latin1 latin2 latin5 latin7 macce macroman
|
||||
swe7 tis620 ucs2 utf8 utf8mb4 utf16 utf32)
|
||||
|
||||
SET(MYSQL_DEFAULT_CHARSET_NAME "${DEFAULT_CHARSET}")
|
||||
SET(MYSQL_DEFAULT_COLLATION_NAME "${DEFAULT_COLLATION}")
|
||||
|
||||
FOREACH(cs in ${CHARSETS_AVAILABLE})
|
||||
SET(HAVE_CHARSET_${cs} 1)
|
||||
ENDFOREACH()
|
||||
|
||||
SET(HAVE_UCA_COLLATIONS 1)
|
||||
|
||||
SET(HAVE_UTF8_GENERAL_CS 1)
|
||||
SET(USE_MB 1)
|
||||
SET(USE_MB_IDENT 1)
|
||||
107
dep/mysqllite/cmake/mysql_version.cmake
Normal file
107
dep/mysqllite/cmake/mysql_version.cmake
Normal file
@@ -0,0 +1,107 @@
|
||||
# Copyright (C) 2009 Sun Microsystems, Inc
|
||||
#
|
||||
# This program 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; version 2 of the License.
|
||||
#
|
||||
# This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#
|
||||
# Global constants, only to be changed between major releases.
|
||||
#
|
||||
|
||||
SET(SHARED_LIB_MAJOR_VERSION "16")
|
||||
SET(PROTOCOL_VERSION "10")
|
||||
SET(DOT_FRM_VERSION "6")
|
||||
|
||||
# Generate "something" to trigger cmake rerun when VERSION changes
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/VERSION
|
||||
${CMAKE_CURRENT_BINARY_DIR}/VERSION.dep
|
||||
)
|
||||
|
||||
# Read value for a variable from VERSION.
|
||||
|
||||
MACRO(MYSQL_GET_CONFIG_VALUE keyword var)
|
||||
IF(NOT ${var})
|
||||
FILE (STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION str REGEX "^[ ]*${keyword}=")
|
||||
IF(str)
|
||||
STRING(REPLACE "${keyword}=" "" str ${str})
|
||||
STRING(REGEX REPLACE "[ ].*" "" str "${str}")
|
||||
SET(${var} ${str})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
# Read mysql version for configure script
|
||||
|
||||
MACRO(GET_MYSQL_VERSION)
|
||||
MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MAJOR" MAJOR_VERSION)
|
||||
MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MINOR" MINOR_VERSION)
|
||||
MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_PATCH" PATCH_VERSION)
|
||||
MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_EXTRA" EXTRA_VERSION)
|
||||
|
||||
IF(NOT MAJOR_VERSION OR NOT MINOR_VERSION OR NOT PATCH_VERSION)
|
||||
MESSAGE(FATAL_ERROR "VERSION file cannot be parsed.")
|
||||
ENDIF()
|
||||
|
||||
SET(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${EXTRA_VERSION}")
|
||||
MESSAGE("-- MySQL ${VERSION}")
|
||||
SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version")
|
||||
SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
|
||||
STRING(REPLACE "-" "_" MYSQL_RPM_VERSION "${VERSION}")
|
||||
MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH_VERSION}")
|
||||
ENDMACRO()
|
||||
|
||||
# Get mysql version and other interesting variables
|
||||
GET_MYSQL_VERSION()
|
||||
|
||||
SET(MYSQL_TCP_PORT_DEFAULT "3306")
|
||||
|
||||
IF(NOT MYSQL_TCP_PORT)
|
||||
SET(MYSQL_TCP_PORT ${MYSQL_TCP_PORT_DEFAULT})
|
||||
SET(MYSQL_TCP_PORT_DEFAULT "0")
|
||||
ELSEIF(MYSQL_TCP_PORT EQUAL MYSQL_TCP_PORT_DEFAULT)
|
||||
SET(MYSQL_TCP_PORT_DEFAULT "0")
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(NOT MYSQL_UNIX_ADDR)
|
||||
SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
|
||||
ENDIF()
|
||||
IF(NOT COMPILATION_COMMENT)
|
||||
SET(COMPILATION_COMMENT "Source distribution lite for Trinity Core")
|
||||
ENDIF()
|
||||
|
||||
# Windows 'date' command has unpredictable output, so cannot rely on it to
|
||||
# set MYSQL_COPYRIGHT_YEAR - if someone finds a portable way to do so then
|
||||
# it might be useful
|
||||
# EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE TMP_DATE)
|
||||
# STRING(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" MYSQL_COPYRIGHT_YEAR ${TMP_DATE})
|
||||
|
||||
# Add version information to the exe and dll files
|
||||
# Refer to http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx
|
||||
# for more info.
|
||||
IF(MSVC)
|
||||
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
SET(FILETYPE VFT_DLL)
|
||||
CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/versioninfo_dll.rc)
|
||||
|
||||
FUNCTION(ADD_VERSION_INFO target sources_var)
|
||||
SET(rcfile ${CMAKE_CURRENT_BINARY_DIR}/versioninfo_dll.rc)
|
||||
SET(${sources_var} ${${sources_var}} ${rcfile} PARENT_SCOPE)
|
||||
ENDFUNCTION()
|
||||
ELSE()
|
||||
FUNCTION(ADD_VERSION_INFO)
|
||||
ENDFUNCTION()
|
||||
ENDIF()
|
||||
142
dep/mysqllite/cmake/os/Windows.cmake
Normal file
142
dep/mysqllite/cmake/os/Windows.cmake
Normal file
@@ -0,0 +1,142 @@
|
||||
# Copyright (C) 2010 Sun Microsystems, Inc
|
||||
#
|
||||
# This program 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; version 2 of the License.
|
||||
#
|
||||
# This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# This file includes Windows specific hacks, mostly around compiler flags
|
||||
|
||||
INCLUDE (CheckCSourceCompiles)
|
||||
INCLUDE (CheckCXXSourceCompiles)
|
||||
INCLUDE (CheckStructHasMember)
|
||||
INCLUDE (CheckLibraryExists)
|
||||
INCLUDE (CheckFunctionExists)
|
||||
INCLUDE (CheckCCompilerFlag)
|
||||
INCLUDE (CheckCSourceRuns)
|
||||
INCLUDE (CheckSymbolExists)
|
||||
INCLUDE (CheckTypeSize)
|
||||
|
||||
# avoid running system checks by using pre-cached check results
|
||||
# system checks are expensive on VS since every tiny program is to be compiled in
|
||||
# a VC solution.
|
||||
GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
INCLUDE(${_SCRIPT_DIR}/WindowsCache.cmake)
|
||||
|
||||
|
||||
# OS display name (version_compile_os etc).
|
||||
# Used by the test suite to ignore bugs on some platforms,
|
||||
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||
SET(SYSTEM_TYPE "Win64")
|
||||
ELSE()
|
||||
SET(SYSTEM_TYPE "Win32")
|
||||
ENDIF()
|
||||
|
||||
# Intel compiler is almost Visual C++
|
||||
# (same compile flags etc). Set MSVC flag
|
||||
IF(CMAKE_C_COMPILER MATCHES "icl")
|
||||
SET(MSVC TRUE)
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS("-D__WIN__ -D_CRT_SECURE_NO_DEPRECATE")
|
||||
ADD_DEFINITIONS("-D_WIN32_WINNT=0x0501")
|
||||
# Speed up build process excluding unused header files
|
||||
ADD_DEFINITIONS("-DWIN32_LEAN_AND_MEAN")
|
||||
|
||||
# Adjust compiler and linker flags
|
||||
IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
# mininal architecture flags, i486 enables GCC atomics
|
||||
ADD_DEFINITIONS(-march=i486)
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC)
|
||||
# Remove support for exceptions
|
||||
FOREACH(flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_INIT)
|
||||
STRING(REPLACE "/EHsc" "" "${flag}" "${${flag}}")
|
||||
ENDFOREACH()
|
||||
|
||||
# Fix CMake's predefined huge stack size
|
||||
STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996 /wd4244 /wd4267 /wd4090")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /we4099 /wd4244 /wd4267")
|
||||
ENDIF()
|
||||
|
||||
# System checks
|
||||
SET(SIGNAL_WITH_VIO_CLOSE 1) # Something that runtime team needs
|
||||
|
||||
# IPv6 constants appeared in Vista SDK first. We need to define them in any case if they are
|
||||
# not in headers, to handle dual mode sockets correctly.
|
||||
CHECK_SYMBOL_EXISTS(IPPROTO_IPV6 "winsock2.h" HAVE_IPPROTO_IPV6)
|
||||
IF(NOT HAVE_IPPROTO_IPV6)
|
||||
SET(HAVE_IPPROTO_IPV6 41)
|
||||
ENDIF()
|
||||
CHECK_SYMBOL_EXISTS(IPV6_V6ONLY "winsock2.h;ws2ipdef.h" HAVE_IPV6_V6ONLY)
|
||||
IF(NOT HAVE_IPV6_V6ONLY)
|
||||
SET(IPV6_V6ONLY 27)
|
||||
ENDIF()
|
||||
|
||||
# Some standard functions exist there under different
|
||||
# names (e.g popen is _popen or strok_r is _strtok_s)
|
||||
# If a replacement function exists, HAVE_FUNCTION is
|
||||
# defined to 1. CMake variable <function_name> will also
|
||||
# be defined to the replacement name.
|
||||
# So for example, CHECK_FUNCTION_REPLACEMENT(popen _popen)
|
||||
# will define HAVE_POPEN to 1 and set variable named popen
|
||||
# to _popen. If the header template, one needs to have
|
||||
# cmakedefine popen @popen@ which will expand to
|
||||
# define popen _popen after CONFIGURE_FILE
|
||||
|
||||
MACRO(CHECK_FUNCTION_REPLACEMENT function replacement)
|
||||
STRING(TOUPPER ${function} function_upper)
|
||||
CHECK_FUNCTION_EXISTS(${function} HAVE_${function_upper})
|
||||
IF(NOT HAVE_${function_upper})
|
||||
CHECK_FUNCTION_EXISTS(${replacement} HAVE_${replacement})
|
||||
IF(HAVE_${replacement})
|
||||
SET(HAVE_${function_upper} 1 )
|
||||
SET(${function} ${replacement})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
MACRO(CHECK_SYMBOL_REPLACEMENT symbol replacement header)
|
||||
STRING(TOUPPER ${symbol} symbol_upper)
|
||||
CHECK_SYMBOL_EXISTS(${symbol} ${header} HAVE_${symbol_upper})
|
||||
IF(NOT HAVE_${symbol_upper})
|
||||
CHECK_SYMBOL_EXISTS(${replacement} ${header} HAVE_${replacement})
|
||||
IF(HAVE_${replacement})
|
||||
SET(HAVE_${symbol_upper} 1)
|
||||
SET(${symbol} ${replacement})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
CHECK_SYMBOL_REPLACEMENT(S_IROTH _S_IREAD sys/stat.h)
|
||||
CHECK_SYMBOL_REPLACEMENT(S_IFIFO _S_IFIFO sys/stat.h)
|
||||
CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h)
|
||||
CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h)
|
||||
CHECK_SYMBOL_REPLACEMENT(isnan _isnan float.h)
|
||||
CHECK_SYMBOL_REPLACEMENT(finite _finite float.h)
|
||||
CHECK_FUNCTION_REPLACEMENT(popen _popen)
|
||||
CHECK_FUNCTION_REPLACEMENT(pclose _pclose)
|
||||
CHECK_FUNCTION_REPLACEMENT(access _access)
|
||||
CHECK_FUNCTION_REPLACEMENT(strcasecmp _stricmp)
|
||||
CHECK_FUNCTION_REPLACEMENT(strncasecmp _strnicmp)
|
||||
CHECK_FUNCTION_REPLACEMENT(snprintf _snprintf)
|
||||
CHECK_FUNCTION_REPLACEMENT(strtok_r strtok_s)
|
||||
CHECK_FUNCTION_REPLACEMENT(strtoll _strtoi64)
|
||||
CHECK_FUNCTION_REPLACEMENT(strtoull _strtoui64)
|
||||
CHECK_FUNCTION_REPLACEMENT(vsnprintf _vsnprintf)
|
||||
CHECK_TYPE_SIZE(ssize_t SIZE_OF_SSIZE_T)
|
||||
IF(NOT HAVE_SIZE_OF_SSIZE_T)
|
||||
SET(ssize_t SSIZE_T)
|
||||
ENDIF()
|
||||
|
||||
SET(FN_NO_CASE_SENSE 1)
|
||||
356
dep/mysqllite/cmake/os/WindowsCache.cmake
Normal file
356
dep/mysqllite/cmake/os/WindowsCache.cmake
Normal file
@@ -0,0 +1,356 @@
|
||||
# Copyright (C) 2010 Sun Microsystems, Inc
|
||||
#
|
||||
# This program 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; version 2 of the License.
|
||||
#
|
||||
# This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# Avoid system checks on Windows by pre-caching results. Most of the system checks
|
||||
# are not relevant for Windows anyway and it takes lot more time to run them,
|
||||
# since CMake to creates a Visual Studio project for each tiny test.
|
||||
# Note that only we cache values on VC++ only, MinGW would give slightly
|
||||
# different results.
|
||||
|
||||
IF(MSVC)
|
||||
SET(HAVE_ACCESS 1 CACHE INTERNAL "")
|
||||
SET(HAVE_AIO_H CACHE INTERNAL "")
|
||||
SET(HAVE_AIO_READ CACHE INTERNAL "")
|
||||
SET(HAVE_ALARM CACHE INTERNAL "")
|
||||
SET(HAVE_ALLOCA_H CACHE INTERNAL "")
|
||||
SET(HAVE_ARPA_INET_H CACHE INTERNAL "")
|
||||
SET(HAVE_ASM_MSR_H CACHE INTERNAL "")
|
||||
SET(HAVE_BACKTRACE CACHE INTERNAL "")
|
||||
SET(HAVE_BACKTRACE_SYMBOLS CACHE INTERNAL "")
|
||||
SET(HAVE_BACKTRACE_SYMBOLS_FD CACHE INTERNAL "")
|
||||
SET(HAVE_BFILL CACHE INTERNAL "")
|
||||
SET(HAVE_BMOVE CACHE INTERNAL "")
|
||||
SET(HAVE_BSD_SIGNALS CACHE INTERNAL "")
|
||||
SET(HAVE_BSEARCH 1 CACHE INTERNAL "")
|
||||
SET(HAVE_BSS_START CACHE INTERNAL "")
|
||||
SET(HAVE_BZERO CACHE INTERNAL "")
|
||||
SET(HAVE_CHOWN CACHE INTERNAL "")
|
||||
SET(HAVE_CLOCK_GETTIME CACHE INTERNAL "")
|
||||
SET(HAVE_COMPRESS CACHE INTERNAL "")
|
||||
SET(HAVE_CRYPT CACHE INTERNAL "")
|
||||
SET(HAVE_CRYPT_H CACHE INTERNAL "")
|
||||
SET(HAVE_CUSERID CACHE INTERNAL "")
|
||||
SET(HAVE_CXX_NEW 1 CACHE INTERNAL "")
|
||||
SET(HAVE_DECL_MADVISE CACHE INTERNAL "")
|
||||
SET(HAVE_DIRECTIO CACHE INTERNAL "")
|
||||
SET(HAVE_DIRENT_H CACHE INTERNAL "")
|
||||
SET(HAVE_DLERROR CACHE INTERNAL "")
|
||||
SET(HAVE_DLFCN_H CACHE INTERNAL "")
|
||||
SET(HAVE_DLOPEN CACHE INTERNAL "")
|
||||
SET(HAVE_DOPRNT CACHE INTERNAL "")
|
||||
SET(HAVE_EXECINFO_H CACHE INTERNAL "")
|
||||
SET(HAVE_FCHMOD CACHE INTERNAL "")
|
||||
SET(HAVE_FCNTL CACHE INTERNAL "")
|
||||
SET(HAVE_FCNTL_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_FCNTL_NONBLOCK CACHE INTERNAL "")
|
||||
SET(HAVE_FCONVERT CACHE INTERNAL "")
|
||||
SET(HAVE_FDATASYNC CACHE INTERNAL "")
|
||||
SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
|
||||
SET(HAVE_FENV_H CACHE INTERNAL "")
|
||||
SET(HAVE_FESETROUND CACHE INTERNAL "")
|
||||
SET(HAVE_FGETLN CACHE INTERNAL "")
|
||||
SET(HAVE_FINITE CACHE INTERNAL "")
|
||||
SET(HAVE_FINITE_IN_MATH_H CACHE INTERNAL "")
|
||||
SET(HAVE_FLOATINGPOINT_H CACHE INTERNAL "")
|
||||
SET(HAVE_FLOAT_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_FLOCKFILE CACHE INTERNAL "")
|
||||
SET(HAVE_FNMATCH_H CACHE INTERNAL "")
|
||||
SET(HAVE_FPSETMASK CACHE INTERNAL "")
|
||||
SET(HAVE_FPU_CONTROL_H CACHE INTERNAL "")
|
||||
SET(HAVE_FSEEKO CACHE INTERNAL "")
|
||||
SET(HAVE_FSYNC CACHE INTERNAL "")
|
||||
SET(HAVE_FTIME 1 CACHE INTERNAL "")
|
||||
SET(HAVE_FTRUNCATE CACHE INTERNAL "")
|
||||
SET(HAVE_GETADDRINFO 1 CACHE INTERNAL "")
|
||||
SET(HAVE_GETCWD 1 CACHE INTERNAL "")
|
||||
SET(HAVE_GETHOSTBYADDR_R CACHE INTERNAL "")
|
||||
SET(HAVE_GETHOSTBYNAME_R CACHE INTERNAL "")
|
||||
SET(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE CACHE INTERNAL "")
|
||||
SET(HAVE_GETHOSTBYNAME_R_RETURN_INT CACHE INTERNAL "")
|
||||
SET(HAVE_GETHRTIME CACHE INTERNAL "")
|
||||
SET(HAVE_GETLINE CACHE INTERNAL "")
|
||||
SET(HAVE_GETNAMEINFO CACHE INTERNAL "")
|
||||
SET(HAVE_GETPAGESIZE CACHE INTERNAL "")
|
||||
SET(HAVE_GETPASS CACHE INTERNAL "")
|
||||
SET(HAVE_GETPASSPHRASE CACHE INTERNAL "")
|
||||
SET(HAVE_GETPWNAM CACHE INTERNAL "")
|
||||
SET(HAVE_GETPWUID CACHE INTERNAL "")
|
||||
SET(HAVE_GETRLIMIT CACHE INTERNAL "")
|
||||
SET(HAVE_GETRUSAGE CACHE INTERNAL "")
|
||||
SET(HAVE_GETTIMEOFDAY CACHE INTERNAL "")
|
||||
SET(HAVE_GETWD CACHE INTERNAL "")
|
||||
SET(HAVE_GMTIME_R CACHE INTERNAL "")
|
||||
SET(HAVE_GRP_H CACHE INTERNAL "")
|
||||
SET(HAVE_IA64INTRIN_H CACHE INTERNAL "")
|
||||
SET(HAVE_IEEEFP_H CACHE INTERNAL "")
|
||||
SET(HAVE_INDEX CACHE INTERNAL "")
|
||||
SET(HAVE_INITGROUPS CACHE INTERNAL "")
|
||||
SET(HAVE_INTTYPES_H CACHE INTERNAL "")
|
||||
SET(HAVE_IPPROTO_IPV6 CACHE INTERNAL "")
|
||||
SET(HAVE_IPV6 TRUE CACHE INTERNAL "")
|
||||
SET(HAVE_IPV6_V6ONLY 1 CACHE INTERNAL "")
|
||||
SET(HAVE_ISINF CACHE INTERNAL "")
|
||||
SET(HAVE_ISNAN CACHE INTERNAL "")
|
||||
SET(HAVE_ISSETUGID CACHE INTERNAL "")
|
||||
SET(HAVE_LANGINFO_H CACHE INTERNAL "")
|
||||
SET(HAVE_LDIV 1 CACHE INTERNAL "")
|
||||
SET(HAVE_LIMITS_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_LOCALE_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_LOCALTIME_R CACHE INTERNAL "")
|
||||
SET(HAVE_LOG2 CACHE INTERNAL "")
|
||||
SET(HAVE_LONGJMP 1 CACHE INTERNAL "")
|
||||
SET(HAVE_LRAND48 CACHE INTERNAL "")
|
||||
SET(HAVE_LSTAT CACHE INTERNAL "")
|
||||
SET(HAVE_MADVISE CACHE INTERNAL "")
|
||||
SET(HAVE_MALLINFO CACHE INTERNAL "")
|
||||
SET(HAVE_MALLOC_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_MEMALIGN CACHE INTERNAL "")
|
||||
SET(HAVE_MEMCPY 1 CACHE INTERNAL "")
|
||||
SET(HAVE_MEMMOVE 1 CACHE INTERNAL "")
|
||||
SET(HAVE_MEMORY_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_MKSTEMP CACHE INTERNAL "")
|
||||
SET(HAVE_MLOCK CACHE INTERNAL "")
|
||||
SET(HAVE_MLOCKALL CACHE INTERNAL "")
|
||||
SET(HAVE_MMAP CACHE INTERNAL "")
|
||||
SET(HAVE_MMAP64 CACHE INTERNAL "")
|
||||
SET(HAVE_NETINET_IN6_H CACHE INTERNAL "")
|
||||
SET(HAVE_NETINET_IN_H CACHE INTERNAL "")
|
||||
SET(HAVE_NL_LANGINFO CACHE INTERNAL "")
|
||||
SET(HAVE_PASE_ENVIRONMENT CACHE INTERNAL "")
|
||||
SET(HAVE_PATHS_H CACHE INTERNAL "")
|
||||
SET(HAVE_PCLOSE CACHE INTERNAL "")
|
||||
SET(HAVE_PERROR 1 CACHE INTERNAL "")
|
||||
SET(HAVE_PEERCRED CACHE INTERNAL "")
|
||||
SET(HAVE_POLL_H CACHE INTERNAL "")
|
||||
SET(HAVE_POPEN CACHE INTERNAL "")
|
||||
SET(HAVE_POLL CACHE INTERNAL "")
|
||||
SET(HAVE_PORT_CREATE CACHE INTERNAL "")
|
||||
SET(HAVE_PORT_H CACHE INTERNAL "")
|
||||
SET(HAVE_POSIX_FALLOCATE CACHE INTERNAL "")
|
||||
SET(HAVE_POSIX_SIGNALS CACHE INTERNAL "")
|
||||
SET(HAVE_PREAD CACHE INTERNAL "")
|
||||
SET(HAVE_PRINTSTACK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_CREATE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_GETSTACKSIZE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_SETSCOPE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_SETSTACKSIZE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_CONDATTR_CREATE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_CONDATTR_SETCLOCK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_INIT CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_KEY_DELETE CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_RWLOCK_RDLOCK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_SIGMASK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_THREADMASK CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_YIELD_NP CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_YIELD_ZERO_ARG CACHE INTERNAL "")
|
||||
SET(HAVE_PUTENV 1 CACHE INTERNAL "")
|
||||
SET(HAVE_PWD_H CACHE INTERNAL "")
|
||||
SET(HAVE_RDTSCLL CACHE INTERNAL "")
|
||||
SET(HAVE_READDIR_R CACHE INTERNAL "")
|
||||
SET(HAVE_READLINK CACHE INTERNAL "")
|
||||
SET(HAVE_READ_REAL_TIME CACHE INTERNAL "")
|
||||
SET(HAVE_REALPATH CACHE INTERNAL "")
|
||||
SET(HAVE_REGCOMP CACHE INTERNAL "")
|
||||
SET(HAVE_RENAME 1 CACHE INTERNAL "")
|
||||
SET(HAVE_RE_COMP CACHE INTERNAL "")
|
||||
SET(HAVE_RINT CACHE INTERNAL "")
|
||||
SET(HAVE_RWLOCK_INIT CACHE INTERNAL "")
|
||||
SET(HAVE_SCHED_H CACHE INTERNAL "")
|
||||
SET(HAVE_SCHED_YIELD CACHE INTERNAL "")
|
||||
SET(HAVE_SELECT 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SELECT_H CACHE INTERNAL "")
|
||||
SET(HAVE_SEMAPHORE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SETENV CACHE INTERNAL "")
|
||||
SET(HAVE_SETFD CACHE INTERNAL "")
|
||||
SET(HAVE_SETLOCALE 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SHMAT CACHE INTERNAL "")
|
||||
SET(HAVE_SHMCTL CACHE INTERNAL "")
|
||||
SET(HAVE_SHMDT CACHE INTERNAL "")
|
||||
SET(HAVE_SHMGET CACHE INTERNAL "")
|
||||
SET(HAVE_SIGACTION CACHE INTERNAL "")
|
||||
SET(HAVE_SIGADDSET CACHE INTERNAL "")
|
||||
SET(HAVE_SIGEMPTYSET CACHE INTERNAL "")
|
||||
SET(HAVE_SIGHOLD CACHE INTERNAL "")
|
||||
SET(HAVE_SIGINT 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SIGPIPE CACHE INTERNAL "")
|
||||
SET(HAVE_SIGQUIT CACHE INTERNAL "")
|
||||
SET(HAVE_SIGSET CACHE INTERNAL "")
|
||||
SET(HAVE_SIGTERM 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SIGTHREADMASK CACHE INTERNAL "")
|
||||
SET(HAVE_SIGWAIT CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_BOOL FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_CHAR TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_CHAR 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_CHARP TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_CHARP ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_IN6_ADDR TRUE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_INT 4 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT16 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT32 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT64 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_INT8 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_LONG TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_LONG 4 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_LONG_LONG TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_LONG_LONG 8 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_MODE_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_OFF_T TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_OFF_T 4 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SHORT TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_SHORT 2 CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SIGSET_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SIZE_T TRUE CACHE INTERNAL "")
|
||||
SET(SIZEOF_SIZE_T ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SOCKADDR_IN6 TRUE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_SOCKLEN_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UCHAR FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT16 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT32 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT64 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_UINT8 FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_ULONG FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZEOF_U_INT32_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SIZE_OF_SSIZE_T FALSE CACHE INTERNAL "")
|
||||
SET(HAVE_SLEEP CACHE INTERNAL "")
|
||||
SET(HAVE_SNPRINTF CACHE INTERNAL "")
|
||||
SET(HAVE_SOCKADDR_STORAGE_SS_FAMILY 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SOLARIS_STYLE_GETHOST CACHE INTERNAL "")
|
||||
SET(STACK_DIRECTION -1 CACHE INTERNAL "")
|
||||
SET(HAVE_STDARG_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STDDEF_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STDINT_H CACHE INTERNAL "")
|
||||
SET(HAVE_STDLIB_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STPCPY CACHE INTERNAL "")
|
||||
SET(HAVE_STRCASECMP CACHE INTERNAL "")
|
||||
SET(HAVE_STRCOLL 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRDUP 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRERROR 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRINGS_H CACHE INTERNAL "")
|
||||
SET(HAVE_STRING_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRLCAT CACHE INTERNAL "")
|
||||
SET(HAVE_STRLCPY CACHE INTERNAL "")
|
||||
SET(HAVE_STRNCASECMP CACHE INTERNAL "")
|
||||
IF(MSVC_VERSION GREATER 1310)
|
||||
SET(HAVE_STRNLEN 1 CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
SET(HAVE_STRPBRK 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRSEP CACHE INTERNAL "")
|
||||
SET(HAVE_STRSIGNAL CACHE INTERNAL "")
|
||||
SET(HAVE_STRSTR 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOK_R CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOL 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOLL CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOUL 1 CACHE INTERNAL "")
|
||||
SET(HAVE_STRTOULL CACHE INTERNAL "")
|
||||
SET(HAVE_SVR3_SIGNALS CACHE INTERNAL "")
|
||||
SET(HAVE_SYNCH_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYSENT_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_CDEFS_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_DIR_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_ERRLIST CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_FILE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_FPU_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_IOCTL_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_IPC_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_MALLOC_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_MMAN_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_PARAM_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_PRCTL_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_PTEM_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_PTE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_RESOURCE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_SELECT_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_SHM_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_SOCKET_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_STAT_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_STREAM_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TERMCAP_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TIMEB_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TIMES_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TIME_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_TYPES_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_UN_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_UTIME_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_VADVISE_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_WAIT_H CACHE INTERNAL "")
|
||||
SET(HAVE_TCGETATTR CACHE INTERNAL "")
|
||||
SET(HAVE_TELL 1 CACHE INTERNAL "")
|
||||
SET(HAVE_TEMPNAM 1 CACHE INTERNAL "")
|
||||
SET(HAVE_TERMCAP_H CACHE INTERNAL "")
|
||||
SET(HAVE_TERMIOS_H CACHE INTERNAL "")
|
||||
SET(HAVE_TERMIO_H CACHE INTERNAL "")
|
||||
SET(HAVE_TERM_H CACHE INTERNAL "")
|
||||
SET(HAVE_THR_SETCONCURRENCY CACHE INTERNAL "")
|
||||
SET(HAVE_THR_YIELD CACHE INTERNAL "")
|
||||
SET(HAVE_TIME 1 CACHE INTERNAL "")
|
||||
SET(HAVE_TIMES CACHE INTERNAL "")
|
||||
SET(HAVE_TIMESPEC_TS_SEC CACHE INTERNAL "")
|
||||
SET(HAVE_TIME_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_TZNAME 1 CACHE INTERNAL "")
|
||||
SET(HAVE_UNISTD_H CACHE INTERNAL "")
|
||||
SET(HAVE_UTIME_H CACHE INTERNAL "")
|
||||
SET(HAVE_VALLOC CACHE INTERNAL "")
|
||||
SET(HAVE_VARARGS_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_VASPRINTF CACHE INTERNAL "")
|
||||
SET(HAVE_VPRINTF 1 CACHE INTERNAL "")
|
||||
IF(MSVC_VERSION GREATER 1310)
|
||||
SET(HAVE_VSNPRINTF 1 CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
SET(HAVE_WEAK_SYMBOL CACHE INTERNAL "")
|
||||
SET(HAVE_WORDS_BIGENDIAN TRUE CACHE INTERNAL "")
|
||||
SET(WORDS_BIGENDIAN CACHE INTERNAL "")
|
||||
SET(HAVE__S_IFIFO 1 CACHE INTERNAL "")
|
||||
SET(HAVE__S_IREAD 1 CACHE INTERNAL "")
|
||||
SET(HAVE__finite 1 CACHE INTERNAL "")
|
||||
SET(HAVE__isnan 1 CACHE INTERNAL "")
|
||||
SET(HAVE__pclose 1 CACHE INTERNAL "")
|
||||
SET(HAVE__popen 1 CACHE INTERNAL "")
|
||||
SET(HAVE__snprintf 1 CACHE INTERNAL "")
|
||||
SET(HAVE__stricmp 1 CACHE INTERNAL "")
|
||||
SET(HAVE__strnicmp 1 CACHE INTERNAL "")
|
||||
SET(HAVE__strtoi64 1 CACHE INTERNAL "")
|
||||
SET(HAVE__strtoui64 1 CACHE INTERNAL "")
|
||||
IF(MSVC_VERSION GREATER 1310)
|
||||
SET(HAVE_strtok_s 1 CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
SET(STDC_HEADERS CACHE 1 INTERNAL "")
|
||||
SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "")
|
||||
SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "")
|
||||
SET(STRUCT_DIRENT_HAS_D_NAMLEN CACHE INTERNAL "")
|
||||
SET(TIME_WITH_SYS_TIME CACHE INTERNAL "")
|
||||
SET(TIOCSTAT_IN_SYS_IOCTL CACHE INTERNAL "")
|
||||
SET(HAVE_S_IROTH CACHE INTERNAL "")
|
||||
SET(HAVE_S_IFIFO CACHE INTERNAL "")
|
||||
SET(QSORT_TYPE_IS_VOID 1 CACHE INTERNAL "")
|
||||
SET(SIGNAL_RETURN_TYPE_IS_VOID 1 CACHE INTERNAL "")
|
||||
SET(C_HAS_inline CACHE INTERNAL "")
|
||||
SET(C_HAS___inline 1 CACHE INTERNAL "")
|
||||
SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
|
||||
SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
|
||||
SET(HAVE_CXXABI_H CACHE INTERNAL "")
|
||||
SET(HAVE_NDIR_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
|
||||
SET(HAVE_ASM_TERMBITS_H CACHE INTERNAL "")
|
||||
SET(HAVE_TERMBITS_H CACHE INTERNAL "")
|
||||
SET(HAVE_VIS_H CACHE INTERNAL "")
|
||||
SET(HAVE_WCHAR_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_WCTYPE_H 1 CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP CACHE INTERNAL "")
|
||||
SET(HAVE_SOCKADDR_IN_SIN_LEN CACHE INTERNAL "")
|
||||
SET(HAVE_SOCKADDR_IN6_SIN6_LEN CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright (C) 2005 MySQL AB
|
||||
|
||||
/* Copyright (C) 2009 Sun Microsystems, Inc
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
@@ -11,24 +11,21 @@
|
||||
|
||||
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 */
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/* Check stack direction (0-down, 1-up) */
|
||||
int f(int *a)
|
||||
{
|
||||
int b;
|
||||
return(&b > a)?1:0;
|
||||
}
|
||||
/*
|
||||
This is a header for libraries containing functions used in both server and
|
||||
only some of clients (but not in libmysql)...
|
||||
Prevent compiler optimizations by calling function
|
||||
through pointer.
|
||||
*/
|
||||
|
||||
#ifndef _my_user_h_
|
||||
#define _my_user_h_
|
||||
|
||||
#include <my_global.h>
|
||||
|
||||
C_MODE_START
|
||||
|
||||
void parse_user(const char *user_id_str, size_t user_id_len,
|
||||
char *user_name_str, size_t *user_name_len,
|
||||
char *host_name_str, size_t *host_name_len);
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* _my_user_h_ */
|
||||
volatile int (*ptr_f)(int *) = f;
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
return ptr_f(&a);
|
||||
}
|
||||
23
dep/mysqllite/cmake/versioninfo.rc.in
Normal file
23
dep/mysqllite/cmake/versioninfo.rc.in
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <windows.h>
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH_VERSION@,0
|
||||
PRODUCTVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH_VERSION@,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS 0
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE @FILETYPE@
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "FileVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@.0\0"
|
||||
VALUE "ProductVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@.0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
618
dep/mysqllite/config.h.cmake
Normal file
618
dep/mysqllite/config.h.cmake
Normal file
@@ -0,0 +1,618 @@
|
||||
/* Copyright (C) 2009, 2011, Oracle and/or its affiliates. All rights
|
||||
reserved
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef MY_CONFIG_H
|
||||
#define MY_CONFIG_H
|
||||
#cmakedefine DOT_FRM_VERSION @DOT_FRM_VERSION@
|
||||
/* Headers we may want to use. */
|
||||
#cmakedefine STDC_HEADERS 1
|
||||
#cmakedefine _GNU_SOURCE 1
|
||||
#cmakedefine HAVE_ALLOCA_H 1
|
||||
#cmakedefine HAVE_AIO_H 1
|
||||
#cmakedefine HAVE_ARPA_INET_H 1
|
||||
#cmakedefine HAVE_ASM_MSR_H 1
|
||||
#cmakedefine HAVE_ASM_TERMBITS_H 1
|
||||
#cmakedefine HAVE_BSEARCH 1
|
||||
#cmakedefine HAVE_CRYPT_H 1
|
||||
#cmakedefine HAVE_CURSES_H 1
|
||||
#cmakedefine HAVE_CXXABI_H 1
|
||||
#cmakedefine HAVE_NCURSES_H 1
|
||||
#cmakedefine HAVE_NDIR_H 1
|
||||
#cmakedefine HAVE_DIRENT_H 1
|
||||
#cmakedefine HAVE_DLFCN_H 1
|
||||
#cmakedefine HAVE_EXECINFO_H 1
|
||||
#cmakedefine HAVE_FCNTL_H 1
|
||||
#cmakedefine HAVE_FENV_H 1
|
||||
#cmakedefine HAVE_FLOAT_H 1
|
||||
#cmakedefine HAVE_FLOATINGPOINT_H 1
|
||||
#cmakedefine HAVE_FNMATCH_H 1
|
||||
#cmakedefine HAVE_FPU_CONTROL_H 1
|
||||
#cmakedefine HAVE_GRP_H 1
|
||||
#cmakedefine HAVE_EXPLICIT_TEMPLATE_INSTANTIATION 1
|
||||
#cmakedefine HAVE_IA64INTRIN_H 1
|
||||
#cmakedefine HAVE_IEEEFP_H 1
|
||||
#cmakedefine HAVE_INTTYPES_H 1
|
||||
#cmakedefine HAVE_LIMITS_H 1
|
||||
#cmakedefine HAVE_LOCALE_H 1
|
||||
#cmakedefine HAVE_MALLOC_H 1
|
||||
#cmakedefine HAVE_MEMORY_H 1
|
||||
#cmakedefine HAVE_NETINET_IN_H 1
|
||||
#cmakedefine HAVE_PATHS_H 1
|
||||
#cmakedefine HAVE_POLL_H 1
|
||||
#cmakedefine HAVE_PORT_H 1
|
||||
#cmakedefine HAVE_PWD_H 1
|
||||
#cmakedefine HAVE_SCHED_H 1
|
||||
#cmakedefine HAVE_SELECT_H 1
|
||||
#cmakedefine HAVE_SOLARIS_LARGE_PAGES 1
|
||||
#cmakedefine HAVE_STDDEF_H 1
|
||||
#cmakedefine HAVE_STDLIB_H 1
|
||||
#cmakedefine HAVE_STDARG_H 1
|
||||
#cmakedefine HAVE_STRINGS_H 1
|
||||
#cmakedefine HAVE_STRING_H 1
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
#cmakedefine HAVE_SEMAPHORE_H 1
|
||||
#cmakedefine HAVE_SYNCH_H 1
|
||||
#cmakedefine HAVE_SYSENT_H 1
|
||||
#cmakedefine HAVE_SYS_DIR_H 1
|
||||
#cmakedefine HAVE_SYS_CDEFS_H 1
|
||||
#cmakedefine HAVE_SYS_FILE_H 1
|
||||
#cmakedefine HAVE_SYS_FPU_H 1
|
||||
#cmakedefine HAVE_SYS_IOCTL_H 1
|
||||
#cmakedefine HAVE_SYS_IPC_H 1
|
||||
#cmakedefine HAVE_SYS_MALLOC_H 1
|
||||
#cmakedefine HAVE_SYS_MMAN_H 1
|
||||
#cmakedefine HAVE_SYS_NDIR_H 1
|
||||
#cmakedefine HAVE_SYS_PTE_H 1
|
||||
#cmakedefine HAVE_SYS_PTEM_H 1
|
||||
#cmakedefine HAVE_SYS_PRCTL_H 1
|
||||
#cmakedefine HAVE_SYS_RESOURCE_H 1
|
||||
#cmakedefine HAVE_SYS_SELECT_H 1
|
||||
#cmakedefine HAVE_SYS_SHM_H 1
|
||||
#cmakedefine HAVE_SYS_SOCKET_H 1
|
||||
#cmakedefine HAVE_SYS_STAT_H 1
|
||||
#cmakedefine HAVE_SYS_STREAM_H 1
|
||||
#cmakedefine HAVE_SYS_TERMCAP_H 1
|
||||
#cmakedefine HAVE_SYS_TIMEB_H 1
|
||||
#cmakedefine HAVE_SYS_TIMES_H 1
|
||||
#cmakedefine HAVE_SYS_TIME_H 1
|
||||
#cmakedefine HAVE_SYS_TYPES_H 1
|
||||
#cmakedefine HAVE_SYS_UN_H 1
|
||||
#cmakedefine HAVE_SYS_VADVISE_H 1
|
||||
#cmakedefine HAVE_TERM_H 1
|
||||
#cmakedefine HAVE_TERMBITS_H 1
|
||||
#cmakedefine HAVE_TERMIOS_H 1
|
||||
#cmakedefine HAVE_TERMIO_H 1
|
||||
#cmakedefine HAVE_TERMCAP_H 1
|
||||
#cmakedefine HAVE_TIME_H 1
|
||||
#cmakedefine HAVE_UNISTD_H 1
|
||||
#cmakedefine HAVE_UTIME_H 1
|
||||
#cmakedefine HAVE_VARARGS_H 1
|
||||
#cmakedefine HAVE_VIS_H 1
|
||||
#cmakedefine HAVE_SYS_UTIME_H 1
|
||||
#cmakedefine HAVE_SYS_WAIT_H 1
|
||||
#cmakedefine HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Libraries */
|
||||
#cmakedefine HAVE_LIBPTHREAD 1
|
||||
#cmakedefine HAVE_LIBM 1
|
||||
#cmakedefine HAVE_LIBDL 1
|
||||
#cmakedefine HAVE_LIBRT 1
|
||||
#cmakedefine HAVE_LIBSOCKET 1
|
||||
#cmakedefine HAVE_LIBNSL 1
|
||||
#cmakedefine HAVE_LIBCRYPT 1
|
||||
#cmakedefine HAVE_LIBMTMALLOC 1
|
||||
#cmakedefine HAVE_LIBWRAP 1
|
||||
/* Does "struct timespec" have a "sec" and "nsec" field? */
|
||||
#cmakedefine HAVE_TIMESPEC_TS_SEC 1
|
||||
|
||||
/* Readline */
|
||||
#cmakedefine HAVE_HIST_ENTRY 1
|
||||
#cmakedefine USE_LIBEDIT_INTERFACE 1
|
||||
#cmakedefine USE_NEW_READLINE_INTERFACE 1
|
||||
|
||||
#cmakedefine FIONREAD_IN_SYS_IOCTL 1
|
||||
#cmakedefine GWINSZ_IN_SYS_IOCTL 1
|
||||
#cmakedefine TIOCSTAT_IN_SYS_IOCTL 1
|
||||
|
||||
/* Functions we may want to use. */
|
||||
#cmakedefine HAVE_AIOWAIT 1
|
||||
#cmakedefine HAVE_ALARM 1
|
||||
#cmakedefine HAVE_ALLOCA 1
|
||||
#cmakedefine HAVE_BFILL 1
|
||||
#cmakedefine HAVE_BMOVE 1
|
||||
#cmakedefine HAVE_BZERO 1
|
||||
#cmakedefine HAVE_INDEX 1
|
||||
#cmakedefine HAVE_CHOWN 1
|
||||
#cmakedefine HAVE_CLOCK_GETTIME 1
|
||||
#cmakedefine HAVE_CRYPT 1
|
||||
#cmakedefine HAVE_CUSERID 1
|
||||
#cmakedefine HAVE_CXX_NEW 1
|
||||
#cmakedefine HAVE_DIRECTIO 1
|
||||
#cmakedefine HAVE_DLERROR 1
|
||||
#cmakedefine HAVE_DLOPEN 1
|
||||
#cmakedefine HAVE_DOPRNT 1
|
||||
#cmakedefine HAVE_FCHMOD 1
|
||||
#cmakedefine HAVE_FCNTL 1
|
||||
#cmakedefine HAVE_FCONVERT 1
|
||||
#cmakedefine HAVE_FDATASYNC 1
|
||||
#cmakedefine HAVE_FESETROUND 1
|
||||
#cmakedefine HAVE_FINITE 1
|
||||
#cmakedefine HAVE_FP_EXCEPT 1
|
||||
#cmakedefine HAVE_FPSETMASK 1
|
||||
#cmakedefine HAVE_FSEEKO 1
|
||||
#cmakedefine HAVE_FSYNC 1
|
||||
#cmakedefine HAVE_FTIME 1
|
||||
#cmakedefine HAVE_GETADDRINFO 1
|
||||
#cmakedefine HAVE_GETCWD 1
|
||||
#cmakedefine HAVE_GETHOSTBYADDR_R 1
|
||||
#cmakedefine HAVE_GETHOSTBYNAME_R 1
|
||||
#cmakedefine HAVE_GETHRTIME 1
|
||||
#cmakedefine HAVE_GETLINE 1
|
||||
#cmakedefine HAVE_GETNAMEINFO 1
|
||||
#cmakedefine HAVE_GETPAGESIZE 1
|
||||
#cmakedefine HAVE_GETPASS 1
|
||||
#cmakedefine HAVE_GETPASSPHRASE 1
|
||||
#cmakedefine HAVE_GETPWNAM 1
|
||||
#cmakedefine HAVE_GETPWUID 1
|
||||
#cmakedefine HAVE_GETRLIMIT 1
|
||||
#cmakedefine HAVE_GETRUSAGE 1
|
||||
#cmakedefine HAVE_GETTIMEOFDAY 1
|
||||
#cmakedefine HAVE_GETWD 1
|
||||
#cmakedefine HAVE_GMTIME_R 1
|
||||
#cmakedefine gmtime_r @gmtime_r@
|
||||
#cmakedefine HAVE_INITGROUPS 1
|
||||
#cmakedefine HAVE_ISSETUGID 1
|
||||
#cmakedefine HAVE_ISNAN 1
|
||||
#cmakedefine HAVE_ISINF 1
|
||||
#cmakedefine HAVE_LARGE_PAGE_OPTION 1
|
||||
#cmakedefine HAVE_LDIV 1
|
||||
#cmakedefine HAVE_LRAND48 1
|
||||
#cmakedefine HAVE_LOCALTIME_R 1
|
||||
#cmakedefine HAVE_LOG2 1
|
||||
#cmakedefine HAVE_LONGJMP 1
|
||||
#cmakedefine HAVE_LSTAT 1
|
||||
#cmakedefine HAVE_MEMALIGN 1
|
||||
/* #cmakedefine HAVE_MLOCK 1 see Bug#54662 */
|
||||
#cmakedefine HAVE_NPTL 1
|
||||
#cmakedefine HAVE_NL_LANGINFO 1
|
||||
#cmakedefine HAVE_MADVISE 1
|
||||
#cmakedefine HAVE_DECL_MADVISE 1
|
||||
#cmakedefine HAVE_DECL_TGOTO 1
|
||||
#cmakedefine HAVE_DECL_MHA_MAPSIZE_VA
|
||||
#cmakedefine HAVE_MALLINFO 1
|
||||
#cmakedefine HAVE_MEMCPY 1
|
||||
#cmakedefine HAVE_MEMMOVE 1
|
||||
#cmakedefine HAVE_MKSTEMP 1
|
||||
#cmakedefine HAVE_MLOCKALL 1
|
||||
#cmakedefine HAVE_MMAP 1
|
||||
#cmakedefine HAVE_MMAP64 1
|
||||
#cmakedefine HAVE_PERROR 1
|
||||
#cmakedefine HAVE_POLL 1
|
||||
#cmakedefine HAVE_PORT_CREATE 1
|
||||
#cmakedefine HAVE_POSIX_FALLOCATE 1
|
||||
#cmakedefine HAVE_PREAD 1
|
||||
#cmakedefine HAVE_PAUSE_INSTRUCTION 1
|
||||
#cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1
|
||||
#cmakedefine HAVE_RDTSCLL 1
|
||||
#cmakedefine HAVE_READ_REAL_TIME 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_CREATE 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETPRIO 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETSCHEDPARAM 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
|
||||
#cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1
|
||||
#cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1
|
||||
#cmakedefine HAVE_PTHREAD_INIT 1
|
||||
#cmakedefine HAVE_PTHREAD_KEY_DELETE 1
|
||||
#cmakedefine HAVE_PTHREAD_KEY_DELETE 1
|
||||
#cmakedefine HAVE_PTHREAD_KILL 1
|
||||
#cmakedefine HAVE_PTHREAD_RWLOCK_RDLOCK 1
|
||||
#cmakedefine HAVE_PTHREAD_SETPRIO_NP 1
|
||||
#cmakedefine HAVE_PTHREAD_SETSCHEDPARAM 1
|
||||
#cmakedefine HAVE_PTHREAD_SIGMASK 1
|
||||
#cmakedefine HAVE_PTHREAD_THREADMASK 1
|
||||
#cmakedefine HAVE_PTHREAD_YIELD_NP 1
|
||||
#cmakedefine HAVE_PTHREAD_YIELD_ZERO_ARG 1
|
||||
#cmakedefine PTHREAD_ONCE_INITIALIZER @PTHREAD_ONCE_INITIALIZER@
|
||||
#cmakedefine HAVE_PUTENV 1
|
||||
#cmakedefine HAVE_RE_COMP 1
|
||||
#cmakedefine HAVE_REGCOMP 1
|
||||
#cmakedefine HAVE_READDIR_R 1
|
||||
#cmakedefine HAVE_READLINK 1
|
||||
#cmakedefine HAVE_REALPATH 1
|
||||
#cmakedefine HAVE_RENAME 1
|
||||
#cmakedefine HAVE_RINT 1
|
||||
#cmakedefine HAVE_RWLOCK_INIT 1
|
||||
#cmakedefine HAVE_SCHED_YIELD 1
|
||||
#cmakedefine HAVE_SELECT 1
|
||||
#cmakedefine HAVE_SETFD 1
|
||||
#cmakedefine HAVE_SETENV 1
|
||||
#cmakedefine HAVE_SETLOCALE 1
|
||||
#cmakedefine HAVE_SIGADDSET 1
|
||||
#cmakedefine HAVE_SIGEMPTYSET 1
|
||||
#cmakedefine HAVE_SIGHOLD 1
|
||||
#cmakedefine HAVE_SIGSET 1
|
||||
#cmakedefine HAVE_SIGSET_T 1
|
||||
#cmakedefine HAVE_SIGACTION 1
|
||||
#cmakedefine HAVE_SIGTHREADMASK 1
|
||||
#cmakedefine HAVE_SIGWAIT 1
|
||||
#cmakedefine HAVE_SLEEP 1
|
||||
#cmakedefine HAVE_SNPRINTF 1
|
||||
#cmakedefine HAVE_STPCPY 1
|
||||
#cmakedefine HAVE_STRERROR 1
|
||||
#cmakedefine HAVE_STRCOLL 1
|
||||
#cmakedefine HAVE_STRSIGNAL 1
|
||||
#cmakedefine HAVE_STRLCPY 1
|
||||
#cmakedefine HAVE_STRLCAT 1
|
||||
#cmakedefine HAVE_FGETLN 1
|
||||
#cmakedefine HAVE_STRNLEN 1
|
||||
#cmakedefine HAVE_STRPBRK 1
|
||||
#cmakedefine HAVE_STRSEP 1
|
||||
#cmakedefine HAVE_STRSTR 1
|
||||
#cmakedefine HAVE_STRTOK_R 1
|
||||
#cmakedefine HAVE_STRTOL 1
|
||||
#cmakedefine HAVE_STRTOLL 1
|
||||
#cmakedefine HAVE_STRTOUL 1
|
||||
#cmakedefine HAVE_STRTOULL 1
|
||||
#cmakedefine HAVE_SHMAT 1
|
||||
#cmakedefine HAVE_SHMCTL 1
|
||||
#cmakedefine HAVE_SHMDT 1
|
||||
#cmakedefine HAVE_SHMGET 1
|
||||
#cmakedefine HAVE_TELL 1
|
||||
#cmakedefine HAVE_TEMPNAM 1
|
||||
#cmakedefine HAVE_THR_SETCONCURRENCY 1
|
||||
#cmakedefine HAVE_THR_YIELD 1
|
||||
#cmakedefine HAVE_TIME 1
|
||||
#cmakedefine HAVE_TIMES 1
|
||||
#cmakedefine HAVE_VALLOC 1
|
||||
#define HAVE_VIO_READ_BUFF 1
|
||||
#cmakedefine HAVE_VASPRINTF 1
|
||||
#cmakedefine HAVE_VPRINTF 1
|
||||
#cmakedefine HAVE_VSNPRINTF 1
|
||||
#cmakedefine HAVE_FTRUNCATE 1
|
||||
#cmakedefine HAVE_TZNAME 1
|
||||
#cmakedefine HAVE_AIO_READ 1
|
||||
/* Symbols we may use */
|
||||
#cmakedefine HAVE_SYS_ERRLIST 1
|
||||
/* used by stacktrace functions */
|
||||
#cmakedefine HAVE_BSS_START 1
|
||||
#cmakedefine HAVE_BACKTRACE 1
|
||||
#cmakedefine HAVE_BACKTRACE_SYMBOLS 1
|
||||
#cmakedefine HAVE_BACKTRACE_SYMBOLS_FD 1
|
||||
#cmakedefine HAVE_PRINTSTACK 1
|
||||
#cmakedefine HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
#cmakedefine HAVE_STRUCT_IN6_ADDR 1
|
||||
#cmakedefine HAVE_NETINET_IN6_H 1
|
||||
#cmakedefine HAVE_IPV6 1
|
||||
#cmakedefine ss_family @ss_family@
|
||||
#cmakedefine HAVE_SOCKADDR_IN_SIN_LEN 1
|
||||
#cmakedefine HAVE_SOCKADDR_IN6_SIN6_LEN 1
|
||||
#cmakedefine HAVE_TIMESPEC_TS_SEC 1
|
||||
#cmakedefine STRUCT_DIRENT_HAS_D_INO 1
|
||||
#cmakedefine STRUCT_DIRENT_HAS_D_NAMLEN 1
|
||||
#cmakedefine SPRINTF_RETURNS_INT 1
|
||||
|
||||
#define USE_MB 1
|
||||
#define USE_MB_IDENT 1
|
||||
|
||||
#cmakedefine HAVE_VALGRIND
|
||||
|
||||
/* Types we may use */
|
||||
#ifdef __APPLE__
|
||||
/*
|
||||
Special handling required for OSX to support universal binaries that
|
||||
mix 32 and 64 bit architectures.
|
||||
*/
|
||||
#if(__LP64__)
|
||||
#define SIZEOF_LONG 8
|
||||
#else
|
||||
#define SIZEOF_LONG 4
|
||||
#endif
|
||||
#define SIZEOF_VOIDP SIZEOF_LONG
|
||||
#define SIZEOF_CHARP SIZEOF_LONG
|
||||
#define SIZEOF_SIZE_T SIZEOF_LONG
|
||||
#else
|
||||
/* No indentation, to fetch the lines from verification scripts */
|
||||
#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
|
||||
#cmakedefine SIZEOF_VOIDP @SIZEOF_VOIDP@
|
||||
#cmakedefine SIZEOF_CHARP @SIZEOF_CHARP@
|
||||
#cmakedefine SIZEOF_SIZE_T @SIZEOF_CHARP@
|
||||
#endif
|
||||
|
||||
#cmakedefine SIZEOF_CHAR @SIZEOF_CHAR@
|
||||
#define HAVE_CHAR 1
|
||||
#define HAVE_LONG 1
|
||||
#define HAVE_CHARP 1
|
||||
#cmakedefine SIZEOF_SHORT @SIZEOF_SHORT@
|
||||
#define HAVE_SHORT 1
|
||||
#cmakedefine SIZEOF_INT @SIZEOF_INT@
|
||||
#define HAVE_INT 1
|
||||
#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
|
||||
#cmakedefine HAVE_LONG_LONG 1
|
||||
#cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@
|
||||
#cmakedefine HAVE_OFF_T 1
|
||||
#cmakedefine SIZEOF_SIGSET_T @SIZEOF_SIGSET_T@
|
||||
#cmakedefine HAVE_SIGSET_T 1
|
||||
#cmakedefine HAVE_SIZE_T 1
|
||||
#cmakedefine SIZEOF_UCHAR @SIZEOF_UCHAR@
|
||||
#cmakedefine HAVE_UCHAR 1
|
||||
#cmakedefine SIZEOF_UINT @SIZEOF_UINT@
|
||||
#cmakedefine HAVE_UINT 1
|
||||
#cmakedefine SIZEOF_ULONG @SIZEOF_ULONG@
|
||||
#cmakedefine HAVE_ULONG 1
|
||||
#cmakedefine SIZEOF_INT8 @SIZEOF_INT8@
|
||||
#cmakedefine HAVE_INT8 1
|
||||
#cmakedefine SIZEOF_UINT8 @SIZEOF_UINT8@
|
||||
#cmakedefine HAVE_UINT8 1
|
||||
#cmakedefine SIZEOF_INT16 @SIZEOF_INT16@
|
||||
#cmakedefine HAVE_INT16 1
|
||||
#cmakedefine SIZEOF_UINT16 @SIZEOF_UINT16@
|
||||
#cmakedefine HAVE_UINT16 1
|
||||
#cmakedefine SIZEOF_INT32 @SIZEOF_INT32@
|
||||
#cmakedefine HAVE_INT32 1
|
||||
#cmakedefine SIZEOF_UINT32 @SIZEOF_UINT32@
|
||||
#cmakedefine HAVE_UINT32 1
|
||||
#cmakedefine SIZEOF_U_INT32_T @SIZEOF_U_INT32_T@
|
||||
#cmakedefine HAVE_U_INT32_T 1
|
||||
#cmakedefine SIZEOF_INT64 @SIZEOF_INT64@
|
||||
#cmakedefine HAVE_INT64 1
|
||||
#cmakedefine SIZEOF_UINT64 @SIZEOF_UINT64@
|
||||
#cmakedefine HAVE_UINT64 1
|
||||
#cmakedefine SIZEOF_BOOL @SIZEOF_BOOL@
|
||||
#cmakedefine HAVE_BOOL 1
|
||||
|
||||
#cmakedefine SOCKET_SIZE_TYPE @SOCKET_SIZE_TYPE@
|
||||
|
||||
#cmakedefine HAVE_MBSTATE_T
|
||||
|
||||
#define MAX_INDEXES 64
|
||||
|
||||
#cmakedefine QSORT_TYPE_IS_VOID 1
|
||||
#cmakedefine RETQSORTTYPE @RETQSORTTYPE@
|
||||
|
||||
#cmakedefine SIGNAL_RETURN_TYPE_IS_VOID 1
|
||||
#cmakedefine RETSIGTYPE @RETSIGTYPE@
|
||||
#cmakedefine VOID_SIGHANDLER 1
|
||||
#define STRUCT_RLIMIT struct rlimit
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if __BIG_ENDIAN
|
||||
#define WORDS_BIGENDIAN 1
|
||||
#endif
|
||||
#else
|
||||
#cmakedefine WORDS_BIGENDIAN 1
|
||||
#endif
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler calls
|
||||
it, or to nothing if 'inline' is not supported under any name. */
|
||||
#cmakedefine C_HAS_inline 1
|
||||
#if !(C_HAS_inline)
|
||||
#ifndef __cplusplus
|
||||
# define inline @C_INLINE@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#cmakedefine TARGET_OS_LINUX 1
|
||||
|
||||
#cmakedefine HAVE_WCTYPE_H 1
|
||||
#cmakedefine HAVE_WCHAR_H 1
|
||||
#cmakedefine HAVE_LANGINFO_H 1
|
||||
#cmakedefine HAVE_MBRLEN
|
||||
#cmakedefine HAVE_MBSCMP
|
||||
#cmakedefine HAVE_MBSRTOWCS
|
||||
#cmakedefine HAVE_WCRTOMB
|
||||
#cmakedefine HAVE_MBRTOWC
|
||||
#cmakedefine HAVE_WCSCOLL
|
||||
#cmakedefine HAVE_WCSDUP
|
||||
#cmakedefine HAVE_WCWIDTH
|
||||
#cmakedefine HAVE_WCTYPE
|
||||
#cmakedefine HAVE_ISWLOWER 1
|
||||
#cmakedefine HAVE_ISWUPPER 1
|
||||
#cmakedefine HAVE_TOWLOWER 1
|
||||
#cmakedefine HAVE_TOWUPPER 1
|
||||
#cmakedefine HAVE_ISWCTYPE 1
|
||||
#cmakedefine HAVE_WCHAR_T 1
|
||||
#cmakedefine HAVE_WCTYPE_T 1
|
||||
#cmakedefine HAVE_WINT_T 1
|
||||
|
||||
|
||||
#cmakedefine HAVE_STRCASECMP 1
|
||||
#cmakedefine HAVE_STRNCASECMP 1
|
||||
#cmakedefine HAVE_STRDUP 1
|
||||
#cmakedefine HAVE_LANGINFO_CODESET
|
||||
#cmakedefine HAVE_TCGETATTR 1
|
||||
#cmakedefine HAVE_FLOCKFILE 1
|
||||
|
||||
#cmakedefine HAVE_WEAK_SYMBOL 1
|
||||
#cmakedefine HAVE_ABI_CXA_DEMANGLE 1
|
||||
|
||||
|
||||
#cmakedefine HAVE_POSIX_SIGNALS 1
|
||||
#cmakedefine HAVE_BSD_SIGNALS 1
|
||||
#cmakedefine HAVE_SVR3_SIGNALS 1
|
||||
#cmakedefine HAVE_V7_SIGNALS 1
|
||||
|
||||
|
||||
#cmakedefine HAVE_SOLARIS_STYLE_GETHOST 1
|
||||
#cmakedefine HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE 1
|
||||
#cmakedefine HAVE_GETHOSTBYNAME_R_RETURN_INT 1
|
||||
|
||||
#cmakedefine MY_ATOMIC_MODE_DUMMY 1
|
||||
#cmakedefine MY_ATOMIC_MODE_RWLOCKS 1
|
||||
#cmakedefine HAVE_GCC_ATOMIC_BUILTINS 1
|
||||
#cmakedefine HAVE_SOLARIS_ATOMIC 1
|
||||
#cmakedefine HAVE_DECL_SHM_HUGETLB 1
|
||||
#cmakedefine HAVE_LARGE_PAGES 1
|
||||
#cmakedefine HUGETLB_USE_PROC_MEMINFO 1
|
||||
#cmakedefine NO_FCNTL_NONBLOCK 1
|
||||
#cmakedefine NO_ALARM 1
|
||||
|
||||
#cmakedefine _LARGE_FILES 1
|
||||
#cmakedefine _LARGEFILE_SOURCE 1
|
||||
#cmakedefine _LARGEFILE64_SOURCE 1
|
||||
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
|
||||
|
||||
#cmakedefine TIME_WITH_SYS_TIME 1
|
||||
|
||||
#cmakedefine STACK_DIRECTION @STACK_DIRECTION@
|
||||
|
||||
#define SYSTEM_TYPE "@SYSTEM_TYPE@"
|
||||
#define MACHINE_TYPE "@CMAKE_SYSTEM_PROCESSOR@"
|
||||
#cmakedefine HAVE_DTRACE 1
|
||||
|
||||
#cmakedefine SIGNAL_WITH_VIO_CLOSE 1
|
||||
|
||||
/* Windows stuff, mostly functions, that have Posix analogs but named differently */
|
||||
#cmakedefine S_IROTH @S_IROTH@
|
||||
#cmakedefine S_IFIFO @S_IFIFO@
|
||||
#cmakedefine IPPROTO_IPV6 @IPPROTO_IPV6@
|
||||
#cmakedefine IPV6_V6ONLY @IPV6_V6ONLY@
|
||||
#cmakedefine sigset_t @sigset_t@
|
||||
#cmakedefine mode_t @mode_t@
|
||||
#cmakedefine SIGQUIT @SIGQUIT@
|
||||
#cmakedefine SIGPIPE @SIGPIPE@
|
||||
#cmakedefine isnan @isnan@
|
||||
#cmakedefine finite @finite@
|
||||
#cmakedefine popen @popen@
|
||||
#cmakedefine pclose @pclose@
|
||||
#cmakedefine ssize_t @ssize_t@
|
||||
#cmakedefine strcasecmp @strcasecmp@
|
||||
#cmakedefine strncasecmp @strncasecmp@
|
||||
#cmakedefine snprintf @snprintf@
|
||||
#cmakedefine strtok_r @strtok_r@
|
||||
#cmakedefine strtoll @strtoll@
|
||||
#cmakedefine strtoull @strtoull@
|
||||
#cmakedefine vsnprintf @vsnprintf@
|
||||
#if (_MSC_VER > 1310)
|
||||
# define HAVE_SETENV
|
||||
#define setenv(a,b,c) _putenv_s(a,b)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
MySQL features
|
||||
*/
|
||||
#cmakedefine ENABLED_LOCAL_INFILE 1
|
||||
#cmakedefine ENABLED_PROFILING 1
|
||||
#cmakedefine EXTRA_DEBUG 1
|
||||
#cmakedefine BACKUP_TEST 1
|
||||
#cmakedefine CYBOZU 1
|
||||
|
||||
/* Character sets and collations */
|
||||
#cmakedefine MYSQL_DEFAULT_CHARSET_NAME "latin1"
|
||||
#cmakedefine MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
|
||||
|
||||
#cmakedefine USE_MB 1
|
||||
#cmakedefine USE_MB_IDENT 1
|
||||
#cmakedefine USE_STRCOLL 1
|
||||
|
||||
/* This should mean case insensitive file system */
|
||||
#cmakedefine FN_NO_CASE_SENSE 1
|
||||
|
||||
#cmakedefine HAVE_CHARSET_armscii8 1
|
||||
#cmakedefine HAVE_CHARSET_ascii 1
|
||||
#cmakedefine HAVE_CHARSET_big5 1
|
||||
#cmakedefine HAVE_CHARSET_cp1250 1
|
||||
#cmakedefine HAVE_CHARSET_cp1251 1
|
||||
#cmakedefine HAVE_CHARSET_cp1256 1
|
||||
#cmakedefine HAVE_CHARSET_cp1257 1
|
||||
#cmakedefine HAVE_CHARSET_cp850 1
|
||||
#cmakedefine HAVE_CHARSET_cp852 1
|
||||
#cmakedefine HAVE_CHARSET_cp866 1
|
||||
#cmakedefine HAVE_CHARSET_cp932 1
|
||||
#cmakedefine HAVE_CHARSET_dec8 1
|
||||
#cmakedefine HAVE_CHARSET_eucjpms 1
|
||||
#cmakedefine HAVE_CHARSET_euckr 1
|
||||
#cmakedefine HAVE_CHARSET_gb2312 1
|
||||
#cmakedefine HAVE_CHARSET_gbk 1
|
||||
#cmakedefine HAVE_CHARSET_geostd8 1
|
||||
#cmakedefine HAVE_CHARSET_greek 1
|
||||
#cmakedefine HAVE_CHARSET_hebrew 1
|
||||
#cmakedefine HAVE_CHARSET_hp8 1
|
||||
#cmakedefine HAVE_CHARSET_keybcs2 1
|
||||
#cmakedefine HAVE_CHARSET_koi8r 1
|
||||
#cmakedefine HAVE_CHARSET_koi8u 1
|
||||
#cmakedefine HAVE_CHARSET_latin1 1
|
||||
#cmakedefine HAVE_CHARSET_latin2 1
|
||||
#cmakedefine HAVE_CHARSET_latin5 1
|
||||
#cmakedefine HAVE_CHARSET_latin7 1
|
||||
#cmakedefine HAVE_CHARSET_macce 1
|
||||
#cmakedefine HAVE_CHARSET_macroman 1
|
||||
#cmakedefine HAVE_CHARSET_sjis 1
|
||||
#cmakedefine HAVE_CHARSET_swe7 1
|
||||
#cmakedefine HAVE_CHARSET_tis620 1
|
||||
#cmakedefine HAVE_CHARSET_ucs2 1
|
||||
#cmakedefine HAVE_CHARSET_ujis 1
|
||||
#cmakedefine HAVE_CHARSET_utf8mb4 1
|
||||
#cmakedefine HAVE_CHARSET_utf8mb3 1
|
||||
#cmakedefine HAVE_CHARSET_utf8 1
|
||||
#cmakedefine HAVE_CHARSET_utf16 1
|
||||
#cmakedefine HAVE_CHARSET_utf32 1
|
||||
#cmakedefine HAVE_UCA_COLLATIONS 1
|
||||
#cmakedefine HAVE_COMPRESS 1
|
||||
|
||||
|
||||
/*
|
||||
Stuff that always need to be defined (compile breaks without it)
|
||||
*/
|
||||
#define HAVE_SPATIAL 1
|
||||
#define HAVE_RTREE_KEYS 1
|
||||
#define HAVE_QUERY_CACHE 1
|
||||
#define BIG_TABLES 1
|
||||
|
||||
/*
|
||||
Important storage engines (those that really need define
|
||||
WITH_<ENGINE>_STORAGE_ENGINE for the whole server)
|
||||
*/
|
||||
#cmakedefine WITH_MYISAM_STORAGE_ENGINE 1
|
||||
#cmakedefine WITH_MYISAMMRG_STORAGE_ENGINE 1
|
||||
#cmakedefine WITH_HEAP_STORAGE_ENGINE 1
|
||||
#cmakedefine WITH_CSV_STORAGE_ENGINE 1
|
||||
#cmakedefine WITH_PARTITION_STORAGE_ENGINE 1
|
||||
#cmakedefine WITH_PERFSCHEMA_STORAGE_ENGINE 1
|
||||
#cmakedefine WITH_NDBCLUSTER_STORAGE_ENGINE 1
|
||||
#if (WITH_NDBCLUSTER_STORAGE_ENGINE) && !defined(EMBEDDED_LIBRARY)
|
||||
# define HAVE_NDB_BINLOG 1
|
||||
#endif
|
||||
|
||||
#cmakedefine DEFAULT_MYSQL_HOME "@DEFAULT_MYSQL_HOME@"
|
||||
#cmakedefine SHAREDIR "@SHAREDIR@"
|
||||
#cmakedefine DEFAULT_BASEDIR "@DEFAULT_BASEDIR@"
|
||||
#cmakedefine MYSQL_DATADIR "@MYSQL_DATADIR@"
|
||||
#cmakedefine DEFAULT_CHARSET_HOME "@DEFAULT_CHARSET_HOME@"
|
||||
#cmakedefine PLUGINDIR "@PLUGINDIR@"
|
||||
#cmakedefine DEFAULT_SYSCONFDIR "@DEFAULT_SYSCONFDIR@"
|
||||
|
||||
#cmakedefine SO_EXT "@CMAKE_SHARED_MODULE_SUFFIX@"
|
||||
|
||||
#define MYSQL_MAJOR_VERSION @MAJOR_VERSION@
|
||||
#define MYSQL_MINOR_VERSION @MINOR_VERSION@
|
||||
|
||||
#define PACKAGE "mysql"
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
#define PACKAGE_NAME "MySQL Server"
|
||||
#define PACKAGE_STRING "MySQL Server @VERSION@"
|
||||
#define PACKAGE_TARNAME "mysql"
|
||||
#define PACKAGE_VERSION "@VERSION@"
|
||||
#define VERSION "@VERSION@"
|
||||
#define PROTOCOL_VERSION 10
|
||||
|
||||
|
||||
#endif
|
||||
1101
dep/mysqllite/configure.cmake
Normal file
1101
dep/mysqllite/configure.cmake
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
||||
#ifdef DBUG_OFF /* We are testing dbug */
|
||||
|
||||
int factorial(register int value) {
|
||||
if(value > 1) {
|
||||
value *= factorial(value-1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <my_global.h>
|
||||
|
||||
int factorial (
|
||||
register int value)
|
||||
{
|
||||
DBUG_ENTER ("factorial");
|
||||
DBUG_PRINT ("find", ("find %d factorial", value));
|
||||
if (value > 1) {
|
||||
value *= factorial (value - 1);
|
||||
}
|
||||
DBUG_PRINT ("result", ("result is %d", value));
|
||||
DBUG_RETURN (value);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/* Declarate _sanity() if not declared in main program */
|
||||
|
||||
#include <my_global.h>
|
||||
|
||||
extern int _sanity(const char *file,uint line);
|
||||
|
||||
#if defined(SAFEMALLOC) && !defined(MASTER) /* Avoid errors in MySQL */
|
||||
int _sanity(const char * file __attribute__((unused)),
|
||||
uint line __attribute__((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -512,7 +512,7 @@ possible since all code preceding the first call to
|
||||
.B DBUG_PUSH
|
||||
is
|
||||
essentially invisible to
|
||||
.B dbug
|
||||
.I dbug
|
||||
(this can be worked around by
|
||||
inserting a temporary
|
||||
.B DBUG_PUSH(argv[1])
|
||||
@@ -708,7 +708,7 @@ EX:\ \fCDBUG_PROCESS\ (argv[0]);\fR
|
||||
.SP 1
|
||||
.LI DBUG_PUSH\
|
||||
Sets a new debugger state by pushing the current
|
||||
.B dbug
|
||||
.I dbug
|
||||
state onto an internal stack and setting up the new state using the
|
||||
debug control string passed as the macro argument. The most common
|
||||
usage is to set the state specified by a debug control string
|
||||
@@ -769,14 +769,14 @@ the 'd' flag. Used to conditionally execute "dangerous" actions, e.g
|
||||
to crash the program testing how recovery works, or to introduce an
|
||||
artificial delay checking for race conditions.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ abort\ ());\fR
|
||||
EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ DBUG_ABORT()\ ());\fR
|
||||
.SP 1
|
||||
.LI DBUG_EVALUATE\
|
||||
The DBUG_EVALUATE macro is similar to DBUG_EXECUTE, but it can be used in
|
||||
the expression context. The first argument is the debug keyword that is used to
|
||||
choose whether the second (keyword is enabled) or the third (keyword is not
|
||||
enabled) argument is evaluated. When
|
||||
.B dbug
|
||||
.I dbug
|
||||
is compiled off, the third argument is evaluated.
|
||||
.SP 1
|
||||
EX:\fC
|
||||
@@ -796,7 +796,7 @@ EX:\fC
|
||||
.br
|
||||
if (prepare_transaction () ||
|
||||
.br
|
||||
DBUG_EVALUATE ("crashme", (abort (), 0), 0) ||
|
||||
DBUG_EVALUATE ("crashme", (DBUG_ABORT(), 0), 0) ||
|
||||
.br
|
||||
commit_transaction () )\fR
|
||||
.SP 1
|
||||
@@ -875,6 +875,12 @@ library. So there will be no need to disable asserts separately with NDEBUG.
|
||||
.SP 1
|
||||
EX:\ \fCDBUG_ASSERT(\ a\ >\ 0\ );\fR
|
||||
.SP 1
|
||||
.LI DBUG_ABORT\
|
||||
This macro could be used instead of abort(). It flushes DBUG_FILE stream
|
||||
to ensure that no
|
||||
.I dbug
|
||||
output is lost and then calls abort().
|
||||
.SP 1
|
||||
.LI DBUG_EXPLAIN\
|
||||
Generates control string corresponding to the current debug state.
|
||||
The macro takes two arguments - a buffer to store the result string
|
||||
@@ -910,17 +916,17 @@ via the
|
||||
.B DBUG_PUSH
|
||||
or
|
||||
.B DBUG_SET
|
||||
macros. Control string consists of colon separate flags. Colons
|
||||
macros. Control string consists of colon separated flags. Colons
|
||||
that are part of ':\\', ':/', or '::' are not considered flag
|
||||
separators. A flag may take an argument or a list of arguments.
|
||||
If a control string starts from a '+' sign it works
|
||||
.I incrementally,
|
||||
that is, it can modify existing state without overriding it. In such a
|
||||
string every flag may be preceded by a '+' or '-' to enable or disable
|
||||
a corresponding option in the debugger state. This section summarizes
|
||||
the currently available debugger options and the flag characters which
|
||||
enable or disable them. Argument lists enclosed in '[' and ']' are
|
||||
optional.
|
||||
that is, it can modify existing state without overriding it. Every
|
||||
flag may be preceded by a '+' or '-' to enable or disable a
|
||||
corresponding option in the debugger state or to add or remove
|
||||
arguments to the list. This section summarizes the currently available
|
||||
debugger options and the flag characters which enable or disable them.
|
||||
Argument lists enclosed in '[' and ']' are optional.
|
||||
.SP 2
|
||||
.BL 22
|
||||
.LI a[,file]
|
||||
@@ -936,6 +942,9 @@ a complete log file in case of crashes. This mode is implicit in
|
||||
multi-threaded environment.
|
||||
.LI d[,keywords]
|
||||
Enable output from macros with specified keywords.
|
||||
Every keyword can be a
|
||||
.I glob(7)
|
||||
pattern.
|
||||
An empty list of keywords implies that all keywords are selected.
|
||||
.LI D[,time]
|
||||
Delay for specified time after each output line, to let output drain.
|
||||
@@ -943,7 +952,19 @@ Time is given in tenths of a second (value of 10 is one second).
|
||||
Default is zero.
|
||||
.LI f[,functions]
|
||||
Limit debugger actions to the specified list of functions.
|
||||
Every function can be a
|
||||
.I glob(7)
|
||||
pattern.
|
||||
An empty list of functions implies that all functions are selected.
|
||||
Every function in the list may optionally be followed by a '/' -
|
||||
this will implicitly select all the functions down the call stack.
|
||||
.SP 1
|
||||
EX: \fCf,func1,func2/:-f,func3,func4/\fR
|
||||
.SP 1
|
||||
This would enable debugger in functions 'func1()', 'func2()' and all
|
||||
functions called from it (directly or indirectly). But not in
|
||||
functions 'func3()' or 'func4()' and all functions called from
|
||||
it.
|
||||
.LI F
|
||||
Mark each debugger output line with the name of the source file
|
||||
containing the macro causing the output.
|
||||
@@ -952,6 +973,9 @@ Mark each debugger output line with the PID (or thread ID) of the
|
||||
current process.
|
||||
.LI g,[functions]
|
||||
Enable profiling for the specified list of functions.
|
||||
Every function can be a
|
||||
.I glob(7)
|
||||
pattern.
|
||||
An empty list of functions enables profiling for all functions.
|
||||
See
|
||||
.B PROFILING\ WITH\ DBUG
|
||||
@@ -970,7 +994,11 @@ Like 'a[,file]' but overwrite old file, do not append.
|
||||
.LI O[,file]
|
||||
Like 'A[,file]' but overwrite old file, do not append.
|
||||
.LI p[,processes]
|
||||
Limit debugger actions to the specified processes. An empty list
|
||||
Limit debugger actions to the specified processes.
|
||||
Every name can be a
|
||||
.I glob(7)
|
||||
pattern.
|
||||
An empty list
|
||||
implies all processes. This is useful for processes which run child
|
||||
processes. Note that each debugger output line can be marked with the
|
||||
name of the current process via the 'P' flag. The process name must
|
||||
@@ -991,14 +1019,6 @@ Most useful with
|
||||
.B DBUG_PUSH
|
||||
macros used to temporarily alter the
|
||||
debugger state.
|
||||
.LI S
|
||||
When compiled with
|
||||
.I safemalloc
|
||||
this flag forces "sanity" memory checks (for overwrites/underwrites)
|
||||
on each
|
||||
.B DBUG_ENTER
|
||||
and
|
||||
.B DBUG_RETURN.
|
||||
.LI t[,N]
|
||||
Enable function control flow tracing.
|
||||
The maximum nesting depth is specified by N, and defaults to
|
||||
|
||||
@@ -1,340 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
@@ -1,229 +0,0 @@
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
@@ -1,524 +0,0 @@
|
||||
*****************yaSSL Release notes, version 1.6.0 (2/22/07)
|
||||
|
||||
This release of yaSSL contains bug fixes, portability enhancements, and
|
||||
better X509 support.
|
||||
|
||||
See normal build instructions below under 1.0.6.
|
||||
See libcurl build instructions below under 1.3.0 and note in 1.5.8.
|
||||
|
||||
*****************yaSSL Release notes, version 1.5.8 (1/10/07)
|
||||
|
||||
This release of yaSSL contains bug fixes, portability enhancements, and
|
||||
support for GCC 4.1.1 and vs2005 sp1.
|
||||
|
||||
|
||||
|
||||
Since yaSSL now supports zlib, as does libcur, the libcurl build test can
|
||||
fail if yaSSL is built with zlib support since the zlib library isn't
|
||||
passed. You can do two things to fix this:
|
||||
|
||||
1) build yaSSL w/o zlib --without-zlib
|
||||
2) or add flags to curl configure LDFLAGS="-lm -lz"
|
||||
|
||||
|
||||
|
||||
*****************yaSSL Release notes, version 1.5.0 (11/09/06)
|
||||
|
||||
This release of yaSSL contains bug fixes, portability enhancements,
|
||||
and full TLS 1.1 support. Use the functions:
|
||||
|
||||
SSL_METHOD *TLSv1_1_server_method(void);
|
||||
SSL_METHOD *TLSv1_1_client_method(void);
|
||||
|
||||
or the SSLv23 versions (even though yaSSL doesn't support SSL 2.0 the v23
|
||||
means to pick the highest of SSL 3.0, TLS 1.0, or TLS 1.1).
|
||||
|
||||
|
||||
See normal build instructions below under 1.0.6.
|
||||
See libcurl build instructions below under 1.3.0.
|
||||
|
||||
|
||||
|
||||
****************yaSSL Release notes, version 1.4.5 (10/15/06)
|
||||
|
||||
|
||||
This release of yaSSL contains bug fixes, portability enhancements,
|
||||
zlib compression support, removal of assembly instructions at runtime if
|
||||
not supported, and initial TLS 1.1 support.
|
||||
|
||||
|
||||
Compression Notes: yaSSL uses zlib for compression and the compression
|
||||
should only be used if yaSSL is at both ends because the implementation
|
||||
details aren't yet standard. If you'd like to turn compression on use
|
||||
the SSL_set_compression() function on the client before calling
|
||||
SSL_connect(). If both the client and server were built with zlib support
|
||||
then the connection will use compression. If the client isn't built with
|
||||
support then SSL_set_compression() will return an error (-1).
|
||||
|
||||
To build yaSSL with zlib support on Unix simply have zlib support on your
|
||||
system and configure will find it if it's in the standard locations. If
|
||||
it's somewhere else use the option ./configure --with-zlib=DIR. If you'd
|
||||
like to disable compression support in yaSSL use ./configure --without-zlib.
|
||||
|
||||
To build yaSSL with zlib support on Windows:
|
||||
|
||||
1) download zlib from http://www.zlib.net/
|
||||
2) follow the instructions in zlib from projects/visualc6/README.txt
|
||||
for how to add the zlib project into the yaSSL workspace noting that
|
||||
you'll need to add configuration support for "Win32 Debug" and
|
||||
"Win32 Release" in note 3 under "To use:".
|
||||
3) define HAVE_LIBZ when building yaSSL
|
||||
|
||||
|
||||
See normal build instructions below under 1.0.6.
|
||||
See libcurl build instructions below under 1.3.0.
|
||||
|
||||
|
||||
********************yaSSL Release notes, version 1.4.0 (08/13/06)
|
||||
|
||||
|
||||
This release of yaSSL contains bug fixes, portability enhancements,
|
||||
nonblocking connect and accept, better OpenSSL error mapping, and
|
||||
certificate caching for session resumption.
|
||||
|
||||
See normal build instructions below under 1.0.6.
|
||||
See libcurl build instructions below under 1.3.0.
|
||||
|
||||
|
||||
********************yaSSL Release notes, version 1.3.7 (06/26/06)
|
||||
|
||||
|
||||
This release of yaSSL contains bug fixes, portability enhancements,
|
||||
and libcurl 7.15.4 support (any newer versions may not build).
|
||||
|
||||
See normal build instructions below under 1.0.6.
|
||||
See libcurl build instructions below under 1.3.0.
|
||||
|
||||
|
||||
********************yaSSL Release notes, version 1.3.5 (06/01/06)
|
||||
|
||||
|
||||
This release of yaSSL contains bug fixes, portability enhancements,
|
||||
better libcurl support, and improved non-blocking I/O.
|
||||
|
||||
See normal build instructions below under 1.0.6.
|
||||
See libcurl build instructions below under 1.3.0.
|
||||
|
||||
|
||||
********************yaSSL Release notes, version 1.3.0 (04/26/06)
|
||||
|
||||
|
||||
This release of yaSSL contains minor bug fixes, portability enhancements,
|
||||
and libcurl support.
|
||||
|
||||
See normal build instructions below under 1.0.6.
|
||||
|
||||
|
||||
--To build for libcurl on Linux, Solaris, *BSD, Mac OS X, or Cygwin:
|
||||
|
||||
To build for libcurl the library needs to be built without C++ globals since
|
||||
the linker will be called in a C context, also libcurl configure will expect
|
||||
OpenSSL library names so some symbolic links are created.
|
||||
|
||||
./configure --enable-pure-c
|
||||
make
|
||||
make openssl-links
|
||||
|
||||
(then go to your libcurl home and tell libcurl about yaSSL build dir)
|
||||
./configure --with-ssl=/yaSSL-BuildDir LDFLAGS=-lm
|
||||
make
|
||||
|
||||
|
||||
--To build for libcurl on Win32:
|
||||
|
||||
Simply add the yaSSL project as a dependency to libcurl, add
|
||||
yaSSL-Home\include and yaSSL-Home\include\openssl to the include list, and
|
||||
define USE_SSLEAY and USE_OPENSSL
|
||||
|
||||
please email todd@yassl.com if you have any questions.
|
||||
|
||||
|
||||
*******************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
|
||||
|
||||
|
||||
|
||||
***************** 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
|
||||
removal of exceptions and rtti so that the library can be linked without the
|
||||
std c++ library.
|
||||
|
||||
--To build on Linux, Solaris, FreeBSD, Mac OS X, or Cygwin
|
||||
|
||||
./configure
|
||||
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 0.9.2
|
||||
|
||||
This release of yaSSL contains minor bug fixes, expanded certificate
|
||||
verification and chaining, and improved documentation.
|
||||
|
||||
Please see build instructions in release notes 0.3.0.
|
||||
|
||||
|
||||
|
||||
******************yaSSL Release notes, version 0.9.0
|
||||
|
||||
This release of yaSSL contains minor bug fixes, client verification handling,
|
||||
hex and base64 encoing/decoding, and an improved test suite.
|
||||
|
||||
Please see build instructions in release notes 0.3.0.
|
||||
|
||||
|
||||
******************yaSSL Release notes, version 0.8.0
|
||||
|
||||
This release of yaSSL contains minor bug fixes, and initial porting effort to
|
||||
64bit, BigEndian, and more UNIX systems.
|
||||
|
||||
Please see build instructions in release notes 0.3.0.
|
||||
|
||||
|
||||
******************yaSSL Release notes, version 0.6.0
|
||||
|
||||
This release of yaSSL contains minor bug fixes, source cleanup, and binary beta
|
||||
(1) of the yaSSL libraries.
|
||||
|
||||
Please see build instructions in release notes 0.3.0.
|
||||
|
||||
|
||||
|
||||
******************yaSSL Release notes, version 0.5.0
|
||||
|
||||
This release of yaSSL contains minor bug fixes, full session resumption
|
||||
support, and initial testing suite support.
|
||||
|
||||
|
||||
|
||||
Please see build instructions in release notes 0.3.0.
|
||||
|
||||
|
||||
|
||||
******************yaSSL Release notes, version 0.4.0
|
||||
|
||||
This release of yaSSL contains minor bug fixes, an optional memory tracker,
|
||||
an echo client and server with input/output redirection for load testing,
|
||||
and initial session caching support.
|
||||
|
||||
|
||||
Please see build instructions in release notes 0.3.0.
|
||||
|
||||
|
||||
******************yaSSL Release notes, version 0.3.5
|
||||
|
||||
This release of yaSSL contains minor bug fixes and extensions to the crypto
|
||||
library including a full test suite.
|
||||
|
||||
|
||||
*******************yaSSL Release notes, version 0.3.0
|
||||
|
||||
This release of yaSSL contains minor bug fixes and extensions to the crypto
|
||||
library including AES and an improved random number generator. GNU autoconf
|
||||
and automake are now used to simplify the build process on Linux.
|
||||
|
||||
*** Linux Build process
|
||||
|
||||
./configure
|
||||
make
|
||||
|
||||
*** Windows Build process
|
||||
|
||||
open the yassl workspace and build the project
|
||||
|
||||
|
||||
*******************yaSSL Release notes, version 0.2.9
|
||||
|
||||
This release of yaSSL contains minor bug fixes and extensions to the crypto
|
||||
library.
|
||||
|
||||
See the notes at the bottom of this page for build instructions.
|
||||
|
||||
|
||||
*******************yaSSL Release notes, version 0.2.5
|
||||
|
||||
This release of yaSSL contains minor bug fixes and a beta binary of the yaSSL
|
||||
libraries for win32 and linux.
|
||||
|
||||
See the notes at the bottom of this page for build instructions.
|
||||
|
||||
|
||||
|
||||
*******************yaSSL Release notes, version 0.2.0
|
||||
|
||||
This release of yaSSL contains minor bug fixes and initial alternate crypto
|
||||
functionality.
|
||||
|
||||
*** Complete Build ***
|
||||
|
||||
See the notes in Readme.txt for build instructions.
|
||||
|
||||
*** Update Build ***
|
||||
|
||||
If you have already done a complete build of yaSSL as described in the release
|
||||
0.0.1 - 0.1.0 notes and downloaded the update to 0.2.0, place the update file
|
||||
yassl-update-0.2.0.tar.gz in the yaSSL home directory and issue the command:
|
||||
|
||||
gzip -cd yassl-update-0.2.0.tar.gz | tar xvf -
|
||||
|
||||
to update the previous release.
|
||||
|
||||
Then issue the make command on linux or rebuild the yaSSL project on Windows.
|
||||
|
||||
*******************yaSSL Release notes, version 0.1.0
|
||||
|
||||
This release of yaSSL contains minor bug fixes, full client and server TLSv1
|
||||
support including full ephemeral Diffie-Hellman support, SSL type RSA and DSS
|
||||
signing and verification, and initial stunnel 4.05 build support.
|
||||
|
||||
|
||||
|
||||
*********************yaSSL Release notes, version 0.0.3
|
||||
|
||||
The third release of yaSSL contains minor bug fixes, client certificate
|
||||
enhancements, and initial ephemeral Diffie-Hellman integration:
|
||||
|
||||
|
||||
|
||||
*********************
|
||||
|
||||
yaSSL Release notes, version 0.0.2
|
||||
|
||||
The second release of yaSSL contains minor bug fixes, client certificate
|
||||
enhancements, session resumption, and improved TLS support including:
|
||||
|
||||
- HMAC for MD5 and SHA-1
|
||||
- PRF (pseudo random function)
|
||||
- Master Secret and Key derivation routines
|
||||
- Record Authentication codes
|
||||
- Finish verify data check
|
||||
|
||||
Once ephemeral RSA and DH are added yaSSL will be fully complaint with TLS.
|
||||
|
||||
|
||||
|
||||
**********************
|
||||
|
||||
yassl Release notes, version 0.0.1
|
||||
|
||||
The first release of yassl supports normal RSA mode SSLv3 connections with
|
||||
support for SHA-1 and MD5 digests. Ciphers include DES, 3DES, and RC4.
|
||||
|
||||
yassl uses the CryptoPP library for cryptography, the source is available at
|
||||
www.cryptopp.com .
|
||||
|
||||
yassl uses CML (the Certificate Management Library) for x509 support. More
|
||||
features will be in future versions. The CML source is available for download
|
||||
from www.digitalnet.com/knowledge/cml_home.htm .
|
||||
|
||||
The next release of yassl will support the 3 lesser-used SSL connection modes;
|
||||
HandShake resumption, Ephemeral RSA (or DH), and Client Authentication as well
|
||||
as full support for TLS. Backwards support for SSLv2 is not planned at this
|
||||
time.
|
||||
|
||||
|
||||
**********************
|
||||
|
||||
Building yassl on linux:
|
||||
|
||||
use the ./buildall script to build everything.
|
||||
|
||||
buildall will configure and build CML, CryptoPP, and yassl. Testing was
|
||||
preformed with gcc version 3.3.2 on kernel 2.4.22.
|
||||
|
||||
|
||||
**********************
|
||||
|
||||
Building yassl on Windows:
|
||||
|
||||
Testing was preformed on Windows 2000 with Visual C++ 6 sp5.
|
||||
|
||||
1) decompress esnacc_r16.tgz in place, see buildall for syntax if unsure
|
||||
|
||||
2) decompress smp_r23.tgz in place
|
||||
|
||||
3) unzip cryptopp51/crypto51.zip in place
|
||||
|
||||
4) Build SNACC (part of CML) using snacc_builds.dsw in the SNACC directory
|
||||
|
||||
5) Build SMP (part of CMP) using smp.dsw in the smp directory
|
||||
|
||||
6) Build yassl using yassl.dsw
|
||||
|
||||
|
||||
**********************
|
||||
|
||||
examples, server and client:
|
||||
|
||||
Please see the server and client examples in both versions to see how to link
|
||||
to yassl and the support libraries. On linux do 'make server' and 'make
|
||||
client' to build them. On Windows you will find the example projects in the
|
||||
main workspace, yassl.dsw.
|
||||
|
||||
The example server and client are compatible with openssl.
|
||||
|
||||
|
||||
**********************
|
||||
|
||||
Building yassl into mysql on linux:
|
||||
|
||||
Testing was done using mysql version 4.0.17.
|
||||
|
||||
alter openssl_libs in the configure file, line 21056. Change '-lssl -lcrypto'
|
||||
to '-lyassl -lcryptopp -lcmapi -lcmlasn -lctil -lc++asn1'.
|
||||
|
||||
see build/config_command for the configure command used to configure mysql
|
||||
please change /home/touska/ to the relevant directory of course.
|
||||
|
||||
add yassl/lib to the LD_LIBRARY_PATH because libmysql/conf_to_src does not
|
||||
use the ssl lib directory though it does use the ssl libraries.
|
||||
|
||||
make
|
||||
|
||||
make install
|
||||
|
||||
|
||||
*********************
|
||||
|
||||
License: yassl is currently under the GPL, please see license information
|
||||
in the source and include files.
|
||||
|
||||
|
||||
*********************
|
||||
|
||||
Contact: please send comments or questions to Todd A Ouska at todd@yassl.com
|
||||
and/or Larry Stefonic at larry@yassl.com or 425-741-6858.
|
||||
|
||||
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* yaSSL buffer header defines input and output buffers to simulate streaming
|
||||
* with SSL types and sockets
|
||||
*/
|
||||
|
||||
#ifndef yaSSL_BUFFER_HPP
|
||||
#define yaSSL_BUFFER_HPP
|
||||
|
||||
#include <assert.h> // assert
|
||||
#include "yassl_types.hpp" // ysDelete
|
||||
#include "memory.hpp" // mySTL::auto_ptr
|
||||
#include STL_ALGORITHM_FILE
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// disable truncated debug symbols
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned int uint;
|
||||
const uint AUTO = 0xFEEDBEEF;
|
||||
|
||||
|
||||
// Checking Policy should implement a check function that tests whether the
|
||||
// index is within the size limit of the array
|
||||
struct Check {
|
||||
void check(uint i, uint limit);
|
||||
};
|
||||
|
||||
|
||||
struct NoCheck {
|
||||
void check(uint, uint);
|
||||
};
|
||||
|
||||
/* input_buffer operates like a smart c style array with a checking option,
|
||||
* meant to be read from through [] with AUTO index or read().
|
||||
* Should only write to at/near construction with assign() or raw (e.g., recv)
|
||||
* followed by add_size with the number of elements added by raw write.
|
||||
*
|
||||
* Not using vector because need checked []access, offset, and the ability to
|
||||
* write to the buffer bulk wise and have the correct size
|
||||
*/
|
||||
|
||||
class input_buffer : public Check {
|
||||
uint size_; // number of elements in buffer
|
||||
uint current_; // current offset position in buffer
|
||||
byte* buffer_; // storage for buffer
|
||||
byte* end_; // end of storage marker
|
||||
public:
|
||||
input_buffer();
|
||||
|
||||
explicit input_buffer(uint s);
|
||||
|
||||
// with assign
|
||||
input_buffer(uint s, const byte* t, uint len);
|
||||
|
||||
~input_buffer();
|
||||
|
||||
// users can pass defualt zero length buffer and then allocate
|
||||
void allocate(uint s);
|
||||
|
||||
// for passing to raw writing functions at beginning, then use add_size
|
||||
byte* get_buffer() const;
|
||||
|
||||
// after a raw write user can set new size
|
||||
// if you know the size before the write use assign()
|
||||
void add_size(uint i);
|
||||
|
||||
uint get_capacity() const;
|
||||
|
||||
uint get_current() const;
|
||||
|
||||
uint get_size() const;
|
||||
|
||||
uint get_remaining() const;
|
||||
|
||||
void set_current(uint i);
|
||||
|
||||
// read only access through [], advance current
|
||||
// user passes in AUTO index for ease of use
|
||||
const byte& operator[](uint i);
|
||||
|
||||
// end of input test
|
||||
bool eof();
|
||||
|
||||
// peek ahead
|
||||
byte peek() const;
|
||||
|
||||
// write function, should use at/near construction
|
||||
void assign(const byte* t, uint s);
|
||||
|
||||
// use read to query input, adjusts current
|
||||
void read(byte* dst, uint length);
|
||||
|
||||
private:
|
||||
input_buffer(const input_buffer&); // hide copy
|
||||
input_buffer& operator=(const input_buffer&); // and assign
|
||||
};
|
||||
|
||||
|
||||
/* output_buffer operates like a smart c style array with a checking option.
|
||||
* Meant to be written to through [] with AUTO index or write().
|
||||
* Size (current) counter increases when written to. Can be constructed with
|
||||
* zero length buffer but be sure to allocate before first use.
|
||||
* Don't use add write for a couple bytes, use [] instead, way less overhead.
|
||||
*
|
||||
* Not using vector because need checked []access and the ability to
|
||||
* write to the buffer bulk wise and retain correct size
|
||||
*/
|
||||
class output_buffer : public Check {
|
||||
uint current_; // current offset and elements in buffer
|
||||
byte* buffer_; // storage for buffer
|
||||
byte* end_; // end of storage marker
|
||||
public:
|
||||
// default
|
||||
output_buffer();
|
||||
|
||||
// with allocate
|
||||
explicit output_buffer(uint s);
|
||||
|
||||
// with assign
|
||||
output_buffer(uint s, const byte* t, uint len);
|
||||
|
||||
~output_buffer();
|
||||
|
||||
uint get_size() const;
|
||||
|
||||
uint get_capacity() const;
|
||||
|
||||
void set_current(uint c);
|
||||
|
||||
// users can pass defualt zero length buffer and then allocate
|
||||
void allocate(uint s);
|
||||
|
||||
// for passing to reading functions when finished
|
||||
const byte* get_buffer() const;
|
||||
|
||||
// allow write access through [], update current
|
||||
// user passes in AUTO as index for ease of use
|
||||
byte& operator[](uint i);
|
||||
|
||||
// end of output test
|
||||
bool eof();
|
||||
|
||||
void write(const byte* t, uint s);
|
||||
|
||||
private:
|
||||
output_buffer(const output_buffer&); // hide copy
|
||||
output_buffer& operator=(const output_buffer&); // and assign
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// turn delete an incomplete type into comipler error instead of warning
|
||||
template <typename T>
|
||||
inline void checked_delete(T* p)
|
||||
{
|
||||
typedef char complete_type[sizeof(T) ? 1 : -1];
|
||||
(void)sizeof(complete_type);
|
||||
ysDelete(p);
|
||||
}
|
||||
|
||||
|
||||
// checked delete functor increases effeciency, no indirection on function call
|
||||
// sets pointer to zero so safe for std conatiners
|
||||
struct del_ptr_zero
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T*& p) const
|
||||
{
|
||||
T* tmp = 0;
|
||||
STL::swap(tmp, p);
|
||||
checked_delete(tmp);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_BUUFER_HPP
|
||||
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* The certificate wrapper header defines certificate management functions
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef yaSSL_CERT_WRAPPER_HPP
|
||||
#define yaSSL_CERT_WRAPPER_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// disable truncated debug symbols
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
|
||||
#include "yassl_types.hpp" // SignatureAlgorithm
|
||||
#include "buffer.hpp" // input_buffer
|
||||
#include "asn.hpp" // SignerList
|
||||
#include "openssl/ssl.h" // internal and external use
|
||||
#include STL_LIST_FILE
|
||||
#include STL_ALGORITHM_FILE
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
typedef unsigned char opaque;
|
||||
class X509; // forward openSSL type
|
||||
|
||||
using TaoCrypt::SignerList;
|
||||
|
||||
// an x509 version 3 certificate
|
||||
class x509 {
|
||||
uint length_;
|
||||
opaque* buffer_;
|
||||
public:
|
||||
explicit x509(uint sz);
|
||||
~x509();
|
||||
|
||||
uint get_length() const;
|
||||
const opaque* get_buffer() const;
|
||||
opaque* use_buffer();
|
||||
|
||||
x509(const x509&);
|
||||
x509& operator=(const x509&);
|
||||
private:
|
||||
void Swap(x509&);
|
||||
};
|
||||
|
||||
|
||||
// Certificate Manager keeps a list of the cert chain and public key
|
||||
class CertManager {
|
||||
typedef STL::list<x509*> CertList;
|
||||
|
||||
CertList list_; // self
|
||||
input_buffer privateKey_;
|
||||
|
||||
CertList peerList_; // peer
|
||||
input_buffer peerPublicKey_;
|
||||
X509* peerX509_; // peer's openSSL X509
|
||||
|
||||
SignatureAlgorithm keyType_; // self key type
|
||||
SignatureAlgorithm peerKeyType_; // peer's key type
|
||||
|
||||
SignerList signers_; // decoded CA keys and names
|
||||
// plus verified chained certs
|
||||
bool verifyPeer_;
|
||||
bool verifyNone_; // no error if verify fails
|
||||
bool failNoCert_;
|
||||
bool sendVerify_;
|
||||
VerifyCallback verifyCallback_; // user verify callback
|
||||
public:
|
||||
CertManager();
|
||||
~CertManager();
|
||||
|
||||
void AddPeerCert(x509* x); // take ownership
|
||||
void CopySelfCert(const x509* x);
|
||||
int CopyCaCert(const x509* x);
|
||||
int Validate();
|
||||
|
||||
int SetPrivateKey(const x509&);
|
||||
|
||||
const x509* get_cert() const;
|
||||
const opaque* get_peerKey() const;
|
||||
const opaque* get_privateKey() const;
|
||||
X509* get_peerX509() const;
|
||||
SignatureAlgorithm get_keyType() const;
|
||||
SignatureAlgorithm get_peerKeyType() const;
|
||||
|
||||
uint get_peerKeyLength() const;
|
||||
uint get_privateKeyLength() const;
|
||||
|
||||
bool verifyPeer() const;
|
||||
bool verifyNone() const;
|
||||
bool failNoCert() const;
|
||||
bool sendVerify() const;
|
||||
|
||||
void setVerifyPeer();
|
||||
void setVerifyNone();
|
||||
void setFailNoCert();
|
||||
void setSendVerify();
|
||||
void setPeerX509(X509*);
|
||||
void setVerifyCallback(VerifyCallback);
|
||||
private:
|
||||
CertManager(const CertManager&); // hide copy
|
||||
CertManager& operator=(const CertManager&); // and assign
|
||||
};
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_CERT_WRAPPER_HPP
|
||||
@@ -1,427 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* The crypto wrapper header is used to define policies for the cipher
|
||||
* components used by SSL. There are 3 policies to consider:
|
||||
*
|
||||
* 1) MAC, the Message Authentication Code used for each Message
|
||||
* 2) Bulk Cipher, the Cipher used to encrypt/decrypt each Message
|
||||
* 3) Atuhentication, the Digitial Signing/Verifiaction scheme used
|
||||
*
|
||||
* This header doesn't rely on a specific crypto libraries internals,
|
||||
* only the implementation should.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef yaSSL_CRYPTO_WRAPPER_HPP
|
||||
#define yaSSL_CRYPTO_WRAPPER_HPP
|
||||
|
||||
#include "yassl_types.hpp"
|
||||
#include <stdio.h> // FILE
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
// Digest policy should implement a get_digest, update, and get sizes for pad
|
||||
// and digest
|
||||
struct Digest : public virtual_base {
|
||||
virtual void get_digest(byte*) = 0;
|
||||
virtual void get_digest(byte*, const byte*, unsigned int) = 0;
|
||||
virtual void update(const byte*, unsigned int) = 0;
|
||||
virtual uint get_digestSize() const = 0;
|
||||
virtual uint get_padSize() const = 0;
|
||||
virtual ~Digest() {}
|
||||
};
|
||||
|
||||
|
||||
// For use with NULL Digests
|
||||
struct NO_MAC : public Digest {
|
||||
void get_digest(byte*);
|
||||
void get_digest(byte*, const byte*, unsigned int);
|
||||
void update(const byte*, unsigned int);
|
||||
uint get_digestSize() const;
|
||||
uint get_padSize() const;
|
||||
};
|
||||
|
||||
|
||||
// MD5 Digest
|
||||
class MD5 : public Digest {
|
||||
public:
|
||||
void get_digest(byte*);
|
||||
void get_digest(byte*, const byte*, unsigned int);
|
||||
void update(const byte*, unsigned int);
|
||||
uint get_digestSize() const;
|
||||
uint get_padSize() const;
|
||||
MD5();
|
||||
~MD5();
|
||||
MD5(const MD5&);
|
||||
MD5& operator=(const MD5&);
|
||||
private:
|
||||
struct MD5Impl;
|
||||
MD5Impl* pimpl_;
|
||||
};
|
||||
|
||||
|
||||
// SHA-1 Digest
|
||||
class SHA : public Digest {
|
||||
public:
|
||||
void get_digest(byte*);
|
||||
void get_digest(byte*, const byte*, unsigned int);
|
||||
void update(const byte*, unsigned int);
|
||||
uint get_digestSize() const;
|
||||
uint get_padSize() const;
|
||||
SHA();
|
||||
~SHA();
|
||||
SHA(const SHA&);
|
||||
SHA& operator=(const SHA&);
|
||||
private:
|
||||
struct SHAImpl;
|
||||
SHAImpl* pimpl_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// RIPEMD-160 Digest
|
||||
class RMD : public Digest {
|
||||
public:
|
||||
void get_digest(byte*);
|
||||
void get_digest(byte*, const byte*, unsigned int);
|
||||
void update(const byte*, unsigned int);
|
||||
uint get_digestSize() const;
|
||||
uint get_padSize() const;
|
||||
RMD();
|
||||
~RMD();
|
||||
RMD(const RMD&);
|
||||
RMD& operator=(const RMD&);
|
||||
private:
|
||||
struct RMDImpl;
|
||||
RMDImpl* pimpl_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// HMAC_MD5
|
||||
class HMAC_MD5 : public Digest {
|
||||
public:
|
||||
void get_digest(byte*);
|
||||
void get_digest(byte*, const byte*, unsigned int);
|
||||
void update(const byte*, unsigned int);
|
||||
uint get_digestSize() const;
|
||||
uint get_padSize() const;
|
||||
HMAC_MD5(const byte*, unsigned int);
|
||||
~HMAC_MD5();
|
||||
private:
|
||||
struct HMAC_MD5Impl;
|
||||
HMAC_MD5Impl* pimpl_;
|
||||
|
||||
HMAC_MD5(const HMAC_MD5&);
|
||||
HMAC_MD5& operator=(const HMAC_MD5&);
|
||||
};
|
||||
|
||||
|
||||
// HMAC_SHA-1
|
||||
class HMAC_SHA : public Digest {
|
||||
public:
|
||||
void get_digest(byte*);
|
||||
void get_digest(byte*, const byte*, unsigned int);
|
||||
void update(const byte*, unsigned int);
|
||||
uint get_digestSize() const;
|
||||
uint get_padSize() const;
|
||||
HMAC_SHA(const byte*, unsigned int);
|
||||
~HMAC_SHA();
|
||||
private:
|
||||
struct HMAC_SHAImpl;
|
||||
HMAC_SHAImpl* pimpl_;
|
||||
|
||||
HMAC_SHA(const HMAC_SHA&);
|
||||
HMAC_SHA& operator=(const HMAC_SHA&);
|
||||
};
|
||||
|
||||
|
||||
// HMAC_RMD
|
||||
class HMAC_RMD : public Digest {
|
||||
public:
|
||||
void get_digest(byte*);
|
||||
void get_digest(byte*, const byte*, unsigned int);
|
||||
void update(const byte*, unsigned int);
|
||||
uint get_digestSize() const;
|
||||
uint get_padSize() const;
|
||||
HMAC_RMD(const byte*, unsigned int);
|
||||
~HMAC_RMD();
|
||||
private:
|
||||
struct HMAC_RMDImpl;
|
||||
HMAC_RMDImpl* pimpl_;
|
||||
|
||||
HMAC_RMD(const HMAC_RMD&);
|
||||
HMAC_RMD& operator=(const HMAC_RMD&);
|
||||
};
|
||||
|
||||
|
||||
// BulkCipher policy should implement encrypt, decrypt, get block size,
|
||||
// and set keys for encrypt and decrypt
|
||||
struct BulkCipher : public virtual_base {
|
||||
virtual void encrypt(byte*, const byte*, unsigned int) = 0;
|
||||
virtual void decrypt(byte*, const byte*, unsigned int) = 0;
|
||||
virtual void set_encryptKey(const byte*, const byte* = 0) = 0;
|
||||
virtual void set_decryptKey(const byte*, const byte* = 0) = 0;
|
||||
virtual uint get_blockSize() const = 0;
|
||||
virtual int get_keySize() const = 0;
|
||||
virtual int get_ivSize() const = 0;
|
||||
virtual ~BulkCipher() {}
|
||||
};
|
||||
|
||||
|
||||
// For use with NULL Ciphers
|
||||
struct NO_Cipher : public BulkCipher {
|
||||
void encrypt(byte*, const byte*, unsigned int) {}
|
||||
void decrypt(byte*, const byte*, unsigned int) {}
|
||||
void set_encryptKey(const byte*, const byte*) {}
|
||||
void set_decryptKey(const byte*, const byte*) {}
|
||||
uint get_blockSize() const { return 0; }
|
||||
int get_keySize() const { return 0; }
|
||||
int get_ivSize() const { return 0; }
|
||||
};
|
||||
|
||||
|
||||
// SSLv3 and TLSv1 always use DES in CBC mode so IV is required
|
||||
class DES : public BulkCipher {
|
||||
public:
|
||||
void encrypt(byte*, const byte*, unsigned int);
|
||||
void decrypt(byte*, const byte*, unsigned int);
|
||||
void set_encryptKey(const byte*, const byte*);
|
||||
void set_decryptKey(const byte*, const byte*);
|
||||
uint get_blockSize() const { return DES_BLOCK; }
|
||||
int get_keySize() const { return DES_KEY_SZ; }
|
||||
int get_ivSize() const { return DES_IV_SZ; }
|
||||
DES();
|
||||
~DES();
|
||||
private:
|
||||
struct DESImpl;
|
||||
DESImpl* pimpl_;
|
||||
|
||||
DES(const DES&); // hide copy
|
||||
DES& operator=(const DES&); // & assign
|
||||
};
|
||||
|
||||
|
||||
// 3DES Encrypt-Decrypt-Encrypt in CBC mode
|
||||
class DES_EDE : public BulkCipher {
|
||||
public:
|
||||
void encrypt(byte*, const byte*, unsigned int);
|
||||
void decrypt(byte*, const byte*, unsigned int);
|
||||
void set_encryptKey(const byte*, const byte*);
|
||||
void set_decryptKey(const byte*, const byte*);
|
||||
uint get_blockSize() const { return DES_BLOCK; }
|
||||
int get_keySize() const { return DES_EDE_KEY_SZ; }
|
||||
int get_ivSize() const { return DES_IV_SZ; }
|
||||
DES_EDE();
|
||||
~DES_EDE();
|
||||
private:
|
||||
struct DES_EDEImpl;
|
||||
DES_EDEImpl* pimpl_;
|
||||
|
||||
DES_EDE(const DES_EDE&); // hide copy
|
||||
DES_EDE& operator=(const DES_EDE&); // & assign
|
||||
};
|
||||
|
||||
|
||||
// Alledged RC4
|
||||
class RC4 : public BulkCipher {
|
||||
public:
|
||||
void encrypt(byte*, const byte*, unsigned int);
|
||||
void decrypt(byte*, const byte*, unsigned int);
|
||||
void set_encryptKey(const byte*, const byte*);
|
||||
void set_decryptKey(const byte*, const byte*);
|
||||
uint get_blockSize() const { return 0; }
|
||||
int get_keySize() const { return RC4_KEY_SZ; }
|
||||
int get_ivSize() const { return 0; }
|
||||
RC4();
|
||||
~RC4();
|
||||
private:
|
||||
struct RC4Impl;
|
||||
RC4Impl* pimpl_;
|
||||
|
||||
RC4(const RC4&); // hide copy
|
||||
RC4& operator=(const RC4&); // & assign
|
||||
};
|
||||
|
||||
|
||||
// AES
|
||||
class AES : public BulkCipher {
|
||||
public:
|
||||
void encrypt(byte*, const byte*, unsigned int);
|
||||
void decrypt(byte*, const byte*, unsigned int);
|
||||
void set_encryptKey(const byte*, const byte*);
|
||||
void set_decryptKey(const byte*, const byte*);
|
||||
uint get_blockSize() const { return AES_BLOCK_SZ; }
|
||||
int get_keySize() const;
|
||||
int get_ivSize() const { return AES_IV_SZ; }
|
||||
explicit AES(unsigned int = AES_128_KEY_SZ);
|
||||
~AES();
|
||||
private:
|
||||
struct AESImpl;
|
||||
AESImpl* pimpl_;
|
||||
|
||||
AES(const AES&); // hide copy
|
||||
AES& operator=(const AES&); // & assign
|
||||
};
|
||||
|
||||
|
||||
// Random number generator
|
||||
class RandomPool {
|
||||
public:
|
||||
void Fill(opaque* dst, uint sz) const;
|
||||
RandomPool();
|
||||
~RandomPool();
|
||||
|
||||
int GetError() const;
|
||||
|
||||
friend class RSA;
|
||||
friend class DSS;
|
||||
friend class DiffieHellman;
|
||||
private:
|
||||
struct RandomImpl;
|
||||
RandomImpl* pimpl_;
|
||||
|
||||
RandomPool(const RandomPool&); // hide copy
|
||||
RandomPool& operator=(const RandomPool&); // & assign
|
||||
};
|
||||
|
||||
|
||||
// Authentication policy should implement sign, and verify
|
||||
struct Auth : public virtual_base {
|
||||
virtual void sign(byte*, const byte*, unsigned int, const RandomPool&) = 0;
|
||||
virtual bool verify(const byte*, unsigned int, const byte*,
|
||||
unsigned int) = 0;
|
||||
virtual uint get_signatureLength() const = 0;
|
||||
virtual ~Auth() {}
|
||||
};
|
||||
|
||||
|
||||
// For use with NULL Authentication schemes
|
||||
struct NO_Auth : public Auth {
|
||||
void sign(byte*, const byte*, unsigned int, const RandomPool&) {}
|
||||
bool verify(const byte*, unsigned int, const byte*, unsigned int)
|
||||
{ return true; }
|
||||
};
|
||||
|
||||
|
||||
// Digitial Signature Standard scheme
|
||||
class DSS : public Auth {
|
||||
public:
|
||||
void sign(byte*, const byte*, unsigned int, const RandomPool&);
|
||||
bool verify(const byte*, unsigned int, const byte*, unsigned int);
|
||||
uint get_signatureLength() const;
|
||||
DSS(const byte*, unsigned int, bool publicKey = true);
|
||||
~DSS();
|
||||
private:
|
||||
struct DSSImpl;
|
||||
DSSImpl* pimpl_;
|
||||
|
||||
DSS(const DSS&);
|
||||
DSS& operator=(const DSS&);
|
||||
};
|
||||
|
||||
|
||||
// RSA Authentication and exchange
|
||||
class RSA : public Auth {
|
||||
public:
|
||||
void sign(byte*, const byte*, unsigned int, const RandomPool&);
|
||||
bool verify(const byte*, unsigned int, const byte*, unsigned int);
|
||||
void encrypt(byte*, const byte*, unsigned int, const RandomPool&);
|
||||
void decrypt(byte*, const byte*, unsigned int, const RandomPool&);
|
||||
uint get_signatureLength() const;
|
||||
uint get_cipherLength() const;
|
||||
RSA(const byte*, unsigned int, bool publicKey = true);
|
||||
~RSA();
|
||||
private:
|
||||
struct RSAImpl;
|
||||
RSAImpl* pimpl_;
|
||||
|
||||
RSA(const RSA&); // hide copy
|
||||
RSA& operator=(const RSA&); // & assing
|
||||
};
|
||||
|
||||
|
||||
class Integer;
|
||||
|
||||
// Diffie-Hellman agreement
|
||||
// hide for now TODO: figure out a way to give access to C clients p and g args
|
||||
class DiffieHellman {
|
||||
public:
|
||||
DiffieHellman(const byte*, unsigned int, const byte*, unsigned int,
|
||||
const byte*, unsigned int, const RandomPool& random);
|
||||
//DiffieHellman(const char*, const RandomPool&);
|
||||
DiffieHellman(const Integer&, const Integer&, const RandomPool&);
|
||||
~DiffieHellman();
|
||||
|
||||
DiffieHellman(const DiffieHellman&);
|
||||
DiffieHellman& operator=(const DiffieHellman&);
|
||||
|
||||
uint get_agreedKeyLength() const;
|
||||
const byte* get_agreedKey() const;
|
||||
const byte* get_publicKey() const;
|
||||
void makeAgreement(const byte*, unsigned int);
|
||||
|
||||
void set_sizes(int&, int&, int&) const;
|
||||
void get_parms(byte*, byte*, byte*) const;
|
||||
private:
|
||||
struct DHImpl;
|
||||
DHImpl* pimpl_;
|
||||
};
|
||||
|
||||
|
||||
// Lagrge Integer
|
||||
class Integer {
|
||||
public:
|
||||
Integer();
|
||||
~Integer();
|
||||
|
||||
Integer(const Integer&);
|
||||
Integer& operator=(const Integer&);
|
||||
|
||||
void assign(const byte*, unsigned int);
|
||||
|
||||
friend class DiffieHellman;
|
||||
private:
|
||||
struct IntegerImpl;
|
||||
IntegerImpl* pimpl_;
|
||||
};
|
||||
|
||||
|
||||
class x509;
|
||||
|
||||
|
||||
struct EncryptedInfo {
|
||||
enum { IV_SZ = 32, NAME_SZ = 80 };
|
||||
char name[NAME_SZ]; // max one line
|
||||
byte iv[IV_SZ]; // in base16 rep
|
||||
uint ivSz;
|
||||
bool set;
|
||||
|
||||
EncryptedInfo() : ivSz(0), set(false) {}
|
||||
};
|
||||
|
||||
x509* PemToDer(FILE*, CertType, EncryptedInfo* info = 0);
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_CRYPTO_WRAPPER_HPP
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* The factory header defines an Object Factory, used by SSL message and
|
||||
* handshake types.
|
||||
*
|
||||
* See Desgin Pattern in GoF and Alexandrescu's chapter in Modern C++ Design,
|
||||
* page 208
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef yaSSL_FACTORY_HPP
|
||||
#define yaSSL_FACTORY_HPP
|
||||
|
||||
#include STL_VECTOR_FILE
|
||||
#include STL_PAIR_FILE
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
// Factory uses its callback map to create objects by id,
|
||||
// returning an abstract base pointer
|
||||
template<class AbstractProduct,
|
||||
typename IdentifierType = int,
|
||||
typename ProductCreator = AbstractProduct* (*)()
|
||||
>
|
||||
class Factory {
|
||||
typedef STL::pair<IdentifierType, ProductCreator> CallBack;
|
||||
typedef STL::vector<CallBack> CallBackVector;
|
||||
|
||||
CallBackVector callbacks_;
|
||||
public:
|
||||
// pass function pointer to register all callbacks upon creation
|
||||
explicit Factory(void (*init)(Factory<AbstractProduct, IdentifierType,
|
||||
ProductCreator>&))
|
||||
{
|
||||
init(*this);
|
||||
}
|
||||
|
||||
// reserve place in vector before registering, used by init funcion
|
||||
void Reserve(size_t sz)
|
||||
{
|
||||
callbacks_.reserve(sz);
|
||||
}
|
||||
|
||||
// register callback
|
||||
void Register(const IdentifierType& id, ProductCreator pc)
|
||||
{
|
||||
callbacks_.push_back(STL::make_pair(id, pc));
|
||||
}
|
||||
|
||||
// THE Creator, returns a new object of the proper type or 0
|
||||
AbstractProduct* CreateObject(const IdentifierType& id) const
|
||||
{
|
||||
typedef typename STL::vector<CallBack>::const_iterator cIter;
|
||||
|
||||
cIter first = callbacks_.begin();
|
||||
cIter last = callbacks_.end();
|
||||
|
||||
while (first != last) {
|
||||
if (first->first == id)
|
||||
break;
|
||||
++first;
|
||||
}
|
||||
|
||||
if (first == callbacks_.end())
|
||||
return 0;
|
||||
return (first->second)();
|
||||
}
|
||||
private:
|
||||
Factory(const Factory&); // hide copy
|
||||
Factory& operator=(const Factory&); // and assign
|
||||
};
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_FACTORY_HPP
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* The handshake header declares function prototypes for creating and reading
|
||||
* the various handshake messages.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef yaSSL_HANDSHAKE_HPP
|
||||
#define yaSSL_HANDSHAKE_HPP
|
||||
|
||||
#include "yassl_types.hpp"
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
// forward decls
|
||||
class SSL;
|
||||
class Finished;
|
||||
class Data;
|
||||
class Alert;
|
||||
struct Hashes;
|
||||
|
||||
enum BufferOutput { buffered, unbuffered };
|
||||
|
||||
void sendClientHello(SSL&);
|
||||
void sendServerHello(SSL&, BufferOutput = buffered);
|
||||
void sendServerHelloDone(SSL&, BufferOutput = buffered);
|
||||
void sendClientKeyExchange(SSL&, BufferOutput = buffered);
|
||||
void sendServerKeyExchange(SSL&, BufferOutput = buffered);
|
||||
void sendChangeCipher(SSL&, BufferOutput = buffered);
|
||||
void sendFinished(SSL&, ConnectionEnd, BufferOutput = buffered);
|
||||
void sendCertificate(SSL&, BufferOutput = buffered);
|
||||
void sendCertificateRequest(SSL&, BufferOutput = buffered);
|
||||
void sendCertificateVerify(SSL&, BufferOutput = buffered);
|
||||
int sendData(SSL&, const void*, int);
|
||||
int sendAlert(SSL& ssl, const Alert& alert);
|
||||
|
||||
int receiveData(SSL&, Data&, bool peek = false);
|
||||
void processReply(SSL&);
|
||||
|
||||
void buildFinished(SSL&, Finished&, const opaque*);
|
||||
void build_certHashes(SSL&, Hashes&);
|
||||
|
||||
void hmac(SSL&, byte*, const byte*, uint, ContentType, bool verify = false);
|
||||
void TLS_hmac(SSL&, byte*, const byte*, uint, ContentType,
|
||||
bool verify = false);
|
||||
void PRF(byte* digest, uint digLen, const byte* secret, uint secLen,
|
||||
const byte* label, uint labLen, const byte* seed, uint seedLen);
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_HANDSHAKE_HPP
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* lock.hpp provides an os specific Lock, locks mutex on entry and unlocks
|
||||
* automatically upon exit, no-ops provided for Single Threaded
|
||||
*/
|
||||
|
||||
#ifndef yaSSL_LOCK_HPP
|
||||
#define yaSSL_LOCK_HPP
|
||||
|
||||
/*
|
||||
Visual Studio Source Annotations header (sourceannotations.h) fails
|
||||
to compile if outside of the global namespace.
|
||||
*/
|
||||
#ifdef YASSL_THREAD_SAFE
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
#ifdef YASSL_THREAD_SAFE
|
||||
#ifdef _WIN32
|
||||
|
||||
class Mutex {
|
||||
CRITICAL_SECTION cs_;
|
||||
public:
|
||||
Mutex();
|
||||
~Mutex();
|
||||
|
||||
class Lock;
|
||||
friend class Lock;
|
||||
|
||||
class Lock {
|
||||
Mutex& mutex_;
|
||||
public:
|
||||
explicit Lock(Mutex& lm);
|
||||
~Lock();
|
||||
};
|
||||
};
|
||||
#else // _WIN32
|
||||
#include <pthread.h>
|
||||
|
||||
class Mutex {
|
||||
pthread_mutex_t mutex_;
|
||||
public:
|
||||
|
||||
Mutex();
|
||||
~Mutex();
|
||||
|
||||
class Lock;
|
||||
friend class Lock;
|
||||
|
||||
class Lock {
|
||||
Mutex& mutex_;
|
||||
public:
|
||||
explicit Lock(Mutex& lm);
|
||||
~Lock();
|
||||
};
|
||||
};
|
||||
|
||||
#endif // _WIN32
|
||||
#else // YASSL_THREAD_SAFE (WE'RE SINGLE)
|
||||
|
||||
class Mutex {
|
||||
public:
|
||||
class Lock {
|
||||
public:
|
||||
explicit Lock(Mutex&) {}
|
||||
};
|
||||
};
|
||||
|
||||
#endif // YASSL_THREAD_SAFE
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
#endif // yaSSL_LOCK_HPP
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* yaSSL log interface
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef yaSSL_LOG_HPP
|
||||
#define yaSSL_LOG_HPP
|
||||
|
||||
#include "socket_wrapper.hpp"
|
||||
|
||||
#ifdef YASSL_LOG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
|
||||
// Debug logger
|
||||
class Log {
|
||||
#ifdef YASSL_LOG
|
||||
FILE* log_;
|
||||
#endif
|
||||
public:
|
||||
explicit Log(const char* str = "yaSSL.log");
|
||||
~Log();
|
||||
|
||||
void Trace(const char*);
|
||||
void ShowTCP(socket_t, bool ended = false);
|
||||
void ShowData(uint, bool sent = false);
|
||||
};
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_LOG_HPP
|
||||
@@ -1,18 +0,0 @@
|
||||
/* crypto.h for openSSL */
|
||||
|
||||
#ifndef ysSSL_crypto_h__
|
||||
#define yaSSL_crypto_h__
|
||||
|
||||
#ifdef YASSL_PREFIX
|
||||
#include "prefix_crypto.h"
|
||||
#endif
|
||||
|
||||
const char* SSLeay_version(int type);
|
||||
|
||||
#define SSLEAY_NUMBER_DEFINED
|
||||
#define SSLEAY_VERSION 0x0900L
|
||||
#define SSLEAY_VERSION_NUMBER SSLEAY_VERSION
|
||||
|
||||
|
||||
#endif /* yaSSL_crypto_h__ */
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/* des.h for openssl */
|
||||
@@ -1 +0,0 @@
|
||||
/* des_old.h for openvn */
|
||||
@@ -1,5 +0,0 @@
|
||||
/* engine.h for libcurl */
|
||||
|
||||
#undef HAVE_OPENSSL_ENGINE_H
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/* err.h for openssl */
|
||||
|
||||
#ifndef yaSSL_err_h__
|
||||
#define yaSSL_err_h__
|
||||
|
||||
|
||||
|
||||
#endif /* yaSSL_err_h__ */
|
||||
@@ -1,10 +0,0 @@
|
||||
/* evp.h for openSSL */
|
||||
|
||||
#ifndef SSLEAY_NUMBER_DEFINED
|
||||
#define SSLEAY_NUMBER_DEFINED
|
||||
|
||||
/* for OpenVPN */
|
||||
#define SSLEAY_VERSION_NUMBER 0x0090700f
|
||||
|
||||
|
||||
#endif /* SSLEAY_NUMBER_DEFINED */
|
||||
@@ -1 +0,0 @@
|
||||
/* hmac.h for openvpn */
|
||||
@@ -1,2 +0,0 @@
|
||||
/* lhash.h for openSSL */
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/* md4.h for libcurl */
|
||||
@@ -1,4 +0,0 @@
|
||||
/* md5.h for openssl */
|
||||
|
||||
#include "ssl.h" /* in there for now */
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/* objects.h for openvpn */
|
||||
@@ -1,12 +0,0 @@
|
||||
/* opensslv.h compatibility */
|
||||
|
||||
#ifndef yaSSL_opensslv_h__
|
||||
#define yaSSL_opensslv_h__
|
||||
|
||||
|
||||
/* api version compatibility */
|
||||
#define OPENSSL_VERSION_NUMBER 0x0090700f
|
||||
|
||||
|
||||
#endif /* yaSSLopensslv_h__ */
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/* pem.h for libcurl */
|
||||
@@ -1,5 +0,0 @@
|
||||
/* pkcs12.h for libcurl */
|
||||
|
||||
|
||||
#undef HAVE_OPENSSL_PKCS12_H
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#define SSLeay_version yaSSLeay_version
|
||||
@@ -1,169 +0,0 @@
|
||||
#define Copyright yaCopyright
|
||||
#define yaSSL_CleanUp yayaSSL_CleanUp
|
||||
#define BN_bin2bn yaBN_bin2bn
|
||||
#define DH_new yaDH_new
|
||||
#define DH_free yaDH_free
|
||||
#define RSA_free yaRSA_free
|
||||
#define RSA_generate_key yaRSA_generate_key
|
||||
#define X509_free yaX509_free
|
||||
#define X509_STORE_CTX_get_current_cert yaX509_STORE_CTX_get_current_cert
|
||||
#define X509_STORE_CTX_get_error yaX509_STORE_CTX_get_error
|
||||
#define X509_STORE_CTX_get_error_depth yaX509_STORE_CTX_get_error_depth
|
||||
#define X509_NAME_oneline yaX509_NAME_oneline
|
||||
#define X509_get_issuer_name yaX509_get_issuer_name
|
||||
#define X509_get_subject_name yaX509_get_subject_name
|
||||
#define X509_verify_cert_error_string yaX509_verify_cert_error_string
|
||||
#define X509_LOOKUP_add_dir yaX509_LOOKUP_add_dir
|
||||
#define X509_LOOKUP_load_file yaX509_LOOKUP_load_file
|
||||
#define X509_LOOKUP_hash_dir yaX509_LOOKUP_hash_dir
|
||||
#define X509_LOOKUP_file yaX509_LOOKUP_file
|
||||
#define X509_STORE_add_lookup yaX509_STORE_add_lookup
|
||||
#define X509_STORE_new yaX509_STORE_new
|
||||
#define X509_STORE_get_by_subject yaX509_STORE_get_by_subject
|
||||
#define ERR_get_error_line_data yaERR_get_error_line_data
|
||||
#define ERR_print_errors_fp yaERR_print_errors_fp
|
||||
#define ERR_error_string yaERR_error_string
|
||||
#define ERR_remove_state yaERR_remove_state
|
||||
#define ERR_get_error yaERR_get_error
|
||||
#define ERR_peek_error yaERR_peek_error
|
||||
#define ERR_GET_REASON yaERR_GET_REASON
|
||||
#define SSL_CTX_new yaSSL_CTX_new
|
||||
#define SSL_new yaSSL_new
|
||||
#define SSL_set_fd yaSSL_set_fd
|
||||
#define SSL_get_fd yaSSL_get_fd
|
||||
#define SSL_connect yaSSL_connect
|
||||
#define SSL_write yaSSL_write
|
||||
#define SSL_read yaSSL_read
|
||||
#define SSL_accept yaSSL_accept
|
||||
#define SSL_CTX_free yaSSL_CTX_free
|
||||
#define SSL_free yaSSL_free
|
||||
#define SSL_clear yaSSL_clear
|
||||
#define SSL_shutdown yaSSL_shutdown
|
||||
#define SSL_set_connect_state yaSSL_set_connect_state
|
||||
#define SSL_set_accept_state yaSSL_set_accept_state
|
||||
#define SSL_do_handshake yaSSL_do_handshake
|
||||
#define SSL_get_cipher yaSSL_get_cipher
|
||||
#define SSL_get_cipher_name yaSSL_get_cipher_name
|
||||
#define SSL_get_shared_ciphers yaSSL_get_shared_ciphers
|
||||
#define SSL_get_cipher_list yaSSL_get_cipher_list
|
||||
#define SSL_get_version yaSSL_get_version
|
||||
#define SSLeay_version yaSSLeay_version
|
||||
#define SSL_get_error yaSSL_get_error
|
||||
#define SSL_load_error_strings yaSSL_load_error_strings
|
||||
#define SSL_set_session yaSSL_set_session
|
||||
#define SSL_get_session yaSSL_get_session
|
||||
#define SSL_flush_sessions yaSSL_flush_sessions
|
||||
#define SSL_SESSION_set_timeout yaSSL_SESSION_set_timeout
|
||||
#define SSL_CTX_set_session_cache_mode yaSSL_CTX_set_session_cache_mode
|
||||
#define SSL_get_peer_certificate yaSSL_get_peer_certificate
|
||||
#define SSL_get_verify_result yaSSL_get_verify_result
|
||||
#define SSL_CTX_set_verify yaSSL_CTX_set_verify
|
||||
#define SSL_CTX_load_verify_locations yaSSL_CTX_load_verify_locations
|
||||
#define SSL_CTX_set_default_verify_paths yaSSL_CTX_set_default_verify_paths
|
||||
#define SSL_CTX_check_private_key yaSSL_CTX_check_private_key
|
||||
#define SSL_CTX_set_session_id_context yaSSL_CTX_set_session_id_context
|
||||
#define SSL_CTX_set_tmp_rsa_callback yaSSL_CTX_set_tmp_rsa_callback
|
||||
#define SSL_CTX_set_options yaSSL_CTX_set_options
|
||||
#define SSL_CTX_set_session_cache_mode yaSSL_CTX_set_session_cache_mode
|
||||
#define SSL_CTX_set_timeout yaSSL_CTX_set_timeout
|
||||
#define SSL_CTX_use_certificate_chain_file yaSSL_CTX_use_certificate_chain_file
|
||||
#define SSL_CTX_set_default_passwd_cb yaSSL_CTX_set_default_passwd_cb
|
||||
#define SSL_CTX_use_RSAPrivateKey_file yaSSL_CTX_use_RSAPrivateKey_file
|
||||
#define SSL_CTX_set_info_callback yaSSL_CTX_set_info_callback
|
||||
#define SSL_CTX_sess_accept yaSSL_CTX_sess_accept
|
||||
#define SSL_CTX_sess_connect yaSSL_CTX_sess_connect
|
||||
#define SSL_CTX_sess_accept_good yaSSL_CTX_sess_accept_good
|
||||
#define SSL_CTX_sess_connect_good yaSSL_CTX_sess_connect_good
|
||||
#define SSL_CTX_sess_accept_renegotiate yaSSL_CTX_sess_accept_renegotiate
|
||||
#define SSL_CTX_sess_connect_renegotiate yaSSL_CTX_sess_connect_renegotiate
|
||||
#define SSL_CTX_sess_hits yaSSL_CTX_sess_hits
|
||||
#define SSL_CTX_sess_cb_hits yaSSL_CTX_sess_cb_hits
|
||||
#define SSL_CTX_sess_cache_full yaSSL_CTX_sess_cache_full
|
||||
#define SSL_CTX_sess_misses yaSSL_CTX_sess_misses
|
||||
#define SSL_CTX_sess_timeouts yaSSL_CTX_sess_timeouts
|
||||
#define SSL_CTX_sess_number yaSSL_CTX_sess_number
|
||||
#define SSL_CTX_sess_get_cache_size yaSSL_CTX_sess_get_cache_size
|
||||
#define SSL_CTX_get_verify_mode yaSSL_CTX_get_verify_mode
|
||||
#define SSL_get_verify_mode yaSSL_get_verify_mode
|
||||
#define SSL_CTX_get_verify_depth yaSSL_CTX_get_verify_depth
|
||||
#define SSL_get_verify_depth yaSSL_get_verify_depth
|
||||
#define SSL_get_default_timeout yaSSL_get_default_timeout
|
||||
#define SSL_CTX_get_session_cache_mode yaSSL_CTX_get_session_cache_mode
|
||||
#define SSL_session_reused yaSSL_session_reused
|
||||
#define SSL_set_rfd yaSSL_set_rfd
|
||||
#define SSL_set_wfd yaSSL_set_wfd
|
||||
#define SSL_set_shutdown yaSSL_set_shutdown
|
||||
#define SSL_set_quiet_shutdown yaSSL_set_quiet_shutdown
|
||||
#define SSL_get_quiet_shutdown yaSSL_get_quiet_shutdown
|
||||
#define SSL_want_read yaSSL_want_read
|
||||
#define SSL_want_write yaSSL_want_write
|
||||
#define SSL_pending yaSSL_pending
|
||||
#define SSLv3_method yaSSLv3_method
|
||||
#define SSLv3_server_method yaSSLv3_server_method
|
||||
#define SSLv3_client_method yaSSLv3_client_method
|
||||
#define TLSv1_server_method yaTLSv1_server_method
|
||||
#define TLSv1_client_method yaTLSv1_client_method
|
||||
#define TLSv1_1_server_method yaTLSv1_1_server_method
|
||||
#define TLSv1_1_client_method yaTLSv1_1_client_method
|
||||
#define SSLv23_server_method yaSSLv23_server_method
|
||||
#define SSL_CTX_use_certificate_file yaSSL_CTX_use_certificate_file
|
||||
#define SSL_CTX_use_PrivateKey_file yaSSL_CTX_use_PrivateKey_file
|
||||
#define SSL_CTX_set_cipher_list yaSSL_CTX_set_cipher_list
|
||||
#define SSL_CTX_sess_set_cache_size yaSSL_CTX_sess_set_cache_size
|
||||
#define SSL_CTX_set_tmp_dh yaSSL_CTX_set_tmp_dh
|
||||
#define OpenSSL_add_all_algorithms yaOpenSSL_add_all_algorithms
|
||||
#define SSL_library_init yaSSL_library_init
|
||||
#define SSLeay_add_ssl_algorithms yaSSLeay_add_ssl_algorithms
|
||||
#define SSL_get_current_cipher yaSSL_get_current_cipher
|
||||
#define SSL_CIPHER_description yaSSL_CIPHER_description
|
||||
#define SSL_alert_type_string_long yaSSL_alert_type_string_long
|
||||
#define SSL_alert_desc_string_long yaSSL_alert_desc_string_long
|
||||
#define SSL_state_string_long yaSSL_state_string_long
|
||||
#define EVP_md5 yaEVP_md5
|
||||
#define EVP_des_ede3_cbc yaEVP_des_ede3_cbc
|
||||
#define EVP_BytesToKey yaEVP_BytesToKey
|
||||
#define DES_set_key_unchecked yaDES_set_key_unchecked
|
||||
#define DES_ede3_cbc_encrypt yaDES_ede3_cbc_encrypt
|
||||
#define RAND_screen yaRAND_screen
|
||||
#define RAND_file_name yaRAND_file_name
|
||||
#define RAND_write_file yaRAND_write_file
|
||||
#define RAND_load_file yaRAND_load_file
|
||||
#define RAND_status yaRAND_status
|
||||
#define RAND_bytes yaRAND_bytes
|
||||
#define DES_set_key yaDES_set_key
|
||||
#define DES_set_odd_parity yaDES_set_odd_parity
|
||||
#define DES_ecb_encrypt yaDES_ecb_encrypt
|
||||
#define SSL_CTX_set_default_passwd_cb_userdata yaSSL_CTX_set_default_passwd_cb_userdata
|
||||
#define SSL_SESSION_free yaSSL_SESSION_free
|
||||
#define SSL_peek yaSSL_peek
|
||||
#define SSL_get_certificate yaSSL_get_certificate
|
||||
#define SSL_get_privatekey yaSSL_get_privatekey
|
||||
#define X509_get_pubkey yaX509_get_pubkey
|
||||
#define EVP_PKEY_copy_parameters yaEVP_PKEY_copy_parameters
|
||||
#define EVP_PKEY_free yaEVP_PKEY_free
|
||||
#define ERR_error_string_n yaERR_error_string_n
|
||||
#define ERR_free_strings yaERR_free_strings
|
||||
#define EVP_cleanup yaEVP_cleanup
|
||||
#define X509_get_ext_d2i yaX509_get_ext_d2i
|
||||
#define GENERAL_NAMES_free yaGENERAL_NAMES_free
|
||||
#define sk_GENERAL_NAME_num yask_GENERAL_NAME_num
|
||||
#define sk_GENERAL_NAME_value yask_GENERAL_NAME_value
|
||||
#define ASN1_STRING_data yaASN1_STRING_data
|
||||
#define ASN1_STRING_length yaASN1_STRING_length
|
||||
#define ASN1_STRING_type yaASN1_STRING_type
|
||||
#define X509_NAME_get_index_by_NID yaX509_NAME_get_index_by_NID
|
||||
#define X509_NAME_ENTRY_get_data yaX509_NAME_ENTRY_get_data
|
||||
#define X509_NAME_get_entry yaX509_NAME_get_entry
|
||||
#define ASN1_STRING_to_UTF8 yaASN1_STRING_to_UTF8
|
||||
#define SSLv23_client_method yaSSLv23_client_method
|
||||
#define SSLv2_client_method yaSSLv2_client_method
|
||||
#define SSL_get1_session yaSSL_get1_session
|
||||
#define X509_get_notBefore yaX509_get_notBefore
|
||||
#define X509_get_notAfter yaX509_get_notAfter
|
||||
#define MD4_Init yaMD4_Init
|
||||
#define MD4_Update yaMD4_Update
|
||||
#define MD4_Final yaMD4_Final
|
||||
#define MD5_Init yaMD5_Init
|
||||
#define MD5_Update yaMD5_Update
|
||||
#define MD5_Final yaMD5_Final
|
||||
#define SSL_set_compression yaSSL_set_compression
|
||||
@@ -1,2 +0,0 @@
|
||||
/* rand.h for openSSL */
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
/* rsa.h for openSSL */
|
||||
|
||||
|
||||
#ifndef yaSSL_rsa_h__
|
||||
#define yaSSL_rsa_h__
|
||||
|
||||
enum { RSA_F4 = 1 };
|
||||
|
||||
|
||||
#endif /* yaSSL_rsa_h__ */
|
||||
@@ -1 +0,0 @@
|
||||
/* sha.h for openvpn */
|
||||
@@ -1,554 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* ssl.h defines openssl compatibility layer
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef yaSSL_openssl_h__
|
||||
#define yaSSL_openssl_h__
|
||||
|
||||
#ifdef YASSL_PREFIX
|
||||
#include "prefix_ssl.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* ERR_print fp */
|
||||
#include "opensslv.h" /* for version number */
|
||||
#include "rsa.h"
|
||||
|
||||
|
||||
#define YASSL_VERSION "1.7.2"
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void yaSSL_CleanUp(); /* call once at end of application use to
|
||||
free static singleton memory holders,
|
||||
not a leak per se, but helpful when
|
||||
looking for them */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)
|
||||
namespace yaSSL {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef X509_NAME /* wincrypt.h clash */
|
||||
|
||||
#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)
|
||||
class SSL;
|
||||
class SSL_SESSION;
|
||||
class SSL_METHOD;
|
||||
class SSL_CTX;
|
||||
class SSL_CIPHER;
|
||||
|
||||
class RSA;
|
||||
|
||||
class X509;
|
||||
class X509_NAME;
|
||||
#else
|
||||
typedef struct SSL SSL;
|
||||
typedef struct SSL_SESSION SSL_SESSION;
|
||||
typedef struct SSL_METHOD SSL_METHOD;
|
||||
typedef struct SSL_CTX SSL_CTX;
|
||||
typedef struct SSL_CIPHER SSL_CIPHER;
|
||||
|
||||
typedef struct RSA RSA;
|
||||
|
||||
typedef struct X509 X509;
|
||||
typedef struct X509_NAME X509_NAME;
|
||||
#endif
|
||||
|
||||
|
||||
/* Big Number stuff, different file? */
|
||||
typedef struct BIGNUM BIGNUM;
|
||||
|
||||
BIGNUM *BN_bin2bn(const unsigned char*, int, BIGNUM*);
|
||||
|
||||
|
||||
/* Diffie-Hellman stuff, different file? */
|
||||
/* mySQL deferences to set group parameters */
|
||||
typedef struct DH {
|
||||
BIGNUM* p;
|
||||
BIGNUM* g;
|
||||
} DH;
|
||||
|
||||
DH* DH_new(void);
|
||||
void DH_free(DH*);
|
||||
|
||||
/* RSA stuff */
|
||||
|
||||
void RSA_free(RSA*);
|
||||
RSA* RSA_generate_key(int, unsigned long, void(*)(int, int, void*), void*);
|
||||
|
||||
|
||||
/* X509 stuff, different file? */
|
||||
|
||||
typedef struct X509_STORE X509_STORE;
|
||||
typedef struct X509_LOOKUP X509_LOOKUP;
|
||||
typedef struct X509_OBJECT { char c; } X509_OBJECT;
|
||||
typedef struct X509_CRL X509_CRL;
|
||||
typedef struct X509_REVOKED X509_REVOKED;
|
||||
typedef struct X509_LOOKUP_METHOD X509_LOOKUP_METHOD;
|
||||
|
||||
|
||||
void X509_free(X509*);
|
||||
|
||||
|
||||
/* bio stuff */
|
||||
typedef struct BIO BIO;
|
||||
|
||||
/* ASN stuff */
|
||||
|
||||
|
||||
|
||||
/* because mySQL dereferences to use error and current_cert, even after calling
|
||||
* get functions for local references */
|
||||
typedef struct X509_STORE_CTX {
|
||||
int error;
|
||||
int error_depth;
|
||||
X509* current_cert;
|
||||
} X509_STORE_CTX;
|
||||
|
||||
|
||||
|
||||
X509* X509_STORE_CTX_get_current_cert(X509_STORE_CTX*);
|
||||
int X509_STORE_CTX_get_error(X509_STORE_CTX*);
|
||||
int X509_STORE_CTX_get_error_depth(X509_STORE_CTX*);
|
||||
|
||||
char* X509_NAME_oneline(X509_NAME*, char*, int);
|
||||
X509_NAME* X509_get_issuer_name(X509*);
|
||||
X509_NAME* X509_get_subject_name(X509*);
|
||||
const char* X509_verify_cert_error_string(long);
|
||||
|
||||
int X509_LOOKUP_add_dir(X509_LOOKUP*, const char*, long);
|
||||
int X509_LOOKUP_load_file(X509_LOOKUP*, const char*, long);
|
||||
X509_LOOKUP_METHOD* X509_LOOKUP_hash_dir(void);
|
||||
X509_LOOKUP_METHOD* X509_LOOKUP_file(void);
|
||||
|
||||
X509_LOOKUP* X509_STORE_add_lookup(X509_STORE*, X509_LOOKUP_METHOD*);
|
||||
X509_STORE* X509_STORE_new(void);
|
||||
int X509_STORE_get_by_subject(X509_STORE_CTX*, int, X509_NAME*,
|
||||
X509_OBJECT*);
|
||||
|
||||
|
||||
|
||||
|
||||
enum { /* X509 Constants */
|
||||
X509_V_OK = 0,
|
||||
X509_V_ERR_CERT_CHAIN_TOO_LONG = 1,
|
||||
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 2,
|
||||
X509_V_ERR_CERT_NOT_YET_VALID = 3,
|
||||
X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 4,
|
||||
X509_V_ERR_CERT_HAS_EXPIRED = 5,
|
||||
X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 6,
|
||||
X509_FILETYPE_PEM = 7,
|
||||
X509_LU_X509 = 8,
|
||||
X509_LU_CRL = 9,
|
||||
X509_V_ERR_CRL_SIGNATURE_FAILURE = 10,
|
||||
X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 11,
|
||||
X509_V_ERR_CRL_HAS_EXPIRED = 12,
|
||||
X509_V_ERR_CERT_REVOKED = 13,
|
||||
X509_V_FLAG_CRL_CHECK = 14,
|
||||
X509_V_FLAG_CRL_CHECK_ALL = 15
|
||||
};
|
||||
|
||||
|
||||
/* Error stuff, could move to yassl_error */
|
||||
unsigned long ERR_get_error_line_data(const char**, int*, const char**, int *);
|
||||
void ERR_print_errors_fp(FILE*);
|
||||
char* ERR_error_string(unsigned long,char*);
|
||||
void ERR_remove_state(unsigned long);
|
||||
unsigned long ERR_get_error(void);
|
||||
unsigned long ERR_peek_error(void);
|
||||
int ERR_GET_REASON(int);
|
||||
|
||||
|
||||
enum { /* ERR Constants */
|
||||
ERR_TXT_STRING = 1,
|
||||
EVP_R_BAD_DECRYPT = 2
|
||||
};
|
||||
|
||||
/*
|
||||
Allow type used by SSL_set_fd to be changed, default to int
|
||||
in order to be compatible with OpenSSL
|
||||
*/
|
||||
#ifndef YASSL_SOCKET_T_DEFINED
|
||||
typedef int YASSL_SOCKET_T;
|
||||
#endif
|
||||
|
||||
SSL_CTX* SSL_CTX_new(SSL_METHOD*);
|
||||
SSL* SSL_new(SSL_CTX*);
|
||||
int SSL_set_fd (SSL*, YASSL_SOCKET_T);
|
||||
YASSL_SOCKET_T SSL_get_fd(const SSL*);
|
||||
int SSL_connect(SSL*); /* if you get an error from connect
|
||||
see note at top of REAMDE */
|
||||
int SSL_write(SSL*, const void*, int);
|
||||
int SSL_read(SSL*, void*, int);
|
||||
int SSL_accept(SSL*);
|
||||
void SSL_CTX_free(SSL_CTX*);
|
||||
void SSL_free(SSL*);
|
||||
int SSL_clear(SSL*);
|
||||
int SSL_shutdown(SSL*);
|
||||
|
||||
void SSL_set_connect_state(SSL*);
|
||||
void SSL_set_accept_state(SSL*);
|
||||
int SSL_do_handshake(SSL*);
|
||||
|
||||
const char* SSL_get_cipher(SSL*);
|
||||
const char* SSL_get_cipher_name(SSL*); /* uses SSL_get_cipher */
|
||||
char* SSL_get_shared_ciphers(SSL*, char*, int);
|
||||
const char* SSL_get_cipher_list(SSL*, int);
|
||||
const char* SSL_get_version(SSL*);
|
||||
const char* SSLeay_version(int);
|
||||
|
||||
int SSL_get_error(SSL*, int);
|
||||
void SSL_load_error_strings(void);
|
||||
|
||||
int SSL_set_session(SSL *ssl, SSL_SESSION *session);
|
||||
SSL_SESSION* SSL_get_session(SSL* ssl);
|
||||
void SSL_flush_sessions(SSL_CTX *ctx, long tm);
|
||||
long SSL_SESSION_set_timeout(SSL_SESSION*, long);
|
||||
long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode);
|
||||
X509* SSL_get_peer_certificate(SSL*);
|
||||
long SSL_get_verify_result(SSL*);
|
||||
|
||||
|
||||
typedef int (*VerifyCallback)(int, X509_STORE_CTX*);
|
||||
typedef int (*pem_password_cb)(char*, int, int, void*);
|
||||
|
||||
void SSL_CTX_set_verify(SSL_CTX*, int, VerifyCallback verify_callback);
|
||||
int SSL_CTX_load_verify_locations(SSL_CTX*, const char*, const char*);
|
||||
int SSL_CTX_set_default_verify_paths(SSL_CTX*);
|
||||
int SSL_CTX_check_private_key(SSL_CTX*);
|
||||
int SSL_CTX_set_session_id_context(SSL_CTX*, const unsigned char*,
|
||||
unsigned int);
|
||||
|
||||
void SSL_CTX_set_tmp_rsa_callback(SSL_CTX*, RSA*(*)(SSL*, int, int));
|
||||
long SSL_CTX_set_options(SSL_CTX*, long);
|
||||
long SSL_CTX_set_session_cache_mode(SSL_CTX*, long);
|
||||
long SSL_CTX_set_timeout(SSL_CTX*, long);
|
||||
int SSL_CTX_use_certificate_chain_file(SSL_CTX*, const char*);
|
||||
void SSL_CTX_set_default_passwd_cb(SSL_CTX*, pem_password_cb);
|
||||
int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX*, const char*, int);
|
||||
void SSL_CTX_set_info_callback(SSL_CTX*, void (*)());
|
||||
|
||||
long SSL_CTX_sess_accept(SSL_CTX*);
|
||||
long SSL_CTX_sess_connect(SSL_CTX*);
|
||||
long SSL_CTX_sess_accept_good(SSL_CTX*);
|
||||
long SSL_CTX_sess_connect_good(SSL_CTX*);
|
||||
long SSL_CTX_sess_accept_renegotiate(SSL_CTX*);
|
||||
long SSL_CTX_sess_connect_renegotiate(SSL_CTX*);
|
||||
long SSL_CTX_sess_hits(SSL_CTX*);
|
||||
long SSL_CTX_sess_cb_hits(SSL_CTX*);
|
||||
long SSL_CTX_sess_cache_full(SSL_CTX*);
|
||||
long SSL_CTX_sess_misses(SSL_CTX*);
|
||||
long SSL_CTX_sess_timeouts(SSL_CTX*);
|
||||
long SSL_CTX_sess_number(SSL_CTX*);
|
||||
long SSL_CTX_sess_get_cache_size(SSL_CTX*);
|
||||
|
||||
int SSL_CTX_get_verify_mode(SSL_CTX*);
|
||||
int SSL_get_verify_mode(SSL*);
|
||||
int SSL_CTX_get_verify_depth(SSL_CTX*);
|
||||
int SSL_get_verify_depth(SSL*);
|
||||
|
||||
long SSL_get_default_timeout(SSL*);
|
||||
long SSL_CTX_get_session_cache_mode(SSL_CTX*);
|
||||
int SSL_session_reused(SSL*);
|
||||
|
||||
int SSL_set_rfd(SSL*, int);
|
||||
int SSL_set_wfd(SSL*, int);
|
||||
void SSL_set_shutdown(SSL*, int);
|
||||
void SSL_set_quiet_shutdown(SSL *ssl,int mode);
|
||||
int SSL_get_quiet_shutdown(SSL *ssl);
|
||||
|
||||
int SSL_want_read(SSL*);
|
||||
int SSL_want_write(SSL*);
|
||||
|
||||
int SSL_pending(SSL*);
|
||||
|
||||
|
||||
enum { /* ssl Constants */
|
||||
SSL_WOULD_BLOCK = -8,
|
||||
SSL_BAD_STAT = -7,
|
||||
SSL_BAD_PATH = -6,
|
||||
SSL_BAD_FILETYPE = -5,
|
||||
SSL_BAD_FILE = -4,
|
||||
SSL_NOT_IMPLEMENTED = -3,
|
||||
SSL_UNKNOWN = -2,
|
||||
SSL_FATAL_ERROR = -1,
|
||||
SSL_NORMAL_SHUTDOWN = 0,
|
||||
SSL_ERROR_NONE = 0, /* for most functions */
|
||||
SSL_FAILURE = 0, /* for some functions */
|
||||
SSL_SUCCESS = 1,
|
||||
|
||||
SSL_FILETYPE_ASN1 = 10,
|
||||
SSL_FILETYPE_PEM = 11,
|
||||
SSL_FILETYPE_DEFAULT = 10, /* ASN1 */
|
||||
|
||||
SSL_VERIFY_NONE = 0,
|
||||
SSL_VERIFY_PEER = 1,
|
||||
SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2,
|
||||
SSL_VERIFY_CLIENT_ONCE = 4,
|
||||
|
||||
SSL_SESS_CACHE_OFF = 30,
|
||||
SSL_SESS_CACHE_CLIENT = 31,
|
||||
SSL_SESS_CACHE_SERVER = 32,
|
||||
SSL_SESS_CACHE_BOTH = 33,
|
||||
SSL_SESS_CACHE_NO_AUTO_CLEAR = 34,
|
||||
SSL_SESS_CACHE_NO_INTERNAL_LOOKUP = 35,
|
||||
|
||||
SSL_OP_MICROSOFT_SESS_ID_BUG = 50,
|
||||
SSL_OP_NETSCAPE_CHALLENGE_BUG = 51,
|
||||
SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = 52,
|
||||
SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG = 53,
|
||||
SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = 54,
|
||||
SSL_OP_MSIE_SSLV2_RSA_PADDING = 55,
|
||||
SSL_OP_SSLEAY_080_CLIENT_DH_BUG = 56,
|
||||
SSL_OP_TLS_D5_BUG = 57,
|
||||
SSL_OP_TLS_BLOCK_PADDING_BUG = 58,
|
||||
SSL_OP_TLS_ROLLBACK_BUG = 59,
|
||||
SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = 60,
|
||||
SSL_OP_ALL = 61,
|
||||
SSL_OP_SINGLE_DH_USE = 62,
|
||||
SSL_OP_EPHEMERAL_RSA = 63,
|
||||
SSL_OP_NO_SSLv2 = 64,
|
||||
SSL_OP_NO_SSLv3 = 65,
|
||||
SSL_OP_NO_TLSv1 = 66,
|
||||
SSL_OP_PKCS1_CHECK_1 = 67,
|
||||
SSL_OP_PKCS1_CHECK_2 = 68,
|
||||
SSL_OP_NETSCAPE_CA_DN_BUG = 69,
|
||||
SSL_OP_NON_EXPORT_FIRST = 70,
|
||||
SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 71,
|
||||
|
||||
SSL_ERROR_WANT_READ = 80,
|
||||
SSL_ERROR_WANT_WRITE = 81,
|
||||
SSL_ERROR_SYSCALL = 82,
|
||||
SSL_ERROR_WANT_X509_LOOKUP = 83,
|
||||
SSL_ERROR_ZERO_RETURN = 84,
|
||||
SSL_ERROR_SSL = 85,
|
||||
|
||||
SSL_SENT_SHUTDOWN = 90,
|
||||
SSL_RECEIVED_SHUTDOWN = 91,
|
||||
SSL_CB_LOOP = 92,
|
||||
SSL_ST_CONNECT = 93,
|
||||
SSL_ST_ACCEPT = 94,
|
||||
SSL_CB_ALERT = 95,
|
||||
SSL_CB_READ = 96,
|
||||
SSL_CB_HANDSHAKE_DONE = 97
|
||||
|
||||
};
|
||||
|
||||
|
||||
SSL_METHOD *SSLv3_method(void);
|
||||
SSL_METHOD *SSLv3_server_method(void);
|
||||
SSL_METHOD *SSLv3_client_method(void);
|
||||
SSL_METHOD *TLSv1_server_method(void);
|
||||
SSL_METHOD *TLSv1_client_method(void);
|
||||
SSL_METHOD *TLSv1_1_server_method(void);
|
||||
SSL_METHOD *TLSv1_1_client_method(void);
|
||||
SSL_METHOD *SSLv23_server_method(void);
|
||||
|
||||
int SSL_CTX_use_certificate_file(SSL_CTX*, const char*, int);
|
||||
int SSL_CTX_use_PrivateKey_file(SSL_CTX*, const char*, int);
|
||||
int SSL_CTX_set_cipher_list(SSL_CTX*, const char*);
|
||||
|
||||
long SSL_CTX_sess_set_cache_size(SSL_CTX*, long);
|
||||
long SSL_CTX_set_tmp_dh(SSL_CTX*, DH*);
|
||||
|
||||
void OpenSSL_add_all_algorithms(void);
|
||||
int SSL_library_init();
|
||||
int SSLeay_add_ssl_algorithms(void);
|
||||
|
||||
|
||||
SSL_CIPHER* SSL_get_current_cipher(SSL*);
|
||||
char* SSL_CIPHER_description(SSL_CIPHER*, char*, int);
|
||||
|
||||
|
||||
char* SSL_alert_type_string_long(int);
|
||||
char* SSL_alert_desc_string_long(int);
|
||||
char* SSL_state_string_long(SSL*);
|
||||
|
||||
|
||||
/* EVP stuff, des and md5, different file? */
|
||||
typedef char EVP_MD;
|
||||
|
||||
typedef char EVP_CIPHER;
|
||||
|
||||
typedef struct EVP_PKEY EVP_PKEY;
|
||||
|
||||
typedef unsigned char DES_cblock[8];
|
||||
typedef const DES_cblock const_DES_cblock;
|
||||
typedef DES_cblock DES_key_schedule;
|
||||
|
||||
enum {
|
||||
DES_ENCRYPT = 1,
|
||||
DES_DECRYPT = 0
|
||||
};
|
||||
|
||||
const EVP_MD* EVP_md5(void);
|
||||
const EVP_CIPHER* EVP_des_ede3_cbc(void);
|
||||
|
||||
typedef unsigned char opaque;
|
||||
|
||||
int EVP_BytesToKey(const EVP_CIPHER*, const EVP_MD*, const opaque*,
|
||||
const opaque*, int, int, opaque*, opaque*);
|
||||
|
||||
void DES_set_key_unchecked(const_DES_cblock*, DES_key_schedule*);
|
||||
void DES_ede3_cbc_encrypt(const opaque*, opaque*, long, DES_key_schedule*,
|
||||
DES_key_schedule*, DES_key_schedule*, DES_cblock*, int);
|
||||
|
||||
|
||||
/* RAND stuff */
|
||||
void RAND_screen(void);
|
||||
const char* RAND_file_name(char*, size_t);
|
||||
int RAND_write_file(const char*);
|
||||
int RAND_load_file(const char*, long);
|
||||
|
||||
|
||||
/* for libcurl */
|
||||
int RAND_status(void);
|
||||
int RAND_bytes(unsigned char* buf, int num);
|
||||
|
||||
int DES_set_key(const_DES_cblock*, DES_key_schedule*);
|
||||
void DES_set_odd_parity(DES_cblock*);
|
||||
void DES_ecb_encrypt(DES_cblock*, DES_cblock*, DES_key_schedule*, int);
|
||||
|
||||
void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*, void* userdata);
|
||||
void SSL_SESSION_free(SSL_SESSION* session);
|
||||
int SSL_peek(SSL* ssl, void* buf, int num);
|
||||
|
||||
X509* SSL_get_certificate(SSL* ssl);
|
||||
EVP_PKEY* SSL_get_privatekey(SSL* ssl);
|
||||
EVP_PKEY* X509_get_pubkey(X509* x);
|
||||
|
||||
int EVP_PKEY_copy_parameters(EVP_PKEY* to, const EVP_PKEY* from);
|
||||
void EVP_PKEY_free(EVP_PKEY* pkey);
|
||||
void ERR_error_string_n(unsigned long e, char *buf, size_t len);
|
||||
void ERR_free_strings(void);
|
||||
void EVP_cleanup(void);
|
||||
|
||||
void* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx);
|
||||
|
||||
#define GEN_IPADD 7
|
||||
#define NID_subject_alt_name 85
|
||||
#define STACK_OF(x) x
|
||||
|
||||
|
||||
/* defined here because libcurl dereferences */
|
||||
typedef struct ASN1_STRING {
|
||||
int type;
|
||||
int length;
|
||||
unsigned char* data;
|
||||
} ASN1_STRING;
|
||||
|
||||
|
||||
typedef struct GENERAL_NAME {
|
||||
int type;
|
||||
union {
|
||||
ASN1_STRING* ia5;
|
||||
} d;
|
||||
} GENERAL_NAME;
|
||||
|
||||
void GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *x);
|
||||
|
||||
int sk_GENERAL_NAME_num(STACK_OF(GENERAL_NAME) *x);
|
||||
GENERAL_NAME* sk_GENERAL_NAME_value(STACK_OF(GENERAL_NAME) *x, int i);
|
||||
|
||||
|
||||
unsigned char* ASN1_STRING_data(ASN1_STRING* x);
|
||||
int ASN1_STRING_length(ASN1_STRING* x);
|
||||
int ASN1_STRING_type(ASN1_STRING *x);
|
||||
|
||||
typedef ASN1_STRING X509_NAME_ENTRY;
|
||||
|
||||
int X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos);
|
||||
|
||||
ASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne);
|
||||
X509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME* name, int loc);
|
||||
|
||||
#define OPENSSL_malloc(x) malloc(x)
|
||||
#define OPENSSL_free(x) free(x)
|
||||
|
||||
int ASN1_STRING_to_UTF8(unsigned char** out, ASN1_STRING* in);
|
||||
|
||||
SSL_METHOD* SSLv23_client_method(void); /* doesn't actually roll back */
|
||||
SSL_METHOD* SSLv2_client_method(void); /* will never work, no v 2 */
|
||||
|
||||
|
||||
SSL_SESSION* SSL_get1_session(SSL* ssl); /* what's ref count */
|
||||
|
||||
|
||||
#define CRYPTO_free(x) free(x)
|
||||
#define ASN1_TIME ASN1_STRING
|
||||
|
||||
ASN1_TIME* X509_get_notBefore(X509* x);
|
||||
ASN1_TIME* X509_get_notAfter(X509* x);
|
||||
|
||||
|
||||
#define ASN1_UTCTIME ASN1_STRING
|
||||
#define NID_commonName 13
|
||||
#define V_ASN1_UTF8STRING 12
|
||||
#define GEN_DNS 2
|
||||
|
||||
#define CERTFICATE_ERROR 0x14090086 /* SSLv3 error */
|
||||
|
||||
|
||||
typedef struct MD4_CTX {
|
||||
int buffer[32]; /* big enough to hold, check size in Init */
|
||||
} MD4_CTX;
|
||||
|
||||
void MD4_Init(MD4_CTX*);
|
||||
void MD4_Update(MD4_CTX*, const void*, unsigned long);
|
||||
void MD4_Final(unsigned char*, MD4_CTX*);
|
||||
|
||||
|
||||
typedef struct MD5_CTX {
|
||||
int buffer[32]; /* big enough to hold, check size in Init */
|
||||
} MD5_CTX;
|
||||
|
||||
void MD5_Init(MD5_CTX*);
|
||||
void MD5_Update(MD5_CTX*, const void*, unsigned long);
|
||||
void MD5_Final(unsigned char*, MD5_CTX*);
|
||||
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
|
||||
|
||||
#define SSL_DEFAULT_CIPHER_LIST "" /* default all */
|
||||
|
||||
|
||||
/* yaSSL adds */
|
||||
int SSL_set_compression(SSL*); /* turn on yaSSL zlib compression */
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)
|
||||
} /* namespace */
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* yaSSL_openssl_h__ */
|
||||
@@ -1 +0,0 @@
|
||||
/* x509.h for libcurl */
|
||||
@@ -1 +0,0 @@
|
||||
/* x509v3.h for libcurl */
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* The socket wrapper header defines a Socket class that hides the differences
|
||||
* between Berkely style sockets and Windows sockets, allowing transparent TCP
|
||||
* access.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef yaSSL_SOCKET_WRAPPER_HPP
|
||||
#define yaSSL_SOCKET_WRAPPER_HPP
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef SOCKET socket_t;
|
||||
#else
|
||||
typedef int socket_t;
|
||||
const socket_t INVALID_SOCKET = -1;
|
||||
const int SD_RECEIVE = 0;
|
||||
const int SD_SEND = 1;
|
||||
const int SD_BOTH = 2;
|
||||
const int SOCKET_ERROR = -1;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
|
||||
// Wraps Windows Sockets and BSD Sockets
|
||||
class Socket {
|
||||
socket_t socket_; // underlying socket descriptor
|
||||
bool wouldBlock_; // if non-blocking data, for last read
|
||||
bool nonBlocking_; // is option set
|
||||
public:
|
||||
explicit Socket(socket_t s = INVALID_SOCKET);
|
||||
~Socket();
|
||||
|
||||
void set_fd(socket_t s);
|
||||
uint get_ready() const;
|
||||
socket_t get_fd() const;
|
||||
|
||||
uint send(const byte* buf, unsigned int len, int flags = 0) const;
|
||||
uint receive(byte* buf, unsigned int len, int flags = 0);
|
||||
|
||||
bool wait();
|
||||
bool WouldBlock() const;
|
||||
bool IsNonBlocking() const;
|
||||
|
||||
void closeSocket();
|
||||
void shutDown(int how = SD_SEND);
|
||||
|
||||
static int get_lastError();
|
||||
static void set_lastError(int error);
|
||||
private:
|
||||
Socket(const Socket&); // hide copy
|
||||
Socket& operator= (const Socket&); // and assign
|
||||
};
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_SOCKET_WRAPPER_HPP
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* timer.hpp provides a high res and low res timers
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef yaSSL_TIMER_HPP
|
||||
#define yaSSL_TIMER_HPP
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
typedef double timer_d;
|
||||
typedef unsigned int uint;
|
||||
|
||||
|
||||
|
||||
timer_d timer();
|
||||
uint lowResTimer();
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
#endif // yaSSL_TIMER_HPP
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 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
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* yaSSL error header defines error codes and an exception class
|
||||
*/
|
||||
|
||||
#ifndef yaSSL_ERROR_HPP
|
||||
#define yaSSL_ERROR_HPP
|
||||
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
enum YasslError {
|
||||
no_error = 0,
|
||||
|
||||
// 10 - 47 from AlertDescription, 0 also close_notify
|
||||
|
||||
range_error = 101,
|
||||
realloc_error = 102,
|
||||
factory_error = 103,
|
||||
unknown_cipher = 104,
|
||||
prefix_error = 105,
|
||||
record_layer = 106,
|
||||
handshake_layer = 107,
|
||||
out_of_order = 108,
|
||||
bad_input = 109,
|
||||
match_error = 110,
|
||||
no_key_file = 111,
|
||||
verify_error = 112,
|
||||
send_error = 113,
|
||||
receive_error = 114,
|
||||
certificate_error = 115,
|
||||
privateKey_error = 116,
|
||||
badVersion_error = 117,
|
||||
compress_error = 118,
|
||||
decompress_error = 119,
|
||||
pms_version_error = 120
|
||||
|
||||
// !!!! add error message to .cpp !!!!
|
||||
|
||||
// 1000+ from TaoCrypt error.hpp
|
||||
|
||||
};
|
||||
|
||||
|
||||
enum Library { yaSSL_Lib = 0, CryptoLib, SocketLib };
|
||||
enum { MAX_ERROR_SZ = 80 };
|
||||
|
||||
void SetErrorString(unsigned long, char*);
|
||||
|
||||
/* remove for now, if go back to exceptions use this wrapper
|
||||
// Base class for all yaSSL exceptions
|
||||
class Error : public mySTL::runtime_error {
|
||||
YasslError error_;
|
||||
Library lib_;
|
||||
public:
|
||||
explicit Error(const char* s = "", YasslError e = no_error,
|
||||
Library l = yaSSL_Lib);
|
||||
|
||||
YasslError get_number() const;
|
||||
Library get_lib() const;
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_ERROR_HPP
|
||||
@@ -1,748 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* yaSSL implementation header defines all strucutres from the SSL.v3
|
||||
* specification "draft-freier-ssl-version3-02.txt"
|
||||
* all page citations refer to this document unless otherwise noted.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef yaSSL_IMP_HPP
|
||||
#define yaSSL_IMP_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// disable truncated debug symbols
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include "yassl_types.hpp"
|
||||
#include "factory.hpp"
|
||||
#include STL_LIST_FILE
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
class SSL; // forward decls
|
||||
class input_buffer;
|
||||
class output_buffer;
|
||||
|
||||
|
||||
struct ProtocolVersion {
|
||||
uint8 major_;
|
||||
uint8 minor_; // major and minor SSL/TLS version numbers
|
||||
|
||||
ProtocolVersion(uint8 maj = 3, uint8 min = 0);
|
||||
};
|
||||
|
||||
|
||||
// Record Layer Header for PlainText, Compressed, and CipherText
|
||||
struct RecordLayerHeader {
|
||||
ContentType type_;
|
||||
ProtocolVersion version_;
|
||||
uint16 length_; // should not exceed 2^14
|
||||
};
|
||||
|
||||
|
||||
// base for all messages
|
||||
struct Message : public virtual_base {
|
||||
virtual input_buffer& set(input_buffer&) =0;
|
||||
virtual output_buffer& get(output_buffer&) const =0;
|
||||
|
||||
virtual void Process(input_buffer&, SSL&) =0;
|
||||
virtual ContentType get_type() const =0;
|
||||
virtual uint16 get_length() const =0;
|
||||
|
||||
virtual ~Message() {}
|
||||
};
|
||||
|
||||
|
||||
class ChangeCipherSpec : public Message {
|
||||
CipherChoice type_;
|
||||
public:
|
||||
ChangeCipherSpec();
|
||||
|
||||
friend input_buffer& operator>>(input_buffer&, ChangeCipherSpec&);
|
||||
friend output_buffer& operator<<(output_buffer&, const ChangeCipherSpec&);
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
ContentType get_type() const;
|
||||
uint16 get_length() const;
|
||||
void Process(input_buffer&, SSL&);
|
||||
private:
|
||||
ChangeCipherSpec(const ChangeCipherSpec&); // hide copy
|
||||
ChangeCipherSpec& operator=(const ChangeCipherSpec&); // and assign
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Alert : public Message {
|
||||
AlertLevel level_;
|
||||
AlertDescription description_;
|
||||
public:
|
||||
Alert() {}
|
||||
Alert(AlertLevel al, AlertDescription ad);
|
||||
|
||||
ContentType get_type() const;
|
||||
uint16 get_length() const;
|
||||
void Process(input_buffer&, SSL&);
|
||||
|
||||
friend input_buffer& operator>>(input_buffer&, Alert&);
|
||||
friend output_buffer& operator<<(output_buffer&, const Alert&);
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
private:
|
||||
Alert(const Alert&); // hide copy
|
||||
Alert& operator=(const Alert&); // and assign
|
||||
};
|
||||
|
||||
|
||||
class Data : public Message {
|
||||
uint16 length_;
|
||||
opaque* buffer_; // read buffer used by fillData input
|
||||
const opaque* write_buffer_; // write buffer used by output operator
|
||||
public:
|
||||
Data();
|
||||
Data(uint16 len, opaque* b);
|
||||
|
||||
friend output_buffer& operator<<(output_buffer&, const Data&);
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
ContentType get_type() const;
|
||||
uint16 get_length() const;
|
||||
void set_length(uint16 l);
|
||||
opaque* set_buffer();
|
||||
void SetData(uint16, const opaque*);
|
||||
void Process(input_buffer&, SSL&);
|
||||
private:
|
||||
Data(const Data&); // hide copy
|
||||
Data& operator=(const Data&); // and assign
|
||||
};
|
||||
|
||||
|
||||
uint32 c24to32(const uint24); // forward form internal header
|
||||
void c32to24(uint32, uint24&);
|
||||
|
||||
|
||||
// HandShake header, same for each message type from page 20/21
|
||||
class HandShakeHeader : public Message {
|
||||
HandShakeType type_;
|
||||
uint24 length_; // length of message
|
||||
public:
|
||||
HandShakeHeader() {}
|
||||
|
||||
ContentType get_type() const;
|
||||
uint16 get_length() const;
|
||||
HandShakeType get_handshakeType() const;
|
||||
void Process(input_buffer&, SSL&);
|
||||
|
||||
void set_type(HandShakeType hst);
|
||||
void set_length(uint32 u32);
|
||||
|
||||
friend input_buffer& operator>>(input_buffer&, HandShakeHeader&);
|
||||
friend output_buffer& operator<<(output_buffer&, const HandShakeHeader&);
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
private:
|
||||
HandShakeHeader(const HandShakeHeader&); // hide copy
|
||||
HandShakeHeader& operator=(const HandShakeHeader&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// Base Class for all handshake messages
|
||||
class HandShakeBase : public virtual_base {
|
||||
int length_;
|
||||
public:
|
||||
int get_length() const;
|
||||
void set_length(int);
|
||||
|
||||
// for building buffer's type field
|
||||
virtual HandShakeType get_type() const =0;
|
||||
|
||||
// handles dispactch of proper >>
|
||||
virtual input_buffer& set(input_buffer& in) =0;
|
||||
virtual output_buffer& get(output_buffer& out) const =0;
|
||||
|
||||
virtual void Process(input_buffer&, SSL&) =0;
|
||||
|
||||
virtual ~HandShakeBase() {}
|
||||
};
|
||||
|
||||
|
||||
struct HelloRequest : public HandShakeBase {
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
void Process(input_buffer&, SSL&);
|
||||
|
||||
HandShakeType get_type() const;
|
||||
};
|
||||
|
||||
|
||||
// The Client's Hello Message from page 23
|
||||
class ClientHello : public HandShakeBase {
|
||||
ProtocolVersion client_version_;
|
||||
Random random_;
|
||||
uint8 id_len_; // session id length
|
||||
opaque session_id_[ID_LEN];
|
||||
uint16 suite_len_; // cipher suite length
|
||||
opaque cipher_suites_[MAX_SUITE_SZ];
|
||||
uint8 comp_len_; // compression length
|
||||
CompressionMethod compression_methods_;
|
||||
public:
|
||||
friend input_buffer& operator>>(input_buffer&, ClientHello&);
|
||||
friend output_buffer& operator<<(output_buffer&, const ClientHello&);
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
HandShakeType get_type() const;
|
||||
void Process(input_buffer&, SSL&);
|
||||
|
||||
const opaque* get_random() const;
|
||||
friend void buildClientHello(SSL&, ClientHello&);
|
||||
friend void ProcessOldClientHello(input_buffer& input, SSL& ssl);
|
||||
|
||||
ClientHello();
|
||||
ClientHello(ProtocolVersion pv, bool useCompression);
|
||||
private:
|
||||
ClientHello(const ClientHello&); // hide copy
|
||||
ClientHello& operator=(const ClientHello&); // and assign
|
||||
};
|
||||
|
||||
|
||||
|
||||
// The Server's Hello Message from page 24
|
||||
class ServerHello : public HandShakeBase {
|
||||
ProtocolVersion server_version_;
|
||||
Random random_;
|
||||
uint8 id_len_; // session id length
|
||||
opaque session_id_[ID_LEN];
|
||||
opaque cipher_suite_[SUITE_LEN];
|
||||
CompressionMethod compression_method_;
|
||||
public:
|
||||
ServerHello(ProtocolVersion pv, bool useCompression);
|
||||
ServerHello();
|
||||
|
||||
friend input_buffer& operator>>(input_buffer&, ServerHello&);
|
||||
friend output_buffer& operator<<(output_buffer&, const ServerHello&);
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
HandShakeType get_type() const;
|
||||
void Process(input_buffer&, SSL&);
|
||||
|
||||
const opaque* get_random() const;
|
||||
friend void buildServerHello(SSL&, ServerHello&);
|
||||
private:
|
||||
ServerHello(const ServerHello&); // hide copy
|
||||
ServerHello& operator=(const ServerHello&); // and assign
|
||||
};
|
||||
|
||||
|
||||
class x509;
|
||||
|
||||
// Certificate could be a chain
|
||||
class Certificate : public HandShakeBase {
|
||||
const x509* cert_;
|
||||
public:
|
||||
Certificate();
|
||||
explicit Certificate(const x509* cert);
|
||||
friend output_buffer& operator<<(output_buffer&, const Certificate&);
|
||||
|
||||
const opaque* get_buffer() const;
|
||||
|
||||
// Process handles input, needs SSL
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
HandShakeType get_type() const;
|
||||
void Process(input_buffer&, SSL&);
|
||||
private:
|
||||
Certificate(const Certificate&); // hide copy
|
||||
Certificate& operator=(const Certificate&); // and assign
|
||||
};
|
||||
|
||||
|
||||
|
||||
// RSA Public Key
|
||||
struct ServerRSAParams {
|
||||
opaque* rsa_modulus_;
|
||||
opaque* rsa_exponent_;
|
||||
};
|
||||
|
||||
|
||||
// Ephemeral Diffie-Hellman Parameters
|
||||
class ServerDHParams {
|
||||
int pSz_;
|
||||
int gSz_;
|
||||
int pubSz_;
|
||||
opaque* p_;
|
||||
opaque* g_;
|
||||
opaque* Ys_;
|
||||
public:
|
||||
ServerDHParams();
|
||||
~ServerDHParams();
|
||||
|
||||
int get_pSize() const;
|
||||
int get_gSize() const;
|
||||
int get_pubSize() const;
|
||||
|
||||
const opaque* get_p() const;
|
||||
const opaque* get_g() const;
|
||||
const opaque* get_pub() const;
|
||||
|
||||
opaque* alloc_p(int sz);
|
||||
opaque* alloc_g(int sz);
|
||||
opaque* alloc_pub(int sz);
|
||||
private:
|
||||
ServerDHParams(const ServerDHParams&); // hide copy
|
||||
ServerDHParams& operator=(const ServerDHParams&); // and assign
|
||||
};
|
||||
|
||||
|
||||
struct ServerKeyBase : public virtual_base {
|
||||
virtual ~ServerKeyBase() {}
|
||||
virtual void build(SSL&) {}
|
||||
virtual void read(SSL&, input_buffer&) {}
|
||||
virtual int get_length() const;
|
||||
virtual opaque* get_serverKey() const;
|
||||
};
|
||||
|
||||
|
||||
// Server random number for FORTEZZA KEA
|
||||
struct Fortezza_Server : public ServerKeyBase {
|
||||
opaque r_s_[FORTEZZA_MAX];
|
||||
};
|
||||
|
||||
|
||||
struct SignatureBase : public virtual_base {
|
||||
virtual ~SignatureBase() {}
|
||||
};
|
||||
|
||||
struct anonymous_sa : public SignatureBase {};
|
||||
|
||||
|
||||
struct Hashes {
|
||||
uint8 md5_[MD5_LEN];
|
||||
uint8 sha_[SHA_LEN];
|
||||
};
|
||||
|
||||
|
||||
struct rsa_sa : public SignatureBase {
|
||||
Hashes hashes_;
|
||||
};
|
||||
|
||||
|
||||
struct dsa_sa : public SignatureBase {
|
||||
uint8 sha_[SHA_LEN];
|
||||
};
|
||||
|
||||
|
||||
// Server's Diffie-Hellman exchange
|
||||
class DH_Server : public ServerKeyBase {
|
||||
ServerDHParams parms_;
|
||||
opaque* signature_;
|
||||
|
||||
int length_; // total length of message
|
||||
opaque* keyMessage_; // total exchange message
|
||||
public:
|
||||
DH_Server();
|
||||
~DH_Server();
|
||||
|
||||
void build(SSL&);
|
||||
void read(SSL&, input_buffer&);
|
||||
int get_length() const;
|
||||
opaque* get_serverKey() const;
|
||||
private:
|
||||
DH_Server(const DH_Server&); // hide copy
|
||||
DH_Server& operator=(const DH_Server&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// Server's RSA exchange
|
||||
struct RSA_Server : public ServerKeyBase {
|
||||
ServerRSAParams params_;
|
||||
opaque* signature_; // signed rsa_sa hashes
|
||||
};
|
||||
|
||||
|
||||
class ServerKeyExchange : public HandShakeBase {
|
||||
ServerKeyBase* server_key_;
|
||||
public:
|
||||
explicit ServerKeyExchange(SSL&);
|
||||
ServerKeyExchange();
|
||||
~ServerKeyExchange();
|
||||
|
||||
void createKey(SSL&);
|
||||
void build(SSL& ssl);
|
||||
|
||||
const opaque* getKey() const;
|
||||
int getKeyLength() const;
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
friend output_buffer& operator<<(output_buffer&, const ServerKeyExchange&);
|
||||
|
||||
void Process(input_buffer&, SSL&);
|
||||
HandShakeType get_type() const;
|
||||
private:
|
||||
ServerKeyExchange(const ServerKeyExchange&); // hide copy
|
||||
ServerKeyExchange& operator=(const ServerKeyExchange&); // and assign
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CertificateRequest : public HandShakeBase {
|
||||
ClientCertificateType certificate_types_[CERT_TYPES];
|
||||
int typeTotal_;
|
||||
STL::list<DistinguishedName> certificate_authorities_;
|
||||
public:
|
||||
CertificateRequest();
|
||||
~CertificateRequest();
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
friend input_buffer& operator>>(input_buffer&, CertificateRequest&);
|
||||
friend output_buffer& operator<<(output_buffer&,
|
||||
const CertificateRequest&);
|
||||
|
||||
void Process(input_buffer&, SSL&);
|
||||
HandShakeType get_type() const;
|
||||
|
||||
void Build();
|
||||
private:
|
||||
CertificateRequest(const CertificateRequest&); // hide copy
|
||||
CertificateRequest& operator=(const CertificateRequest&); // and assign
|
||||
};
|
||||
|
||||
|
||||
struct ServerHelloDone : public HandShakeBase {
|
||||
ServerHelloDone();
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
void Process(input_buffer& input, SSL& ssl);
|
||||
|
||||
HandShakeType get_type() const;
|
||||
};
|
||||
|
||||
|
||||
struct PreMasterSecret {
|
||||
opaque random_[SECRET_LEN]; // first two bytes Protocol Version
|
||||
};
|
||||
|
||||
|
||||
struct ClientKeyBase : public virtual_base {
|
||||
virtual ~ClientKeyBase() {}
|
||||
virtual void build(SSL&) {}
|
||||
virtual void read(SSL&, input_buffer&) {}
|
||||
virtual int get_length() const;
|
||||
virtual opaque* get_clientKey() const;
|
||||
};
|
||||
|
||||
|
||||
class EncryptedPreMasterSecret : public ClientKeyBase {
|
||||
opaque* secret_;
|
||||
int length_;
|
||||
public:
|
||||
EncryptedPreMasterSecret();
|
||||
~EncryptedPreMasterSecret();
|
||||
|
||||
void build(SSL&);
|
||||
void read(SSL&, input_buffer&);
|
||||
int get_length() const;
|
||||
opaque* get_clientKey() const;
|
||||
void alloc(int sz);
|
||||
private:
|
||||
// hide copy and assign
|
||||
EncryptedPreMasterSecret(const EncryptedPreMasterSecret&);
|
||||
EncryptedPreMasterSecret& operator=(const EncryptedPreMasterSecret&);
|
||||
};
|
||||
|
||||
|
||||
// Fortezza Key Parameters from page 29
|
||||
// hard code lengths cause only used here
|
||||
struct FortezzaKeys : public ClientKeyBase {
|
||||
opaque y_c_ [128]; // client's Yc, public value
|
||||
opaque r_c_ [128]; // client's Rc
|
||||
opaque y_signature_ [40]; // DSS signed public key
|
||||
opaque wrapped_client_write_key_ [12]; // wrapped by the TEK
|
||||
opaque wrapped_server_write_key_ [12]; // wrapped by the TEK
|
||||
opaque client_write_iv_ [24];
|
||||
opaque server_write_iv_ [24];
|
||||
opaque master_secret_iv_ [24]; // IV used to encrypt preMaster
|
||||
opaque encrypted_preMasterSecret_[48]; // random & crypted by the TEK
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Diffie-Hellman public key from page 40/41
|
||||
class ClientDiffieHellmanPublic : public ClientKeyBase {
|
||||
PublicValueEncoding public_value_encoding_;
|
||||
int length_; // includes two byte length for message
|
||||
opaque* Yc_; // length + Yc_
|
||||
// dh_Yc only if explicit, otherwise sent in certificate
|
||||
enum { KEY_OFFSET = 2 };
|
||||
public:
|
||||
ClientDiffieHellmanPublic();
|
||||
~ClientDiffieHellmanPublic();
|
||||
|
||||
void build(SSL&);
|
||||
void read(SSL&, input_buffer&);
|
||||
int get_length() const;
|
||||
opaque* get_clientKey() const;
|
||||
void alloc(int sz, bool offset = false);
|
||||
private:
|
||||
// hide copy and assign
|
||||
ClientDiffieHellmanPublic(const ClientDiffieHellmanPublic&);
|
||||
ClientDiffieHellmanPublic& operator=(const ClientDiffieHellmanPublic&);
|
||||
};
|
||||
|
||||
|
||||
class ClientKeyExchange : public HandShakeBase {
|
||||
ClientKeyBase* client_key_;
|
||||
public:
|
||||
explicit ClientKeyExchange(SSL& ssl);
|
||||
ClientKeyExchange();
|
||||
~ClientKeyExchange();
|
||||
|
||||
void createKey(SSL&);
|
||||
void build(SSL& ssl);
|
||||
|
||||
const opaque* getKey() const;
|
||||
int getKeyLength() const;
|
||||
|
||||
friend output_buffer& operator<<(output_buffer&, const ClientKeyExchange&);
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
HandShakeType get_type() const;
|
||||
void Process(input_buffer&, SSL&);
|
||||
private:
|
||||
ClientKeyExchange(const ClientKeyExchange&); // hide copy
|
||||
ClientKeyExchange& operator=(const ClientKeyExchange&); // and assign
|
||||
};
|
||||
|
||||
|
||||
class CertificateVerify : public HandShakeBase {
|
||||
Hashes hashes_;
|
||||
byte* signature_; // owns
|
||||
public:
|
||||
CertificateVerify();
|
||||
~CertificateVerify();
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
friend input_buffer& operator>>(input_buffer&, CertificateVerify&);
|
||||
friend output_buffer& operator<<(output_buffer&, const CertificateVerify&);
|
||||
|
||||
void Process(input_buffer&, SSL&);
|
||||
HandShakeType get_type() const;
|
||||
|
||||
void Build(SSL&);
|
||||
private:
|
||||
CertificateVerify(const CertificateVerify&); // hide copy
|
||||
CertificateVerify& operator=(const CertificateVerify&); // and assign
|
||||
};
|
||||
|
||||
|
||||
class Finished : public HandShakeBase {
|
||||
Hashes hashes_;
|
||||
public:
|
||||
Finished();
|
||||
|
||||
uint8* set_md5();
|
||||
uint8* set_sha();
|
||||
|
||||
friend input_buffer& operator>>(input_buffer&, Finished&);
|
||||
friend output_buffer& operator<<(output_buffer&, const Finished&);
|
||||
|
||||
input_buffer& set(input_buffer& in);
|
||||
output_buffer& get(output_buffer& out) const;
|
||||
|
||||
void Process(input_buffer&, SSL&);
|
||||
|
||||
HandShakeType get_type() const;
|
||||
private:
|
||||
Finished(const Finished&); // hide copy
|
||||
Finished& operator=(const Finished&); // and assign
|
||||
};
|
||||
|
||||
|
||||
class RandomPool; // forward for connection
|
||||
|
||||
|
||||
// SSL Connection defined on page 11
|
||||
struct Connection {
|
||||
opaque *pre_master_secret_;
|
||||
opaque master_secret_[SECRET_LEN];
|
||||
opaque client_random_[RAN_LEN];
|
||||
opaque server_random_[RAN_LEN];
|
||||
opaque sessionID_[ID_LEN];
|
||||
opaque client_write_MAC_secret_[SHA_LEN]; // sha is max size
|
||||
opaque server_write_MAC_secret_[SHA_LEN];
|
||||
opaque client_write_key_[AES_256_KEY_SZ]; // aes 256bit is max sz
|
||||
opaque server_write_key_[AES_256_KEY_SZ];
|
||||
opaque client_write_IV_[AES_IV_SZ]; // aes is max size
|
||||
opaque server_write_IV_[AES_IV_SZ];
|
||||
uint32 sequence_number_;
|
||||
uint32 peer_sequence_number_;
|
||||
uint32 pre_secret_len_; // pre master length
|
||||
bool send_server_key_; // server key exchange?
|
||||
bool master_clean_; // master secret clean?
|
||||
bool TLS_; // TLSv1 or greater
|
||||
bool TLSv1_1_; // TLSv1.1 or greater
|
||||
bool sessionID_Set_; // do we have a session
|
||||
bool compression_; // zlib compression?
|
||||
ProtocolVersion version_; // negotiated version
|
||||
ProtocolVersion chVersion_; // client hello version
|
||||
RandomPool& random_;
|
||||
|
||||
Connection(ProtocolVersion v, RandomPool& ran);
|
||||
~Connection();
|
||||
|
||||
void AllocPreSecret(uint sz);
|
||||
void CleanPreMaster();
|
||||
void CleanMaster();
|
||||
void TurnOffTLS();
|
||||
void TurnOffTLS1_1();
|
||||
private:
|
||||
Connection(const Connection&); // hide copy
|
||||
Connection& operator=(const Connection&); // and assign
|
||||
};
|
||||
|
||||
|
||||
struct Ciphers; // forward
|
||||
|
||||
|
||||
// TLSv1 Security Spec, defined on page 56 of RFC 2246
|
||||
struct Parameters {
|
||||
ConnectionEnd entity_;
|
||||
BulkCipherAlgorithm bulk_cipher_algorithm_;
|
||||
CipherType cipher_type_;
|
||||
uint8 key_size_;
|
||||
uint8 iv_size_;
|
||||
IsExportable is_exportable_;
|
||||
MACAlgorithm mac_algorithm_;
|
||||
uint8 hash_size_;
|
||||
CompressionMethod compression_algorithm_;
|
||||
KeyExchangeAlgorithm kea_; // yassl additions
|
||||
SignatureAlgorithm sig_algo_; // signature auth type
|
||||
SignatureAlgorithm verify_algo_; // cert verify auth type
|
||||
bool pending_;
|
||||
bool resumable_; // new conns by session
|
||||
uint16 encrypt_size_; // current msg encrypt sz
|
||||
Cipher suite_[SUITE_LEN]; // choosen suite
|
||||
uint8 suites_size_;
|
||||
Cipher suites_[MAX_SUITE_SZ];
|
||||
char cipher_name_[MAX_SUITE_NAME];
|
||||
char cipher_list_[MAX_CIPHERS][MAX_SUITE_NAME];
|
||||
bool removeDH_; // for server's later use
|
||||
|
||||
Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion, bool haveDH);
|
||||
|
||||
void SetSuites(ProtocolVersion pv, bool removeDH = false,
|
||||
bool removeRSA = false, bool removeDSA = false);
|
||||
void SetCipherNames();
|
||||
private:
|
||||
Parameters(const Parameters&); // hide copy
|
||||
Parameters& operator=(const Parameters&); // and assing
|
||||
};
|
||||
|
||||
|
||||
input_buffer& operator>>(input_buffer&, RecordLayerHeader&);
|
||||
output_buffer& operator<<(output_buffer&, const RecordLayerHeader&);
|
||||
|
||||
input_buffer& operator>>(input_buffer&, Message&);
|
||||
output_buffer& operator<<(output_buffer&, const Message&);
|
||||
|
||||
input_buffer& operator>>(input_buffer&, HandShakeBase&);
|
||||
output_buffer& operator<<(output_buffer&, const HandShakeBase&);
|
||||
|
||||
|
||||
// Message Factory definition
|
||||
// uses the ContentType enumeration for unique id
|
||||
typedef Factory<Message> MessageFactory;
|
||||
void InitMessageFactory(MessageFactory&); // registers derived classes
|
||||
|
||||
// HandShake Factory definition
|
||||
// uses the HandShakeType enumeration for unique id
|
||||
typedef Factory<HandShakeBase> HandShakeFactory;
|
||||
void InitHandShakeFactory(HandShakeFactory&); // registers derived classes
|
||||
|
||||
// ServerKey Factory definition
|
||||
// uses KeyExchangeAlgorithm enumeration for unique id
|
||||
typedef Factory<ServerKeyBase> ServerKeyFactory;
|
||||
void InitServerKeyFactory(ServerKeyFactory&);
|
||||
|
||||
// ClientKey Factory definition
|
||||
// uses KeyExchangeAlgorithm enumeration for unique id
|
||||
typedef Factory<ClientKeyBase> ClientKeyFactory;
|
||||
void InitClientKeyFactory(ClientKeyFactory&);
|
||||
|
||||
|
||||
// Message Creators
|
||||
Message* CreateHandShake();
|
||||
Message* CreateCipherSpec();
|
||||
Message* CreateAlert();
|
||||
Message* CreateData();
|
||||
|
||||
|
||||
// HandShake Creators
|
||||
HandShakeBase* CreateCertificate();
|
||||
HandShakeBase* CreateHelloRequest();
|
||||
HandShakeBase* CreateClientHello();
|
||||
HandShakeBase* CreateServerHello();
|
||||
HandShakeBase* CreateServerKeyExchange();
|
||||
HandShakeBase* CreateCertificateRequest();
|
||||
HandShakeBase* CreateServerHelloDone();
|
||||
HandShakeBase* CreateClientKeyExchange();
|
||||
HandShakeBase* CreateCertificateVerify();
|
||||
HandShakeBase* CreateFinished();
|
||||
|
||||
|
||||
// ServerKey Exchange Creators
|
||||
ServerKeyBase* CreateRSAServerKEA();
|
||||
ServerKeyBase* CreateDHServerKEA();
|
||||
ServerKeyBase* CreateFortezzaServerKEA();
|
||||
|
||||
// ClientKey Exchange Creators
|
||||
ClientKeyBase* CreateRSAClient();
|
||||
ClientKeyBase* CreateDHClient();
|
||||
ClientKeyBase* CreateFortezzaClient();
|
||||
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_IMP_HPP
|
||||
@@ -1,693 +0,0 @@
|
||||
/*
|
||||
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* yaSSL internal header defines SSL supporting types not specified in the
|
||||
* draft along with type conversion functions and openssl compatibility
|
||||
*/
|
||||
|
||||
|
||||
#ifndef yaSSL_INT_HPP
|
||||
#define yaSSL_INT_HPP
|
||||
|
||||
#include "yassl_imp.hpp"
|
||||
#include "yassl_error.hpp"
|
||||
#include "crypto_wrapper.hpp"
|
||||
#include "cert_wrapper.hpp"
|
||||
#include "log.hpp"
|
||||
#include "lock.hpp"
|
||||
#include "openssl/ssl.h" // ASN1_STRING and DH
|
||||
|
||||
// Check if _POSIX_THREADS should be forced
|
||||
#if !defined(_POSIX_THREADS) && (defined(__NETWARE__) || defined(__hpux))
|
||||
// HPUX does not define _POSIX_THREADS as it's not _fully_ implemented
|
||||
// Netware supports pthreads but does not announce it
|
||||
#define _POSIX_THREADS
|
||||
#endif
|
||||
|
||||
#ifdef _POSIX_THREADS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
// State Machine for Record Layer Protocol
|
||||
enum RecordLayerState {
|
||||
recordNotReady = 0, // fatal error, no more processing
|
||||
recordReady
|
||||
};
|
||||
|
||||
|
||||
// State Machine for HandShake Protocol
|
||||
enum HandShakeState {
|
||||
handShakeNotReady = 0, // fatal error, no more processing
|
||||
preHandshake, // initial state
|
||||
inHandshake, // handshake started
|
||||
handShakeReady // handshake done
|
||||
};
|
||||
|
||||
|
||||
// client input HandShake state, use if HandShakeState == inHandShake
|
||||
enum ClientState {
|
||||
serverNull = 0,
|
||||
serverHelloComplete,
|
||||
serverCertComplete,
|
||||
serverKeyExchangeComplete,
|
||||
serverHelloDoneComplete,
|
||||
serverFinishedComplete
|
||||
};
|
||||
|
||||
|
||||
// server input HandShake state, use if HandShakeState == inHandShake
|
||||
enum ServerState {
|
||||
clientNull = 0,
|
||||
clientHelloComplete,
|
||||
clientKeyExchangeComplete,
|
||||
clientFinishedComplete
|
||||
};
|
||||
|
||||
|
||||
// client connect state for nonblocking restart
|
||||
enum ConnectState {
|
||||
CONNECT_BEGIN = 0,
|
||||
CLIENT_HELLO_SENT,
|
||||
FIRST_REPLY_DONE,
|
||||
FINISHED_DONE,
|
||||
SECOND_REPLY_DONE
|
||||
};
|
||||
|
||||
|
||||
// server accpet state for nonblocking restart
|
||||
enum AcceptState {
|
||||
ACCEPT_BEGIN = 0,
|
||||
ACCEPT_FIRST_REPLY_DONE,
|
||||
SERVER_HELLO_DONE,
|
||||
ACCEPT_SECOND_REPLY_DONE,
|
||||
ACCEPT_FINISHED_DONE,
|
||||
ACCEPT_THIRD_REPLY_DONE
|
||||
};
|
||||
|
||||
|
||||
// combines all states
|
||||
class States {
|
||||
RecordLayerState recordLayer_;
|
||||
HandShakeState handshakeLayer_;
|
||||
ClientState clientState_;
|
||||
ServerState serverState_;
|
||||
ConnectState connectState_;
|
||||
AcceptState acceptState_;
|
||||
char errorString_[MAX_ERROR_SZ];
|
||||
YasslError what_;
|
||||
public:
|
||||
States();
|
||||
|
||||
const RecordLayerState& getRecord() const;
|
||||
const HandShakeState& getHandShake() const;
|
||||
const ClientState& getClient() const;
|
||||
const ServerState& getServer() const;
|
||||
const ConnectState& GetConnect() const;
|
||||
const AcceptState& GetAccept() const;
|
||||
const char* getString() const;
|
||||
YasslError What() const;
|
||||
|
||||
RecordLayerState& useRecord();
|
||||
HandShakeState& useHandShake();
|
||||
ClientState& useClient();
|
||||
ServerState& useServer();
|
||||
ConnectState& UseConnect();
|
||||
AcceptState& UseAccept();
|
||||
char* useString();
|
||||
void SetError(YasslError);
|
||||
private:
|
||||
States(const States&); // hide copy
|
||||
States& operator=(const States&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// holds all factories
|
||||
class sslFactory {
|
||||
MessageFactory messageFactory_; // creates new messages by type
|
||||
HandShakeFactory handShakeFactory_; // creates new handshake types
|
||||
ServerKeyFactory serverKeyFactory_; // creates new server key types
|
||||
ClientKeyFactory clientKeyFactory_; // creates new client key types
|
||||
|
||||
sslFactory(); // only GetSSL_Factory creates
|
||||
public:
|
||||
const MessageFactory& getMessage() const;
|
||||
const HandShakeFactory& getHandShake() const;
|
||||
const ServerKeyFactory& getServerKey() const;
|
||||
const ClientKeyFactory& getClientKey() const;
|
||||
|
||||
friend sslFactory& GetSSL_Factory(); // singleton creator
|
||||
private:
|
||||
sslFactory(const sslFactory&); // hide copy
|
||||
sslFactory& operator=(const sslFactory&); // and assign
|
||||
};
|
||||
|
||||
|
||||
#undef X509_NAME // wincrypt.h clash
|
||||
|
||||
// openSSL X509 names
|
||||
class X509_NAME {
|
||||
char* name_;
|
||||
size_t sz_;
|
||||
ASN1_STRING entry_;
|
||||
public:
|
||||
X509_NAME(const char*, size_t sz);
|
||||
~X509_NAME();
|
||||
|
||||
const char* GetName() const;
|
||||
ASN1_STRING* GetEntry(int i);
|
||||
size_t GetLength() const;
|
||||
private:
|
||||
X509_NAME(const X509_NAME&); // hide copy
|
||||
X509_NAME& operator=(const X509_NAME&); // and assign
|
||||
};
|
||||
|
||||
|
||||
class StringHolder {
|
||||
ASN1_STRING asnString_;
|
||||
public:
|
||||
StringHolder(const char* str, int sz);
|
||||
~StringHolder();
|
||||
|
||||
ASN1_STRING* GetString();
|
||||
private:
|
||||
StringHolder(const StringHolder&); // hide copy
|
||||
StringHolder& operator=(const StringHolder&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// openSSL X509
|
||||
class X509 {
|
||||
X509_NAME issuer_;
|
||||
X509_NAME subject_;
|
||||
StringHolder beforeDate_; // not valid before
|
||||
StringHolder afterDate_; // not valid after
|
||||
public:
|
||||
X509(const char* i, size_t, const char* s, size_t,
|
||||
const char* b, int, const char* a, int);
|
||||
~X509() {}
|
||||
|
||||
X509_NAME* GetIssuer();
|
||||
X509_NAME* GetSubject();
|
||||
|
||||
ASN1_STRING* GetBefore();
|
||||
ASN1_STRING* GetAfter();
|
||||
|
||||
private:
|
||||
X509(const X509&); // hide copy
|
||||
X509& operator=(const X509&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// openSSL bignum
|
||||
struct BIGNUM {
|
||||
/*
|
||||
gcc 2.96 fix: because of two Integer classes (yaSSL::Integer and
|
||||
TaoCrypt::Integer), we need to explicitly state the namespace
|
||||
here to let gcc 2.96 deduce the correct type.
|
||||
*/
|
||||
yaSSL::Integer int_;
|
||||
void assign(const byte* b, uint s) { int_.assign(b,s); }
|
||||
};
|
||||
|
||||
|
||||
// openSSL session
|
||||
class SSL_SESSION {
|
||||
opaque sessionID_[ID_LEN];
|
||||
opaque master_secret_[SECRET_LEN];
|
||||
Cipher suite_[SUITE_LEN];
|
||||
uint bornOn_; // create time in seconds
|
||||
uint timeout_; // timeout in seconds
|
||||
RandomPool& random_; // will clean master secret
|
||||
X509* peerX509_;
|
||||
public:
|
||||
explicit SSL_SESSION(RandomPool&);
|
||||
SSL_SESSION(const SSL&, RandomPool&);
|
||||
~SSL_SESSION();
|
||||
|
||||
const opaque* GetID() const;
|
||||
const opaque* GetSecret() const;
|
||||
const Cipher* GetSuite() const;
|
||||
uint GetBornOn() const;
|
||||
uint GetTimeOut() const;
|
||||
X509* GetPeerX509() const;
|
||||
void SetTimeOut(uint);
|
||||
|
||||
SSL_SESSION& operator=(const SSL_SESSION&); // allow assign for resumption
|
||||
private:
|
||||
SSL_SESSION(const SSL_SESSION&); // hide copy
|
||||
|
||||
void CopyX509(X509*);
|
||||
};
|
||||
|
||||
|
||||
// holds all sessions
|
||||
class Sessions {
|
||||
STL::list<SSL_SESSION*> list_;
|
||||
RandomPool random_; // for session cleaning
|
||||
Mutex mutex_; // no-op for single threaded
|
||||
int count_; // flush counter
|
||||
|
||||
Sessions() : count_(0) {} // only GetSessions can create
|
||||
public:
|
||||
SSL_SESSION* lookup(const opaque*, SSL_SESSION* copy = 0);
|
||||
void add(const SSL&);
|
||||
void remove(const opaque*);
|
||||
void Flush();
|
||||
|
||||
~Sessions();
|
||||
|
||||
friend Sessions& GetSessions(); // singleton creator
|
||||
private:
|
||||
Sessions(const Sessions&); // hide copy
|
||||
Sessions& operator=(const Sessions&); // and assign
|
||||
};
|
||||
|
||||
|
||||
#ifdef _POSIX_THREADS
|
||||
typedef pthread_t THREAD_ID_T;
|
||||
#else
|
||||
typedef DWORD THREAD_ID_T;
|
||||
#endif
|
||||
|
||||
// thread error data
|
||||
struct ThreadError {
|
||||
THREAD_ID_T threadID_;
|
||||
int errorID_;
|
||||
};
|
||||
|
||||
|
||||
// holds all errors
|
||||
class Errors {
|
||||
STL::list<ThreadError> list_;
|
||||
Mutex mutex_;
|
||||
|
||||
Errors() {} // only GetErrors can create
|
||||
public:
|
||||
int Lookup(bool peek); // self lookup
|
||||
void Add(int);
|
||||
void Remove(); // remove self
|
||||
|
||||
~Errors() {}
|
||||
|
||||
friend Errors& GetErrors(); // singleton creator
|
||||
private:
|
||||
Errors(const Errors&); // hide copy
|
||||
Errors& operator=(const Errors); // and assign
|
||||
};
|
||||
|
||||
|
||||
Sessions& GetSessions(); // forward singletons
|
||||
sslFactory& GetSSL_Factory();
|
||||
Errors& GetErrors();
|
||||
|
||||
|
||||
// openSSL method and context types
|
||||
class SSL_METHOD {
|
||||
ProtocolVersion version_;
|
||||
ConnectionEnd side_;
|
||||
bool verifyPeer_; // request or send certificate
|
||||
bool verifyNone_; // whether to verify certificate
|
||||
bool failNoCert_;
|
||||
bool multipleProtocol_; // for SSLv23 compatibility
|
||||
public:
|
||||
SSL_METHOD(ConnectionEnd ce, ProtocolVersion pv,
|
||||
bool multipleProtocol = false);
|
||||
|
||||
ProtocolVersion getVersion() const;
|
||||
ConnectionEnd getSide() const;
|
||||
|
||||
void setVerifyPeer();
|
||||
void setVerifyNone();
|
||||
void setFailNoCert();
|
||||
|
||||
bool verifyPeer() const;
|
||||
bool verifyNone() const;
|
||||
bool failNoCert() const;
|
||||
bool multipleProtocol() const;
|
||||
private:
|
||||
SSL_METHOD(const SSL_METHOD&); // hide copy
|
||||
SSL_METHOD& operator=(const SSL_METHOD&); // and assign
|
||||
};
|
||||
|
||||
|
||||
struct Ciphers {
|
||||
bool setSuites_; // user set suites from default
|
||||
byte suites_[MAX_SUITE_SZ]; // new suites
|
||||
int suiteSz_; // suite length in bytes
|
||||
|
||||
Ciphers() : setSuites_(false), suiteSz_(0) {}
|
||||
};
|
||||
|
||||
|
||||
struct DH; // forward
|
||||
|
||||
|
||||
// save for SSL construction
|
||||
struct DH_Parms {
|
||||
Integer p_;
|
||||
Integer g_;
|
||||
bool set_; // if set by user
|
||||
|
||||
DH_Parms() : set_(false) {}
|
||||
};
|
||||
|
||||
|
||||
enum StatsField {
|
||||
Accept, Connect, AcceptGood, ConnectGood, AcceptRenegotiate,
|
||||
ConnectRenegotiate, Hits, CbHits, CacheFull, Misses, Timeouts, Number,
|
||||
GetCacheSize, VerifyMode, VerifyDepth
|
||||
};
|
||||
|
||||
|
||||
// SSL stats
|
||||
struct Stats {
|
||||
long accept_;
|
||||
long connect_;
|
||||
long acceptGood_;
|
||||
long connectGood_;
|
||||
long acceptRenegotiate_;
|
||||
long connectRenegotiate_;
|
||||
|
||||
long hits_;
|
||||
long cbHits_;
|
||||
long cacheFull_;
|
||||
long misses_;
|
||||
long timeouts_;
|
||||
long number_;
|
||||
long getCacheSize_;
|
||||
|
||||
int verifyMode_;
|
||||
int verifyDepth_;
|
||||
public:
|
||||
Stats() : accept_(0), connect_(0), acceptGood_(0), connectGood_(0),
|
||||
acceptRenegotiate_(0), connectRenegotiate_(0), hits_(0), cbHits_(0),
|
||||
cacheFull_(0), misses_(0), timeouts_(0), number_(0), getCacheSize_(0),
|
||||
verifyMode_(0), verifyDepth_(0)
|
||||
{}
|
||||
private:
|
||||
Stats(const Stats&); // hide copy
|
||||
Stats& operator=(const Stats&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// the SSL context
|
||||
class SSL_CTX {
|
||||
public:
|
||||
typedef STL::list<x509*> CertList;
|
||||
private:
|
||||
SSL_METHOD* method_;
|
||||
x509* certificate_;
|
||||
x509* privateKey_;
|
||||
CertList caList_;
|
||||
Ciphers ciphers_;
|
||||
DH_Parms dhParms_;
|
||||
pem_password_cb passwordCb_;
|
||||
void* userData_;
|
||||
bool sessionCacheOff_;
|
||||
bool sessionCacheFlushOff_;
|
||||
Stats stats_;
|
||||
Mutex mutex_; // for Stats
|
||||
VerifyCallback verifyCallback_;
|
||||
public:
|
||||
explicit SSL_CTX(SSL_METHOD* meth);
|
||||
~SSL_CTX();
|
||||
|
||||
const x509* getCert() const;
|
||||
const x509* getKey() const;
|
||||
const SSL_METHOD* getMethod() const;
|
||||
const Ciphers& GetCiphers() const;
|
||||
const DH_Parms& GetDH_Parms() const;
|
||||
const Stats& GetStats() const;
|
||||
VerifyCallback getVerifyCallback() const;
|
||||
pem_password_cb GetPasswordCb() const;
|
||||
void* GetUserData() const;
|
||||
bool GetSessionCacheOff() const;
|
||||
bool GetSessionCacheFlushOff() const;
|
||||
|
||||
void setVerifyPeer();
|
||||
void setVerifyNone();
|
||||
void setFailNoCert();
|
||||
void setVerifyCallback(VerifyCallback);
|
||||
bool SetCipherList(const char*);
|
||||
bool SetDH(const DH&);
|
||||
void SetPasswordCb(pem_password_cb cb);
|
||||
void SetUserData(void*);
|
||||
void SetSessionCacheOff();
|
||||
void SetSessionCacheFlushOff();
|
||||
|
||||
void IncrementStats(StatsField);
|
||||
void AddCA(x509* ca);
|
||||
const CertList& GetCA_List() const;
|
||||
|
||||
friend int read_file(SSL_CTX*, const char*, int, CertType);
|
||||
private:
|
||||
SSL_CTX(const SSL_CTX&); // hide copy
|
||||
SSL_CTX& operator=(const SSL_CTX&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// holds all cryptographic types
|
||||
class Crypto {
|
||||
Digest* digest_; // agreed upon digest
|
||||
BulkCipher* cipher_; // agreed upon cipher
|
||||
DiffieHellman* dh_; // dh parms
|
||||
RandomPool random_; // random number generator
|
||||
CertManager cert_; // manages certificates
|
||||
public:
|
||||
explicit Crypto();
|
||||
~Crypto();
|
||||
|
||||
const Digest& get_digest() const;
|
||||
const BulkCipher& get_cipher() const;
|
||||
const DiffieHellman& get_dh() const;
|
||||
const RandomPool& get_random() const;
|
||||
const CertManager& get_certManager() const;
|
||||
|
||||
Digest& use_digest();
|
||||
BulkCipher& use_cipher();
|
||||
DiffieHellman& use_dh();
|
||||
RandomPool& use_random();
|
||||
CertManager& use_certManager();
|
||||
|
||||
void SetDH(DiffieHellman*);
|
||||
void SetDH(const DH_Parms&);
|
||||
void setDigest(Digest*);
|
||||
void setCipher(BulkCipher*);
|
||||
|
||||
bool DhSet();
|
||||
private:
|
||||
Crypto(const Crypto&); // hide copy
|
||||
Crypto& operator=(const Crypto&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// holds all handshake and verify hashes
|
||||
class sslHashes {
|
||||
MD5 md5HandShake_; // md5 handshake hash
|
||||
SHA shaHandShake_; // sha handshake hash
|
||||
Finished verify_; // peer's verify hash
|
||||
Hashes certVerify_; // peer's cert verify hash
|
||||
public:
|
||||
sslHashes() {}
|
||||
|
||||
const MD5& get_MD5() const;
|
||||
const SHA& get_SHA() const;
|
||||
const Finished& get_verify() const;
|
||||
const Hashes& get_certVerify() const;
|
||||
|
||||
MD5& use_MD5();
|
||||
SHA& use_SHA();
|
||||
Finished& use_verify();
|
||||
Hashes& use_certVerify();
|
||||
private:
|
||||
sslHashes(const sslHashes&); // hide copy
|
||||
sslHashes& operator=(const sslHashes&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// holds input and output buffers
|
||||
class Buffers {
|
||||
public:
|
||||
typedef STL::list<input_buffer*> inputList;
|
||||
typedef STL::list<output_buffer*> outputList;
|
||||
private:
|
||||
inputList dataList_; // list of users app data / handshake
|
||||
outputList handShakeList_; // buffered handshake msgs
|
||||
input_buffer* rawInput_; // buffered raw input yet to process
|
||||
public:
|
||||
Buffers();
|
||||
~Buffers();
|
||||
|
||||
const inputList& getData() const;
|
||||
const outputList& getHandShake() const;
|
||||
|
||||
inputList& useData();
|
||||
outputList& useHandShake();
|
||||
|
||||
void SetRawInput(input_buffer*); // takes ownership
|
||||
input_buffer* TakeRawInput(); // takes ownership
|
||||
private:
|
||||
Buffers(const Buffers&); // hide copy
|
||||
Buffers& operator=(const Buffers&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// wraps security parameters
|
||||
class Security {
|
||||
Connection conn_; // connection information
|
||||
Parameters parms_; // may be pending
|
||||
SSL_SESSION resumeSession_; // if resuming
|
||||
SSL_CTX* ctx_; // context used to init
|
||||
bool resuming_; // trying to resume
|
||||
public:
|
||||
Security(ProtocolVersion, RandomPool&, ConnectionEnd, const Ciphers&,
|
||||
SSL_CTX*, bool);
|
||||
|
||||
const SSL_CTX* GetContext() const;
|
||||
const Connection& get_connection() const;
|
||||
const Parameters& get_parms() const;
|
||||
const SSL_SESSION& get_resume() const;
|
||||
bool get_resuming() const;
|
||||
|
||||
Connection& use_connection();
|
||||
Parameters& use_parms();
|
||||
SSL_SESSION& use_resume();
|
||||
|
||||
void set_resuming(bool b);
|
||||
private:
|
||||
Security(const Security&); // hide copy
|
||||
Security& operator=(const Security&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// THE SSL type
|
||||
class SSL {
|
||||
Crypto crypto_; // agreed crypto agents
|
||||
Security secure_; // Connection and Session parms
|
||||
States states_; // Record and HandShake states
|
||||
sslHashes hashes_; // handshake, finished hashes
|
||||
Socket socket_; // socket wrapper
|
||||
Buffers buffers_; // buffered handshakes and data
|
||||
Log log_; // logger
|
||||
bool quietShutdown_;
|
||||
|
||||
// optimization variables
|
||||
bool has_data_; // buffered data ready?
|
||||
public:
|
||||
SSL(SSL_CTX* ctx);
|
||||
|
||||
// gets and uses
|
||||
const Crypto& getCrypto() const;
|
||||
const Security& getSecurity() const;
|
||||
const States& getStates() const;
|
||||
const sslHashes& getHashes() const;
|
||||
const sslFactory& getFactory() const;
|
||||
const Socket& getSocket() const;
|
||||
YasslError GetError() const;
|
||||
bool GetMultiProtocol() const;
|
||||
bool CompressionOn() const;
|
||||
|
||||
Crypto& useCrypto();
|
||||
Security& useSecurity();
|
||||
States& useStates();
|
||||
sslHashes& useHashes();
|
||||
Socket& useSocket();
|
||||
Log& useLog();
|
||||
Buffers& useBuffers();
|
||||
|
||||
bool HasData() const;
|
||||
bool GetQuietShutdown() const;
|
||||
|
||||
// sets
|
||||
void set_pending(Cipher suite);
|
||||
void set_random(const opaque*, ConnectionEnd);
|
||||
void set_sessionID(const opaque*);
|
||||
void set_session(SSL_SESSION*);
|
||||
void set_preMaster(const opaque*, uint);
|
||||
void set_masterSecret(const opaque*);
|
||||
void SetError(YasslError);
|
||||
int SetCompression();
|
||||
void UnSetCompression();
|
||||
void SetQuietShutdown(bool mode);
|
||||
|
||||
// helpers
|
||||
bool isTLS() const;
|
||||
bool isTLSv1_1() const;
|
||||
void order_error();
|
||||
void makeMasterSecret();
|
||||
void makeTLSMasterSecret();
|
||||
void addData(input_buffer* data);
|
||||
void fillData(Data&);
|
||||
void PeekData(Data&);
|
||||
void addBuffer(output_buffer* b);
|
||||
void flushBuffer();
|
||||
void verifyState(const RecordLayerHeader&);
|
||||
void verifyState(const HandShakeHeader&);
|
||||
void verifyState(ClientState);
|
||||
void verifyState(ServerState);
|
||||
void verfiyHandShakeComplete();
|
||||
void matchSuite(const opaque*, uint length);
|
||||
void deriveKeys();
|
||||
void deriveTLSKeys();
|
||||
void Send(const byte*, uint);
|
||||
|
||||
uint bufferedData();
|
||||
uint get_SEQIncrement(bool);
|
||||
|
||||
const byte* get_macSecret(bool);
|
||||
private:
|
||||
void storeKeys(const opaque*);
|
||||
void setKeys();
|
||||
void verifyClientState(HandShakeType);
|
||||
void verifyServerState(HandShakeType);
|
||||
|
||||
SSL(const SSL&); // hide copy
|
||||
const SSL& operator=(const SSL&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// compression
|
||||
int Compress(const byte*, int, input_buffer&);
|
||||
int DeCompress(input_buffer&, int, input_buffer&);
|
||||
|
||||
|
||||
// conversion functions
|
||||
void c32to24(uint32, uint24&);
|
||||
void c24to32(const uint24, uint32&);
|
||||
|
||||
uint32 c24to32(const uint24);
|
||||
|
||||
void ato16(const opaque*, uint16&);
|
||||
void ato24(const opaque*, uint24&);
|
||||
|
||||
void c16toa(uint16, opaque*);
|
||||
void c24toa(const uint24, opaque*);
|
||||
void c32toa(uint32 u32, opaque*);
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // yaSSL_INT_HPP
|
||||
@@ -1,530 +0,0 @@
|
||||
/*
|
||||
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* yaSSL types header defines all constants, enums, and typedefs
|
||||
* from the SSL.v3 specification "draft-freier-ssl-version3-02.txt"
|
||||
*/
|
||||
|
||||
|
||||
#ifndef yaSSL_TYPES_HPP
|
||||
#define yaSSL_TYPES_HPP
|
||||
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
#include "type_traits.hpp"
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// disable conversion warning
|
||||
// 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
|
||||
#pragma warning(disable:4244 4996)
|
||||
#endif
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
#define YASSL_LIB
|
||||
|
||||
|
||||
#ifdef YASSL_PURE_C
|
||||
|
||||
// library allocation
|
||||
struct new_t {}; // yaSSL New type
|
||||
extern new_t ys; // pass in parameter
|
||||
|
||||
} // namespace yaSSL
|
||||
|
||||
void* operator new (size_t, 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 {
|
||||
|
||||
|
||||
template<typename T>
|
||||
void ysDelete(T* ptr)
|
||||
{
|
||||
if (ptr) ptr->~T();
|
||||
::operator delete(ptr, yaSSL::ys);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void ysArrayDelete(T* ptr)
|
||||
{
|
||||
// can't do array placement destruction since not tracking size in
|
||||
// allocation, only allow builtins to use array placement since they
|
||||
// don't need destructors called
|
||||
typedef char builtin[TaoCrypt::IsFundamentalType<T>::Yes ? 1 : -1];
|
||||
(void)sizeof(builtin);
|
||||
|
||||
::operator delete[](ptr, yaSSL::ys);
|
||||
}
|
||||
|
||||
#define NEW_YS new (yaSSL::ys)
|
||||
|
||||
// to resolve compiler generated operator delete on base classes with
|
||||
// virtual destructors (when on stack), make sure doesn't get called
|
||||
class virtual_base {
|
||||
public:
|
||||
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 short uint16;
|
||||
typedef unsigned int uint32;
|
||||
typedef uint8 uint24[3];
|
||||
typedef uint32 uint64[2];
|
||||
|
||||
typedef uint8 opaque;
|
||||
typedef opaque byte;
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
|
||||
#ifdef USE_SYS_STL
|
||||
// use system STL
|
||||
#define STL_VECTOR_FILE <vector>
|
||||
#define STL_LIST_FILE <list>
|
||||
#define STL_ALGORITHM_FILE <algorithm>
|
||||
#define STL_MEMORY_FILE <memory>
|
||||
#define STL_PAIR_FILE <utility>
|
||||
|
||||
#define STL_NAMESPACE std
|
||||
#else
|
||||
// use mySTL
|
||||
#define STL_VECTOR_FILE "vector.hpp"
|
||||
#define STL_LIST_FILE "list.hpp"
|
||||
#define STL_ALGORITHM_FILE "algorithm.hpp"
|
||||
#define STL_MEMORY_FILE "memory.hpp"
|
||||
#define STL_PAIR_FILE "pair.hpp"
|
||||
|
||||
#define STL_NAMESPACE mySTL
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
T min(T a, T b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// all length constants in bytes
|
||||
const int ID_LEN = 32; // session id length
|
||||
const int SUITE_LEN = 2; // cipher suite length
|
||||
const int SECRET_LEN = 48; // pre RSA and all master secret length
|
||||
const int MASTER_ROUNDS = 3; // master secret derivation rounds
|
||||
const int RAN_LEN = 32; // client and server random length
|
||||
const int MAC_BLOCK_SZ = 64; // MAC block size, & padding
|
||||
const int MD5_LEN = 16; // MD5 digest length
|
||||
const int SHA_LEN = 20; // SHA digest length
|
||||
const int RMD_LEN = 20; // RIPEMD-160 digest length
|
||||
const int PREFIX = 3; // up to 3 prefix letters for secret rounds
|
||||
const int KEY_PREFIX = 7; // up to 7 prefix letters for key rounds
|
||||
const int FORTEZZA_MAX = 128; // Maximum Fortezza Key length
|
||||
const int MAX_SUITE_SZ = 128; // 64 max suites * sizeof(suite)
|
||||
const int MAX_SUITE_NAME = 48; // max length of suite name
|
||||
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_SENDER = 4; // Sender constant, for finished generation
|
||||
const int PAD_MD5 = 48; // pad length 1 and 2 for md5 finished
|
||||
const int PAD_SHA = 40; // should be 44, specd wrong by netscape
|
||||
const int PAD_RMD = 44; // pad length for RIPEMD-160, some use 40??
|
||||
const int CERT_HEADER = 3; // always use 3 bytes for certificate
|
||||
const int CERT_TYPES = 7; // certificate request types
|
||||
const int REQUEST_HEADER = 2; // request uses 2 bytes
|
||||
const int VERIFY_HEADER = 2; // verify length field
|
||||
const int MIN_CERT_TYPES = 1; // minimum certificate request types
|
||||
const int MIN_DIS_NAMES = 3; // minimum distinguished names
|
||||
const int MIN_DIS_SIZE = 1; // minimum distinguished name size
|
||||
const int RECORD_HEADER = 5; // type + version + length(2)
|
||||
const int HANDSHAKE_HEADER = 4; // type + length(3)
|
||||
const int FINISHED_SZ = MD5_LEN + SHA_LEN; // sizeof finished data
|
||||
const int TLS_FINISHED_SZ = 12; // TLS verify data size
|
||||
const int SEQ_SZ = 8; // 64 bit sequence number
|
||||
const int LENGTH_SZ = 2; // length field for HMAC, data only
|
||||
const int VERSION_SZ = SIZEOF_ENUM * 2; // SSL/TLS length of version
|
||||
const int DES_KEY_SZ = 8; // DES Key length
|
||||
const int DES_EDE_KEY_SZ = 24; // DES EDE Key length
|
||||
const int DES_BLOCK = 8; // DES is always fixed block size 8
|
||||
const int DES_IV_SZ = DES_BLOCK; // Init Vector length for DES
|
||||
const int RC4_KEY_SZ = 16; // RC4 Key length
|
||||
const int AES_128_KEY_SZ = 16; // AES 128bit Key length
|
||||
const int AES_192_KEY_SZ = 24; // AES 192bit Key length
|
||||
const int AES_256_KEY_SZ = 32; // AES 256bit Key length
|
||||
const int AES_BLOCK_SZ = 16; // AES 128bit block size, rfc 3268
|
||||
const int AES_IV_SZ = AES_BLOCK_SZ; // AES Init Vector length
|
||||
const int DSS_SIG_SZ = 40; // two 20 byte high byte first Integers
|
||||
const int DSS_ENCODED_EXTRA = 6; // seqID + len(1) + (intID + len(1)) * 2
|
||||
const int EVP_SALT_SZ = 8;
|
||||
const int MASTER_LABEL_SZ = 13; // TLS master secret label size
|
||||
const int KEY_LABEL_SZ = 13; // TLS key block expansion size
|
||||
const int FINISHED_LABEL_SZ = 15; // TLS finished lable length
|
||||
const int SEED_LEN = RAN_LEN * 2; // TLS seed, client + server random
|
||||
const int DEFAULT_TIMEOUT = 500; // Default Session timeout in seconds
|
||||
const int MAX_RECORD_SIZE = 16384; // 2^14, max size by standard
|
||||
const int COMPRESS_EXTRA = 1024; // extra compression possible addition
|
||||
const int SESSION_FLUSH_COUNT = 256; // when to flush session cache
|
||||
|
||||
|
||||
typedef uint8 Cipher; // first byte is always 0x00 for SSLv3 & TLS
|
||||
|
||||
typedef opaque Random[RAN_LEN];
|
||||
|
||||
typedef opaque* DistinguishedName;
|
||||
|
||||
typedef bool IsExportable;
|
||||
|
||||
|
||||
enum CompressionMethod { no_compression = 0, zlib = 221 };
|
||||
|
||||
enum CipherType { stream, block };
|
||||
|
||||
enum CipherChoice { change_cipher_spec_choice = 1 };
|
||||
|
||||
enum PublicValueEncoding { implicit_encoding, explicit_encoding };
|
||||
|
||||
enum ConnectionEnd { server_end, client_end };
|
||||
|
||||
enum AlertLevel { warning = 1, fatal = 2 };
|
||||
|
||||
|
||||
|
||||
// Record Layer Header identifier from page 12
|
||||
enum ContentType {
|
||||
no_type = 0,
|
||||
change_cipher_spec = 20,
|
||||
alert = 21,
|
||||
handshake = 22,
|
||||
application_data = 23
|
||||
};
|
||||
|
||||
|
||||
// HandShake Layer Header identifier from page 20
|
||||
enum HandShakeType {
|
||||
no_shake = -1,
|
||||
hello_request = 0,
|
||||
client_hello = 1,
|
||||
server_hello = 2,
|
||||
certificate = 11,
|
||||
server_key_exchange = 12,
|
||||
certificate_request = 13,
|
||||
server_hello_done = 14,
|
||||
certificate_verify = 15,
|
||||
client_key_exchange = 16,
|
||||
finished = 20
|
||||
};
|
||||
|
||||
|
||||
// Valid Alert types from page 16/17
|
||||
enum AlertDescription {
|
||||
close_notify = 0,
|
||||
unexpected_message = 10,
|
||||
bad_record_mac = 20,
|
||||
decompression_failure = 30,
|
||||
handshake_failure = 40,
|
||||
no_certificate = 41,
|
||||
bad_certificate = 42,
|
||||
unsupported_certificate = 43,
|
||||
certificate_revoked = 44,
|
||||
certificate_expired = 45,
|
||||
certificate_unknown = 46,
|
||||
illegal_parameter = 47
|
||||
};
|
||||
|
||||
|
||||
// Supported Key Exchange Protocols
|
||||
enum KeyExchangeAlgorithm {
|
||||
no_kea = 0,
|
||||
rsa_kea,
|
||||
diffie_hellman_kea,
|
||||
fortezza_kea
|
||||
};
|
||||
|
||||
|
||||
// Supported Authentication Schemes
|
||||
enum SignatureAlgorithm {
|
||||
anonymous_sa_algo = 0,
|
||||
rsa_sa_algo,
|
||||
dsa_sa_algo
|
||||
};
|
||||
|
||||
|
||||
// Valid client certificate request types from page 27
|
||||
enum ClientCertificateType {
|
||||
rsa_sign = 1,
|
||||
dss_sign = 2,
|
||||
rsa_fixed_dh = 3,
|
||||
dss_fixed_dh = 4,
|
||||
rsa_ephemeral_dh = 5,
|
||||
dss_ephemeral_dh = 6,
|
||||
fortezza_kea_cert = 20
|
||||
};
|
||||
|
||||
|
||||
// Supported Ciphers from page 43
|
||||
enum BulkCipherAlgorithm {
|
||||
cipher_null,
|
||||
rc4,
|
||||
rc2,
|
||||
des,
|
||||
triple_des, // leading 3 (3des) not valid identifier
|
||||
des40,
|
||||
idea,
|
||||
aes
|
||||
};
|
||||
|
||||
|
||||
// Supported Message Authentication Codes from page 43
|
||||
enum MACAlgorithm {
|
||||
no_mac,
|
||||
md5,
|
||||
sha,
|
||||
rmd
|
||||
};
|
||||
|
||||
|
||||
// Certificate file Type
|
||||
enum CertType { Cert = 0, PrivateKey, CA };
|
||||
|
||||
|
||||
// all Cipher Suites from pages 41/42
|
||||
const Cipher SSL_NULL_WITH_NULL_NULL = 0; // { 0x00, 0x00 }
|
||||
const Cipher SSL_RSA_WITH_NULL_MD5 = 1; // { 0x00, 0x01 }
|
||||
const Cipher SSL_RSA_WITH_NULL_SHA = 2; // { 0x00, 0x02 }
|
||||
const Cipher SSL_RSA_EXPORT_WITH_RC4_40_MD5 = 3; // { 0x00, 0x03 }
|
||||
const Cipher SSL_RSA_WITH_RC4_128_MD5 = 4; // { 0x00, 0x04 }
|
||||
const Cipher SSL_RSA_WITH_RC4_128_SHA = 5; // { 0x00, 0x05 }
|
||||
const Cipher SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 6; // { 0x00, 0x06 }
|
||||
const Cipher SSL_RSA_WITH_IDEA_CBC_SHA = 7; // { 0x00, 0x07 }
|
||||
const Cipher SSL_RSA_EXPORT_WITH_DES40_CBC_SHA = 8; // { 0x00, 0x08 }
|
||||
const Cipher SSL_RSA_WITH_DES_CBC_SHA = 9; // { 0x00, 0x09 }
|
||||
const Cipher SSL_RSA_WITH_3DES_EDE_CBC_SHA = 10; // { 0x00, 0x0A }
|
||||
const Cipher SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 11; // { 0x00, 0x0B }
|
||||
const Cipher SSL_DH_DSS_WITH_DES_CBC_SHA = 12; // { 0x00, 0x0C }
|
||||
const Cipher SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA = 13; // { 0x00, 0x0D }
|
||||
const Cipher SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 14; // { 0x00, 0x0E }
|
||||
const Cipher SSL_DH_RSA_WITH_DES_CBC_SHA = 15; // { 0x00, 0x0F }
|
||||
const Cipher SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA = 16; // { 0x00, 0x10 }
|
||||
const Cipher SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 17; // { 0x00, 0x11 }
|
||||
const Cipher SSL_DHE_DSS_WITH_DES_CBC_SHA = 18; // { 0x00, 0x12 }
|
||||
const Cipher SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 19; // { 0x00, 0x13 }
|
||||
const Cipher SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 20; // { 0x00, 0x14 }
|
||||
const Cipher SSL_DHE_RSA_WITH_DES_CBC_SHA = 21; // { 0x00, 0x15 }
|
||||
const Cipher SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 22; // { 0x00, 0x16 }
|
||||
const Cipher SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 = 23; // { 0x00, 0x17 }
|
||||
const Cipher SSL_DH_anon_WITH_RC4_128_MD5 = 24; // { 0x00, 0x18 }
|
||||
const Cipher SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 25; // { 0x00, 0x19 }
|
||||
const Cipher SSL_DH_anon_WITH_DES_CBC_SHA = 26; // { 0x00, 0x1A }
|
||||
const Cipher SSL_DH_anon_WITH_3DES_EDE_CBC_SHA = 27; // { 0x00, 0x1B }
|
||||
const Cipher SSL_FORTEZZA_KEA_WITH_NULL_SHA = 28; // { 0x00, 0x1C }
|
||||
const Cipher SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 29; // { 0x00, 0x1D }
|
||||
const Cipher SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 30; // { 0x00, 0x1E }
|
||||
|
||||
// .. to 0x2B uses Kerberos Authentication
|
||||
|
||||
|
||||
// TLS AES extensions
|
||||
const Cipher TLS_RSA_WITH_AES_128_CBC_SHA = 47; // { 0x00, 0x2F }
|
||||
const Cipher TLS_DH_DSS_WITH_AES_128_CBC_SHA = 48; // { 0x00, 0x30 }
|
||||
const Cipher TLS_DH_RSA_WITH_AES_128_CBC_SHA = 49; // { 0x00, 0x31 }
|
||||
const Cipher TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 50; // { 0x00, 0x32 }
|
||||
const Cipher TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 51; // { 0x00, 0x33 }
|
||||
const Cipher TLS_DH_anon_WITH_AES_128_CBC_SHA = 52; // { 0x00, 0x34 }
|
||||
|
||||
const Cipher TLS_RSA_WITH_AES_256_CBC_SHA = 53; // { 0x00, 0x35 }
|
||||
const Cipher TLS_DH_DSS_WITH_AES_256_CBC_SHA = 54; // { 0x00, 0x36 }
|
||||
const Cipher TLS_DH_RSA_WITH_AES_256_CBC_SHA = 55; // { 0x00, 0x37 }
|
||||
const Cipher TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 56; // { 0x00, 0x38 }
|
||||
const Cipher TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 57; // { 0x00, 0x39 }
|
||||
const Cipher TLS_DH_anon_WITH_AES_256_CBC_SHA = 58; // { 0x00, 0x3A }
|
||||
|
||||
|
||||
// OpenPGP extensions
|
||||
|
||||
const Cipher TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160 = 114; // { 0x00, 0x72 };
|
||||
const Cipher TLS_DHE_DSS_WITH_AES_128_CBC_RMD160 = 115; // { 0x00, 0x73 };
|
||||
const Cipher TLS_DHE_DSS_WITH_AES_256_CBC_RMD160 = 116; // { 0x00, 0x74 };
|
||||
const Cipher TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160 = 119; // { 0x00, 0x77 };
|
||||
const Cipher TLS_DHE_RSA_WITH_AES_128_CBC_RMD160 = 120; // { 0x00, 0x78 };
|
||||
const Cipher TLS_DHE_RSA_WITH_AES_256_CBC_RMD160 = 121; // { 0x00, 0x79 };
|
||||
const Cipher TLS_RSA_WITH_3DES_EDE_CBC_RMD160 = 124; // { 0x00, 0x7C };
|
||||
const Cipher TLS_RSA_WITH_AES_128_CBC_RMD160 = 125; // { 0x00, 0x7D };
|
||||
const Cipher TLS_RSA_WITH_AES_256_CBC_RMD160 = 126; // { 0x00, 0x7E };
|
||||
|
||||
|
||||
const char* const null_str = "";
|
||||
|
||||
const char* const cipher_names[128] =
|
||||
{
|
||||
null_str, // SSL_NULL_WITH_NULL_NULL = 0
|
||||
null_str, // SSL_RSA_WITH_NULL_MD5 = 1
|
||||
null_str, // SSL_RSA_WITH_NULL_SHA = 2
|
||||
null_str, // SSL_RSA_EXPORT_WITH_RC4_40_MD5 = 3
|
||||
"RC4-MD5", // SSL_RSA_WITH_RC4_128_MD5 = 4
|
||||
"RC4-SHA", // SSL_RSA_WITH_RC4_128_SHA = 5
|
||||
null_str, // SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 6
|
||||
null_str, // SSL_RSA_WITH_IDEA_CBC_SHA = 7
|
||||
null_str, // SSL_RSA_EXPORT_WITH_DES40_CBC_SHA = 8
|
||||
"DES-CBC-SHA", // SSL_RSA_WITH_DES_CBC_SHA = 9
|
||||
"DES-CBC3-SHA", // SSL_RSA_WITH_3DES_EDE_CBC_SHA = 10
|
||||
|
||||
null_str, // SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 11
|
||||
null_str, // SSL_DH_DSS_WITH_DES_CBC_SHA = 12
|
||||
null_str, // SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA = 13
|
||||
null_str, // SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 14
|
||||
null_str, // SSL_DH_RSA_WITH_DES_CBC_SHA = 15
|
||||
null_str, // SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA = 16
|
||||
null_str, // SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 17
|
||||
"EDH-DSS-DES-CBC-SHA", // SSL_DHE_DSS_WITH_DES_CBC_SHA = 18
|
||||
"EDH-DSS-DES-CBC3-SHA", // SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 19
|
||||
null_str, // SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 20
|
||||
|
||||
"EDH-RSA-DES-CBC-SHA", // SSL_DHE_RSA_WITH_DES_CBC_SHA = 21
|
||||
"EDH-RSA-DES-CBC3-SHA", // SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 22
|
||||
null_str, // SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 = 23
|
||||
null_str, // SSL_DH_anon_WITH_RC4_128_MD5 = 24
|
||||
null_str, // SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 25
|
||||
null_str, // SSL_DH_anon_WITH_DES_CBC_SHA = 26
|
||||
null_str, // SSL_DH_anon_WITH_3DES_EDE_CBC_SHA = 27
|
||||
null_str, // SSL_FORTEZZA_KEA_WITH_NULL_SHA = 28
|
||||
null_str, // SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 29
|
||||
null_str, // SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 30
|
||||
|
||||
null_str, null_str, null_str, null_str, null_str, // 31 - 35
|
||||
null_str, null_str, null_str, null_str, null_str, // 36 - 40
|
||||
null_str, null_str, null_str, null_str, null_str, // 41 - 45
|
||||
null_str, // 46
|
||||
|
||||
// TLS AES extensions
|
||||
"AES128-SHA", // TLS_RSA_WITH_AES_128_CBC_SHA = 47
|
||||
null_str, // TLS_DH_DSS_WITH_AES_128_CBC_SHA = 48
|
||||
null_str, // TLS_DH_RSA_WITH_AES_128_CBC_SHA = 49
|
||||
"DHE-DSS-AES128-SHA", // TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 50
|
||||
"DHE-RSA-AES128-SHA", // TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 51
|
||||
null_str, // TLS_DH_anon_WITH_AES_128_CBC_SHA = 52
|
||||
|
||||
"AES256-SHA", // TLS_RSA_WITH_AES_256_CBC_SHA = 53
|
||||
null_str, // TLS_DH_DSS_WITH_AES_256_CBC_SHA = 54
|
||||
null_str, // TLS_DH_RSA_WITH_AES_256_CBC_SHA = 55
|
||||
"DHE-DSS-AES256-SHA", // TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 56
|
||||
"DHE-RSA-AES256-SHA", // TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 57
|
||||
null_str, // TLS_DH_anon_WITH_AES_256_CBC_SHA = 58
|
||||
|
||||
null_str, // 59
|
||||
null_str, // 60
|
||||
null_str, null_str, null_str, null_str, null_str, // 61 - 65
|
||||
null_str, null_str, null_str, null_str, null_str, // 66 - 70
|
||||
null_str, null_str, null_str, null_str, null_str, // 71 - 75
|
||||
null_str, null_str, null_str, null_str, null_str, // 76 - 80
|
||||
null_str, null_str, null_str, null_str, null_str, // 81 - 85
|
||||
null_str, null_str, null_str, null_str, null_str, // 86 - 90
|
||||
null_str, null_str, null_str, null_str, null_str, // 91 - 95
|
||||
null_str, null_str, null_str, null_str, null_str, // 96 - 100
|
||||
null_str, null_str, null_str, null_str, null_str, // 101 - 105
|
||||
null_str, null_str, null_str, null_str, null_str, // 106 - 110
|
||||
null_str, null_str, null_str, // 111 - 113
|
||||
|
||||
"DHE-DSS-DES-CBC3-RMD", // TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160 = 114
|
||||
"DHE-DSS-AES128-RMD", // TLS_DHE_DSS_WITH_AES_128_CBC_RMD160 = 115
|
||||
"DHE-DSS-AES256-RMD", // TLS_DHE_DSS_WITH_AES_256_CBC_RMD160 = 116
|
||||
null_str, // 117
|
||||
null_str, // 118
|
||||
"DHE-RSA-DES-CBC3-RMD", // TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160 = 119
|
||||
"DHE-RSA-AES128-RMD", // TLS_DHE_RSA_WITH_AES_128_CBC_RMD160 = 120
|
||||
"DHE-RSA-AES256-RMD", // TLS_DHE_RSA_WITH_AES_256_CBC_RMD160 = 121
|
||||
null_str, // 122
|
||||
null_str, // 123
|
||||
"DES-CBC3-RMD", // TLS_RSA_WITH_3DES_EDE_CBC_RMD160 = 124
|
||||
"AES128-RMD", // TLS_RSA_WITH_AES_128_CBC_RMD160 = 125
|
||||
"AES256-RMD", // TLS_RSA_WITH_AES_256_CBC_RMD160 = 126
|
||||
null_str // 127
|
||||
};
|
||||
|
||||
// fill with MD5 pad size since biggest required
|
||||
const opaque PAD1[PAD_MD5] = { 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36
|
||||
};
|
||||
const opaque PAD2[PAD_MD5] = { 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c
|
||||
};
|
||||
|
||||
const opaque client[SIZEOF_SENDER] = { 0x43, 0x4C, 0x4E, 0x54 };
|
||||
const opaque server[SIZEOF_SENDER] = { 0x53, 0x52, 0x56, 0x52 };
|
||||
|
||||
const opaque tls_client[FINISHED_LABEL_SZ + 1] = "client finished";
|
||||
const opaque tls_server[FINISHED_LABEL_SZ + 1] = "server finished";
|
||||
|
||||
const opaque master_label[MASTER_LABEL_SZ + 1] = "master secret";
|
||||
const opaque key_label [KEY_LABEL_SZ + 1] = "key expansion";
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96
|
||||
/*
|
||||
gcc 2.96 bails out because of two declarations of byte: yaSSL::byte and
|
||||
TaoCrypt::byte. TODO: define global types.hpp and move the declaration of
|
||||
'byte' there.
|
||||
*/
|
||||
using yaSSL::byte;
|
||||
#endif
|
||||
|
||||
|
||||
#endif // yaSSL_TYPES_HPP
|
||||
@@ -1,279 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* yaSSL buffer header implements input/output buffers to simulate streaming
|
||||
* with SSL types and sockets
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h> // memcpy
|
||||
#include "runtime.hpp"
|
||||
#include "buffer.hpp"
|
||||
#include "yassl_types.hpp"
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
|
||||
// Checking Policy should implement a check function that tests whether the
|
||||
// index is within the size limit of the array
|
||||
|
||||
void Check::check(uint i, uint limit)
|
||||
{
|
||||
assert(i < limit);
|
||||
}
|
||||
|
||||
|
||||
void NoCheck::check(uint, uint)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* input_buffer operates like a smart c style array with a checking option,
|
||||
* meant to be read from through [] with AUTO index or read().
|
||||
* Should only write to at/near construction with assign() or raw (e.g., recv)
|
||||
* followed by add_size with the number of elements added by raw write.
|
||||
*
|
||||
* Not using vector because need checked []access, offset, and the ability to
|
||||
* write to the buffer bulk wise and have the correct size
|
||||
*/
|
||||
|
||||
|
||||
input_buffer::input_buffer()
|
||||
: size_(0), current_(0), buffer_(0), end_(0)
|
||||
{}
|
||||
|
||||
|
||||
input_buffer::input_buffer(uint s)
|
||||
: size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
|
||||
{}
|
||||
|
||||
|
||||
// with assign
|
||||
input_buffer::input_buffer(uint s, const byte* t, uint len)
|
||||
: size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
|
||||
{
|
||||
assign(t, len);
|
||||
}
|
||||
|
||||
|
||||
input_buffer::~input_buffer()
|
||||
{
|
||||
ysArrayDelete(buffer_);
|
||||
}
|
||||
|
||||
|
||||
// users can pass defualt zero length buffer and then allocate
|
||||
void input_buffer::allocate(uint s)
|
||||
{
|
||||
assert(!buffer_); // find realloc error
|
||||
buffer_ = NEW_YS byte[s];
|
||||
end_ = buffer_ + s;
|
||||
}
|
||||
|
||||
|
||||
// for passing to raw writing functions at beginning, then use add_size
|
||||
byte* input_buffer::get_buffer() const
|
||||
{
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
|
||||
// after a raw write user can set NEW_YS size
|
||||
// if you know the size before the write use assign()
|
||||
void input_buffer::add_size(uint i)
|
||||
{
|
||||
check(size_ + i-1, get_capacity());
|
||||
size_ += i;
|
||||
}
|
||||
|
||||
|
||||
uint input_buffer::get_capacity() const
|
||||
{
|
||||
return (uint) (end_ - buffer_);
|
||||
}
|
||||
|
||||
|
||||
uint input_buffer::get_current() const
|
||||
{
|
||||
return current_;
|
||||
}
|
||||
|
||||
|
||||
uint input_buffer::get_size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
|
||||
uint input_buffer::get_remaining() const
|
||||
{
|
||||
return size_ - current_;
|
||||
}
|
||||
|
||||
|
||||
void input_buffer::set_current(uint i)
|
||||
{
|
||||
if (i)
|
||||
check(i - 1, size_);
|
||||
current_ = i;
|
||||
}
|
||||
|
||||
|
||||
// read only access through [], advance current
|
||||
// user passes in AUTO index for ease of use
|
||||
const byte& input_buffer::operator[](uint i)
|
||||
{
|
||||
assert (i == AUTO);
|
||||
check(current_, size_);
|
||||
return buffer_[current_++];
|
||||
}
|
||||
|
||||
|
||||
// end of input test
|
||||
bool input_buffer::eof()
|
||||
{
|
||||
return current_ >= size_;
|
||||
}
|
||||
|
||||
|
||||
// peek ahead
|
||||
byte input_buffer::peek() const
|
||||
{
|
||||
return buffer_[current_];
|
||||
}
|
||||
|
||||
|
||||
// write function, should use at/near construction
|
||||
void input_buffer::assign(const byte* t, uint s)
|
||||
{
|
||||
check(current_, get_capacity());
|
||||
add_size(s);
|
||||
memcpy(&buffer_[current_], t, s);
|
||||
}
|
||||
|
||||
|
||||
// use read to query input, adjusts current
|
||||
void input_buffer::read(byte* dst, uint length)
|
||||
{
|
||||
check(current_ + length - 1, size_);
|
||||
memcpy(dst, &buffer_[current_], length);
|
||||
current_ += length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* output_buffer operates like a smart c style array with a checking option.
|
||||
* Meant to be written to through [] with AUTO index or write().
|
||||
* Size (current) counter increases when written to. Can be constructed with
|
||||
* zero length buffer but be sure to allocate before first use.
|
||||
* Don't use add write for a couple bytes, use [] instead, way less overhead.
|
||||
*
|
||||
* Not using vector because need checked []access and the ability to
|
||||
* write to the buffer bulk wise and retain correct size
|
||||
*/
|
||||
|
||||
|
||||
output_buffer::output_buffer()
|
||||
: current_(0), buffer_(0), end_(0)
|
||||
{}
|
||||
|
||||
|
||||
// with allocate
|
||||
output_buffer::output_buffer(uint s)
|
||||
: current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
|
||||
{}
|
||||
|
||||
|
||||
// with assign
|
||||
output_buffer::output_buffer(uint s, const byte* t, uint len)
|
||||
: current_(0), buffer_(NEW_YS byte[s]), end_(buffer_+ s)
|
||||
{
|
||||
write(t, len);
|
||||
}
|
||||
|
||||
|
||||
output_buffer::~output_buffer()
|
||||
{
|
||||
ysArrayDelete(buffer_);
|
||||
}
|
||||
|
||||
|
||||
uint output_buffer::get_size() const
|
||||
{
|
||||
return current_;
|
||||
}
|
||||
|
||||
|
||||
uint output_buffer::get_capacity() const
|
||||
{
|
||||
return (uint) (end_ - buffer_);
|
||||
}
|
||||
|
||||
|
||||
void output_buffer::set_current(uint c)
|
||||
{
|
||||
check(c, get_capacity());
|
||||
current_ = c;
|
||||
}
|
||||
|
||||
|
||||
// users can pass defualt zero length buffer and then allocate
|
||||
void output_buffer::allocate(uint s)
|
||||
{
|
||||
assert(!buffer_); // find realloc error
|
||||
buffer_ = NEW_YS byte[s]; end_ = buffer_ + s;
|
||||
}
|
||||
|
||||
|
||||
// for passing to reading functions when finished
|
||||
const byte* output_buffer::get_buffer() const
|
||||
{
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
|
||||
// allow write access through [], update current
|
||||
// user passes in AUTO as index for ease of use
|
||||
byte& output_buffer::operator[](uint i)
|
||||
{
|
||||
assert(i == AUTO);
|
||||
check(current_, get_capacity());
|
||||
return buffer_[current_++];
|
||||
}
|
||||
|
||||
|
||||
// end of output test
|
||||
bool output_buffer::eof()
|
||||
{
|
||||
return current_ >= get_capacity();
|
||||
}
|
||||
|
||||
|
||||
void output_buffer::write(const byte* t, uint s)
|
||||
{
|
||||
check(current_ + s - 1, get_capacity());
|
||||
memcpy(&buffer_[current_], t, s);
|
||||
current_ += s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
@@ -1,370 +0,0 @@
|
||||
/*
|
||||
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* The certificate wrapper source implements certificate management functions
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "cert_wrapper.hpp"
|
||||
#include "yassl_int.hpp"
|
||||
#include "error.hpp"
|
||||
|
||||
#if defined(USE_CML_LIB)
|
||||
#include "cmapi_cpp.h"
|
||||
#else
|
||||
#include "asn.hpp"
|
||||
#include "file.hpp"
|
||||
#endif // USE_CML_LIB
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
x509::x509(uint sz) : length_(sz), buffer_(NEW_YS opaque[sz])
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
x509::~x509()
|
||||
{
|
||||
ysArrayDelete(buffer_);
|
||||
}
|
||||
|
||||
|
||||
x509::x509(const x509& that) : length_(that.length_),
|
||||
buffer_(NEW_YS opaque[length_])
|
||||
{
|
||||
memcpy(buffer_, that.buffer_, length_);
|
||||
}
|
||||
|
||||
|
||||
void x509::Swap(x509& that)
|
||||
{
|
||||
STL::swap(length_, that.length_);
|
||||
STL::swap(buffer_, that.buffer_);
|
||||
}
|
||||
|
||||
|
||||
x509& x509::operator=(const x509& that)
|
||||
{
|
||||
x509 temp(that);
|
||||
Swap(temp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
uint x509::get_length() const
|
||||
{
|
||||
return length_;
|
||||
}
|
||||
|
||||
|
||||
const opaque* x509::get_buffer() const
|
||||
{
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
|
||||
opaque* x509::use_buffer()
|
||||
{
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
|
||||
//CertManager
|
||||
CertManager::CertManager()
|
||||
: peerX509_(0), verifyPeer_(false), verifyNone_(false), failNoCert_(false),
|
||||
sendVerify_(false), verifyCallback_(0)
|
||||
{}
|
||||
|
||||
|
||||
CertManager::~CertManager()
|
||||
{
|
||||
ysDelete(peerX509_);
|
||||
|
||||
STL::for_each(signers_.begin(), signers_.end(), del_ptr_zero()) ;
|
||||
|
||||
STL::for_each(peerList_.begin(), peerList_.end(), del_ptr_zero()) ;
|
||||
|
||||
STL::for_each(list_.begin(), list_.end(), del_ptr_zero()) ;
|
||||
}
|
||||
|
||||
|
||||
bool CertManager::verifyPeer() const
|
||||
{
|
||||
return verifyPeer_;
|
||||
}
|
||||
|
||||
|
||||
bool CertManager::verifyNone() const
|
||||
{
|
||||
return verifyNone_;
|
||||
}
|
||||
|
||||
|
||||
bool CertManager::failNoCert() const
|
||||
{
|
||||
return failNoCert_;
|
||||
}
|
||||
|
||||
|
||||
bool CertManager::sendVerify() const
|
||||
{
|
||||
return sendVerify_;
|
||||
}
|
||||
|
||||
|
||||
void CertManager::setVerifyPeer()
|
||||
{
|
||||
verifyPeer_ = true;
|
||||
}
|
||||
|
||||
|
||||
void CertManager::setVerifyNone()
|
||||
{
|
||||
verifyNone_ = true;
|
||||
}
|
||||
|
||||
|
||||
void CertManager::setFailNoCert()
|
||||
{
|
||||
failNoCert_ = true;
|
||||
}
|
||||
|
||||
|
||||
void CertManager::setSendVerify()
|
||||
{
|
||||
sendVerify_ = true;
|
||||
}
|
||||
|
||||
|
||||
void CertManager::setVerifyCallback(VerifyCallback vc)
|
||||
{
|
||||
verifyCallback_ = vc;
|
||||
}
|
||||
|
||||
|
||||
void CertManager::AddPeerCert(x509* x)
|
||||
{
|
||||
peerList_.push_back(x); // take ownership
|
||||
}
|
||||
|
||||
|
||||
void CertManager::CopySelfCert(const x509* x)
|
||||
{
|
||||
if (x)
|
||||
list_.push_back(NEW_YS x509(*x));
|
||||
}
|
||||
|
||||
|
||||
// add to signers
|
||||
int CertManager::CopyCaCert(const x509* x)
|
||||
{
|
||||
TaoCrypt::Source source(x->get_buffer(), x->get_length());
|
||||
TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_,
|
||||
TaoCrypt::CertDecoder::CA);
|
||||
|
||||
if (!cert.GetError().What()) {
|
||||
const TaoCrypt::PublicKey& key = cert.GetPublicKey();
|
||||
signers_.push_back(NEW_YS TaoCrypt::Signer(key.GetKey(), key.size(),
|
||||
cert.GetCommonName(), cert.GetHash()));
|
||||
}
|
||||
// just don't add, not an error return cert.GetError().What();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const x509* CertManager::get_cert() const
|
||||
{
|
||||
return list_.front();
|
||||
}
|
||||
|
||||
|
||||
const opaque* CertManager::get_peerKey() const
|
||||
{
|
||||
return peerPublicKey_.get_buffer();
|
||||
}
|
||||
|
||||
|
||||
X509* CertManager::get_peerX509() const
|
||||
{
|
||||
return peerX509_;
|
||||
}
|
||||
|
||||
|
||||
SignatureAlgorithm CertManager::get_peerKeyType() const
|
||||
{
|
||||
return peerKeyType_;
|
||||
}
|
||||
|
||||
|
||||
SignatureAlgorithm CertManager::get_keyType() const
|
||||
{
|
||||
return keyType_;
|
||||
}
|
||||
|
||||
|
||||
uint CertManager::get_peerKeyLength() const
|
||||
{
|
||||
return peerPublicKey_.get_size();
|
||||
}
|
||||
|
||||
|
||||
const opaque* CertManager::get_privateKey() const
|
||||
{
|
||||
return privateKey_.get_buffer();
|
||||
}
|
||||
|
||||
|
||||
uint CertManager::get_privateKeyLength() const
|
||||
{
|
||||
return privateKey_.get_size();
|
||||
}
|
||||
|
||||
|
||||
// Validate the peer's certificate list, from root to peer (last to first)
|
||||
int CertManager::Validate()
|
||||
{
|
||||
CertList::reverse_iterator last = peerList_.rbegin();
|
||||
size_t count = peerList_.size();
|
||||
|
||||
while ( count > 1 ) {
|
||||
TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());
|
||||
TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
|
||||
|
||||
if (int err = cert.GetError().What())
|
||||
return err;
|
||||
|
||||
const TaoCrypt::PublicKey& key = cert.GetPublicKey();
|
||||
signers_.push_back(NEW_YS TaoCrypt::Signer(key.GetKey(), key.size(),
|
||||
cert.GetCommonName(), cert.GetHash()));
|
||||
++last;
|
||||
--count;
|
||||
}
|
||||
|
||||
if (count) {
|
||||
// peer's is at the front
|
||||
TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());
|
||||
TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);
|
||||
|
||||
int err = cert.GetError().What();
|
||||
if ( err )
|
||||
return err;
|
||||
|
||||
uint sz = cert.GetPublicKey().size();
|
||||
peerPublicKey_.allocate(sz);
|
||||
peerPublicKey_.assign(cert.GetPublicKey().GetKey(), sz);
|
||||
|
||||
if (cert.GetKeyType() == TaoCrypt::RSAk)
|
||||
peerKeyType_ = rsa_sa_algo;
|
||||
else
|
||||
peerKeyType_ = dsa_sa_algo;
|
||||
|
||||
size_t iSz = strlen(cert.GetIssuer()) + 1;
|
||||
size_t sSz = strlen(cert.GetCommonName()) + 1;
|
||||
int bSz = (int)strlen(cert.GetBeforeDate()) + 1;
|
||||
int aSz = (int)strlen(cert.GetAfterDate()) + 1;
|
||||
peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(),
|
||||
sSz, cert.GetBeforeDate(), bSz,
|
||||
cert.GetAfterDate(), aSz);
|
||||
|
||||
if (err == TaoCrypt::SIG_OTHER_E && verifyCallback_) {
|
||||
X509_STORE_CTX store;
|
||||
store.error = err;
|
||||
store.error_depth = static_cast<int>(count) - 1;
|
||||
store.current_cert = peerX509_;
|
||||
|
||||
int ok = verifyCallback_(0, &store);
|
||||
if (ok) return 0;
|
||||
}
|
||||
|
||||
if (err == TaoCrypt::SIG_OTHER_E) return err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Set the private key
|
||||
int CertManager::SetPrivateKey(const x509& key)
|
||||
{
|
||||
privateKey_.allocate(key.get_length());
|
||||
privateKey_.assign(key.get_buffer(), key.get_length());
|
||||
|
||||
// set key type
|
||||
if (x509* cert = list_.front()) {
|
||||
TaoCrypt::Source source(cert->get_buffer(), cert->get_length());
|
||||
TaoCrypt::CertDecoder cd(source, false);
|
||||
cd.DecodeToKey();
|
||||
if (int err = cd.GetError().What())
|
||||
return err;
|
||||
if (cd.GetKeyType() == TaoCrypt::RSAk)
|
||||
keyType_ = rsa_sa_algo;
|
||||
else
|
||||
keyType_ = dsa_sa_algo;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Store OpenSSL type peer's cert
|
||||
void CertManager::setPeerX509(X509* x)
|
||||
{
|
||||
assert(peerX509_ == 0);
|
||||
if (x == 0) return;
|
||||
|
||||
X509_NAME* issuer = x->GetIssuer();
|
||||
X509_NAME* subject = x->GetSubject();
|
||||
ASN1_STRING* before = x->GetBefore();
|
||||
ASN1_STRING* after = x->GetAfter();
|
||||
|
||||
peerX509_ = NEW_YS X509(issuer->GetName(), issuer->GetLength(),
|
||||
subject->GetName(), subject->GetLength(), (const char*) before->data,
|
||||
before->length, (const char*) after->data, after->length);
|
||||
}
|
||||
|
||||
|
||||
#if defined(USE_CML_LIB)
|
||||
|
||||
// Get the peer's certificate, extract and save public key
|
||||
void CertManager::SetPeerKey()
|
||||
{
|
||||
// first cert is the peer's
|
||||
x509* main = peerList_.front();
|
||||
|
||||
Bytes_struct cert;
|
||||
cert.num = main->get_length();
|
||||
cert.data = main->set_buffer();
|
||||
|
||||
CML::Certificate cm(cert);
|
||||
const CML::ASN::Cert& raw = cm.base();
|
||||
CTIL::CSM_Buffer key = raw.pubKeyInfo.key;
|
||||
|
||||
uint sz;
|
||||
opaque* key_buffer = reinterpret_cast<opaque*>(key.Get(sz));
|
||||
peerPublicKey_.allocate(sz);
|
||||
peerPublicKey_.assign(key_buffer, sz);
|
||||
}
|
||||
|
||||
|
||||
#endif // USE_CML_LIB
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* Locking functions
|
||||
*/
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "lock.hpp"
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
#ifdef YASSL_THREAD_SAFE
|
||||
#ifdef _WIN32
|
||||
|
||||
Mutex::Mutex()
|
||||
{
|
||||
InitializeCriticalSection(&cs_);
|
||||
}
|
||||
|
||||
|
||||
Mutex::~Mutex()
|
||||
{
|
||||
DeleteCriticalSection(&cs_);
|
||||
}
|
||||
|
||||
|
||||
Mutex::Lock::Lock(Mutex& lm) : mutex_(lm)
|
||||
{
|
||||
EnterCriticalSection(&mutex_.cs_);
|
||||
}
|
||||
|
||||
|
||||
Mutex::Lock::~Lock()
|
||||
{
|
||||
LeaveCriticalSection(&mutex_.cs_);
|
||||
}
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
Mutex::Mutex()
|
||||
{
|
||||
pthread_mutex_init(&mutex_, 0);
|
||||
}
|
||||
|
||||
|
||||
Mutex::~Mutex()
|
||||
{
|
||||
pthread_mutex_destroy(&mutex_);
|
||||
}
|
||||
|
||||
|
||||
Mutex::Lock::Lock(Mutex& lm) : mutex_(lm)
|
||||
{
|
||||
pthread_mutex_lock(&mutex_.mutex_);
|
||||
}
|
||||
|
||||
|
||||
Mutex::Lock::~Lock()
|
||||
{
|
||||
pthread_mutex_unlock(&mutex_.mutex_);
|
||||
}
|
||||
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // YASSL_THREAD_SAFE
|
||||
|
||||
|
||||
|
||||
} // namespace yaSSL
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* Debug logging functions
|
||||
*/
|
||||
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
#ifdef YASSL_LOG
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
#ifdef YASSL_LOG
|
||||
|
||||
enum { MAX_MSG = 81 };
|
||||
|
||||
Log::Log(const char* str)
|
||||
{
|
||||
log_ = fopen(str, "w");
|
||||
Trace("********** Logger Attached **********");
|
||||
}
|
||||
|
||||
|
||||
Log::~Log()
|
||||
{
|
||||
Trace("********** Logger Detached **********");
|
||||
fclose(log_);
|
||||
}
|
||||
|
||||
|
||||
// Trace a message
|
||||
void Log::Trace(const char* str)
|
||||
{
|
||||
if (!log_) return;
|
||||
|
||||
time_t clicks = time(0);
|
||||
char timeStr[32];
|
||||
|
||||
// get rid of newline
|
||||
strncpy(timeStr, ctime(&clicks), sizeof(timeStr));
|
||||
unsigned int len = strlen(timeStr);
|
||||
timeStr[len - 1] = 0;
|
||||
|
||||
char msg[MAX_MSG];
|
||||
|
||||
strncpy(msg, timeStr, sizeof(timeStr));
|
||||
strncat(msg, ":", 1);
|
||||
strncat(msg, str, MAX_MSG - sizeof(timeStr) - 2);
|
||||
strncat(msg, "\n", 1);
|
||||
msg[MAX_MSG - 1] = 0;
|
||||
|
||||
fputs(msg, log_);
|
||||
}
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(__MACH__) || defined(__hpux__)
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
|
||||
|
||||
// write tcp address
|
||||
void Log::ShowTCP(socket_t fd, bool ended)
|
||||
{
|
||||
sockaddr_in peeraddr;
|
||||
socklen_t len = sizeof(peeraddr);
|
||||
if (getpeername(fd, (sockaddr*)&peeraddr, &len) != 0)
|
||||
return;
|
||||
|
||||
const char* p = reinterpret_cast<const char*>(&peeraddr.sin_addr);
|
||||
char msg[MAX_MSG];
|
||||
char number[16];
|
||||
|
||||
if (ended)
|
||||
strncpy(msg, "yaSSL conn DONE w/ peer ", 26);
|
||||
else
|
||||
strncpy(msg, "yaSSL conn BEGUN w/ peer ", 26);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
sprintf(number, "%u", static_cast<unsigned short>(p[i]));
|
||||
strncat(msg, number, 8);
|
||||
if (i < 3)
|
||||
strncat(msg, ".", 1);
|
||||
}
|
||||
strncat(msg, " port ", 8);
|
||||
sprintf(number, "%d", htons(peeraddr.sin_port));
|
||||
strncat(msg, number, 8);
|
||||
|
||||
msg[MAX_MSG - 1] = 0;
|
||||
Trace(msg);
|
||||
}
|
||||
|
||||
|
||||
// log processed data
|
||||
void Log::ShowData(uint bytes, bool sent)
|
||||
{
|
||||
char msg[MAX_MSG];
|
||||
char number[16];
|
||||
|
||||
if (sent)
|
||||
strncpy(msg, "Sent ", 10);
|
||||
else
|
||||
strncpy(msg, "Received ", 10);
|
||||
sprintf(number, "%u", bytes);
|
||||
strncat(msg, number, 8);
|
||||
strncat(msg, " bytes of application data", 27);
|
||||
|
||||
msg[MAX_MSG - 1] = 0;
|
||||
Trace(msg);
|
||||
}
|
||||
|
||||
|
||||
#else // no YASSL_LOG
|
||||
|
||||
|
||||
Log::Log(const char*) {}
|
||||
Log::~Log() {}
|
||||
void Log::Trace(const char*) {}
|
||||
void Log::ShowTCP(socket_t, bool) {}
|
||||
void Log::ShowData(uint, bool) {}
|
||||
|
||||
|
||||
#endif // YASSL_LOG
|
||||
} // namespace
|
||||
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* The socket wrapper source implements a Socket class that hides the
|
||||
* differences between Berkely style sockets and Windows sockets, allowing
|
||||
* transparent TCP access.
|
||||
*/
|
||||
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "socket_wrapper.hpp"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#endif // _WIN32
|
||||
|
||||
#if defined(__sun) || defined(__SCO_VERSION__) || defined(__NETWARE__)
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
const int SOCKET_EINVAL = WSAEINVAL;
|
||||
const int SOCKET_EWOULDBLOCK = WSAEWOULDBLOCK;
|
||||
const int SOCKET_EAGAIN = WSAEWOULDBLOCK;
|
||||
#else
|
||||
const int SOCKET_EINVAL = EINVAL;
|
||||
const int SOCKET_EWOULDBLOCK = EWOULDBLOCK;
|
||||
const int SOCKET_EAGAIN = EAGAIN;
|
||||
#endif // _WIN32
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
Socket::Socket(socket_t s)
|
||||
: socket_(s), wouldBlock_(false), nonBlocking_(false)
|
||||
{}
|
||||
|
||||
|
||||
void Socket::set_fd(socket_t s)
|
||||
{
|
||||
socket_ = s;
|
||||
}
|
||||
|
||||
|
||||
socket_t Socket::get_fd() const
|
||||
{
|
||||
return socket_;
|
||||
}
|
||||
|
||||
|
||||
Socket::~Socket()
|
||||
{
|
||||
// don't close automatically now
|
||||
}
|
||||
|
||||
|
||||
void Socket::closeSocket()
|
||||
{
|
||||
if (socket_ != INVALID_SOCKET) {
|
||||
#ifdef _WIN32
|
||||
closesocket(socket_);
|
||||
#else
|
||||
close(socket_);
|
||||
#endif
|
||||
socket_ = INVALID_SOCKET;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint Socket::get_ready() const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
unsigned long ready = 0;
|
||||
ioctlsocket(socket_, FIONREAD, &ready);
|
||||
#else
|
||||
/*
|
||||
64-bit Solaris requires the variable passed to
|
||||
FIONREAD be a 32-bit value.
|
||||
*/
|
||||
unsigned int ready = 0;
|
||||
ioctl(socket_, FIONREAD, &ready);
|
||||
#endif
|
||||
|
||||
return ready;
|
||||
}
|
||||
|
||||
|
||||
uint Socket::send(const byte* buf, unsigned int sz, int flags) const
|
||||
{
|
||||
const byte* pos = buf;
|
||||
const byte* end = pos + sz;
|
||||
|
||||
while (pos != end) {
|
||||
int sent = ::send(socket_, reinterpret_cast<const char *>(pos),
|
||||
static_cast<int>(end - pos), flags);
|
||||
|
||||
if (sent == -1)
|
||||
return 0;
|
||||
|
||||
pos += sent;
|
||||
}
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
uint Socket::receive(byte* buf, unsigned int sz, int flags)
|
||||
{
|
||||
wouldBlock_ = false;
|
||||
|
||||
int recvd = ::recv(socket_, reinterpret_cast<char *>(buf), sz, flags);
|
||||
|
||||
// idea to seperate error from would block by arnetheduck@gmail.com
|
||||
if (recvd == -1) {
|
||||
if (get_lastError() == SOCKET_EWOULDBLOCK ||
|
||||
get_lastError() == SOCKET_EAGAIN) {
|
||||
wouldBlock_ = true; // would have blocked this time only
|
||||
nonBlocking_ = true; // socket nonblocking, win32 only way to tell
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (recvd == 0)
|
||||
return static_cast<uint>(-1);
|
||||
|
||||
return recvd;
|
||||
}
|
||||
|
||||
|
||||
// wait if blocking for input, return false for error
|
||||
bool Socket::wait()
|
||||
{
|
||||
byte b;
|
||||
return receive(&b, 1, MSG_PEEK) != static_cast<uint>(-1);
|
||||
}
|
||||
|
||||
|
||||
void Socket::shutDown(int how)
|
||||
{
|
||||
shutdown(socket_, how);
|
||||
}
|
||||
|
||||
|
||||
int Socket::get_lastError()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return WSAGetLastError();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool Socket::WouldBlock() const
|
||||
{
|
||||
return wouldBlock_;
|
||||
}
|
||||
|
||||
|
||||
bool Socket::IsNonBlocking() const
|
||||
{
|
||||
return nonBlocking_;
|
||||
}
|
||||
|
||||
|
||||
void Socket::set_lastError(int errorCode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WSASetLastError(errorCode);
|
||||
#else
|
||||
errno = errorCode;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* timer.cpp implements a high res and low res timer
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "timer.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
timer_d timer()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
uint lowResTimer()
|
||||
{
|
||||
return static_cast<uint>(timer());
|
||||
}
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
timer_d timer()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
|
||||
return static_cast<double>(tv.tv_sec)
|
||||
+ static_cast<double>(tv.tv_usec) / 1000000;
|
||||
}
|
||||
|
||||
|
||||
uint lowResTimer()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
|
||||
return tv.tv_sec;
|
||||
}
|
||||
|
||||
|
||||
#endif // _WIN32
|
||||
} // namespace yaSSL
|
||||
@@ -1,275 +0,0 @@
|
||||
/*
|
||||
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* yaSSL error implements and an exception class
|
||||
*/
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "yassl_error.hpp"
|
||||
#include "error.hpp" // TaoCrypt error numbers
|
||||
#include "openssl/ssl.h" // SSL_ERROR_WANT_READ
|
||||
#include <string.h> // strncpy
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
|
||||
#pragma warning(disable: 4996)
|
||||
#endif
|
||||
|
||||
namespace yaSSL {
|
||||
|
||||
|
||||
/* may bring back in future
|
||||
Error::Error(const char* s, YasslError e, Library l)
|
||||
: mySTL::runtime_error(s), error_(e), lib_(l)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
YasslError Error::get_number() const
|
||||
{
|
||||
return error_;
|
||||
}
|
||||
|
||||
|
||||
Library Error::get_lib() const
|
||||
{
|
||||
|
||||
return lib_;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void SetErrorString(unsigned long 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;
|
||||
|
||||
case privateKey_error :
|
||||
strncpy(buffer, "unable to proccess private key, bad format", max);
|
||||
break;
|
||||
|
||||
case badVersion_error :
|
||||
strncpy(buffer, "protocl version mismatch", max);
|
||||
break;
|
||||
|
||||
case compress_error :
|
||||
strncpy(buffer, "compression error", max);
|
||||
break;
|
||||
|
||||
case decompress_error :
|
||||
strncpy(buffer, "decompression error", max);
|
||||
break;
|
||||
|
||||
case pms_version_error :
|
||||
strncpy(buffer, "bad PreMasterSecret version error", max);
|
||||
break;
|
||||
|
||||
// openssl errors
|
||||
case SSL_ERROR_WANT_READ :
|
||||
strncpy(buffer, "the read operation would block", max);
|
||||
break;
|
||||
|
||||
case CERTFICATE_ERROR :
|
||||
strncpy(buffer, "Unable to verify certificate", max);
|
||||
break;
|
||||
|
||||
// TaoCrypt errors
|
||||
case NO_ERROR_E :
|
||||
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;
|
||||
|
||||
case CONTENT_E :
|
||||
strncpy(buffer, "bad content processing", max);
|
||||
break;
|
||||
|
||||
case PEM_E :
|
||||
strncpy(buffer, "bad PEM format processing", max);
|
||||
break;
|
||||
|
||||
default :
|
||||
strncpy(buffer, "unknown error number", max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace yaSSL
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,340 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
@@ -1,229 +0,0 @@
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
TaoCrypt release 0.9.2 02/5/2007
|
||||
|
||||
|
||||
This release includes bug fixes, portability enhancements, and some
|
||||
optimiations.
|
||||
|
||||
See 0.9.0 for build instructions.
|
||||
|
||||
|
||||
|
||||
|
||||
******************TaoCrypt release 0.9.0 09/18/2006
|
||||
|
||||
This is the first release of TaoCrypt, it was previously only included with
|
||||
yaSSL. TaoCrypt is highly portable and fast, its features include:
|
||||
|
||||
One way hash functions: SHA-1, MD2, MD4, MD5, RIPEMD-160
|
||||
Message authentication codes: HMAC
|
||||
Block Ciphers: DES, Triple-DES, AES, Blowfish, Twofish
|
||||
Stream Ciphers: ARC4
|
||||
Public Key Crypto: RSA, DSA, Diffie-Hellman
|
||||
Password based key derivation: PBKDF2 from PKCS #5
|
||||
Pseudo Random Number Generators
|
||||
Lare Integer Support
|
||||
Base 16/64 encoding/decoding
|
||||
DER encoding/decoding
|
||||
X.509 processing
|
||||
SSE2 and ia32 asm for the right processors and compilers
|
||||
|
||||
|
||||
To build on Unix
|
||||
|
||||
./configure
|
||||
make
|
||||
|
||||
To test the build, from the ./test directory run ./test
|
||||
|
||||
|
||||
On Windows
|
||||
|
||||
Open the taocrypt project workspace
|
||||
Choose (Re)Build All
|
||||
|
||||
To test the build, run the test executable
|
||||
|
||||
|
||||
Please send any questions or comments to todd@yassl.com.
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* aes.hpp defines AES
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_AES_HPP
|
||||
#define TAO_CRYPT_AES_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "modes.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_AES_ASM
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
enum { AES_BLOCK_SIZE = 16 };
|
||||
|
||||
|
||||
// AES encryption and decryption, see FIPS-197
|
||||
class AES : public Mode_BASE {
|
||||
public:
|
||||
enum { BLOCK_SIZE = AES_BLOCK_SIZE };
|
||||
|
||||
AES(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(BLOCK_SIZE, DIR, MODE) {}
|
||||
|
||||
#ifdef DO_AES_ASM
|
||||
void Process(byte*, const byte*, word32);
|
||||
#endif
|
||||
void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION);
|
||||
void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }
|
||||
private:
|
||||
static const word32 rcon_[];
|
||||
|
||||
word32 rounds_;
|
||||
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 AsmEncrypt(const byte*, byte*, void*) 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& operator=(const AES&); // and assign
|
||||
};
|
||||
|
||||
|
||||
typedef BlockCipher<ENCRYPTION, AES, ECB> AES_ECB_Encryption;
|
||||
typedef BlockCipher<DECRYPTION, AES, ECB> AES_ECB_Decryption;
|
||||
|
||||
typedef BlockCipher<ENCRYPTION, AES, CBC> AES_CBC_Encryption;
|
||||
typedef BlockCipher<DECRYPTION, AES, CBC> AES_CBC_Decryption;
|
||||
|
||||
|
||||
|
||||
} // naemspace
|
||||
|
||||
#endif // TAO_CRYPT_AES_HPP
|
||||
@@ -1,226 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* based on Wei Dai's algebra.h from CryptoPP */
|
||||
|
||||
#ifndef TAO_CRYPT_ALGEBRA_HPP
|
||||
#define TAO_CRYPT_ALGEBRA_HPP
|
||||
|
||||
#include "integer.hpp"
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// "const Element&" returned by member functions are references
|
||||
// to internal data members. Since each object may have only
|
||||
// one such data member for holding results, the following code
|
||||
// will produce incorrect results:
|
||||
// abcd = group.Add(group.Add(a,b), group.Add(c,d));
|
||||
// But this should be fine:
|
||||
// abcd = group.Add(a, group.Add(b, group.Add(c,d));
|
||||
|
||||
// Abstract Group
|
||||
class TAOCRYPT_NO_VTABLE AbstractGroup : public virtual_base
|
||||
{
|
||||
public:
|
||||
typedef Integer Element;
|
||||
|
||||
virtual ~AbstractGroup() {}
|
||||
|
||||
virtual bool Equal(const Element &a, const Element &b) const =0;
|
||||
virtual const Element& Identity() const =0;
|
||||
virtual const Element& Add(const Element &a, const Element &b) const =0;
|
||||
virtual const Element& Inverse(const Element &a) const =0;
|
||||
virtual bool InversionIsFast() const {return false;}
|
||||
|
||||
virtual const Element& Double(const Element &a) const;
|
||||
virtual const Element& Subtract(const Element &a, const Element &b) const;
|
||||
virtual Element& Accumulate(Element &a, const Element &b) const;
|
||||
virtual Element& Reduce(Element &a, const Element &b) const;
|
||||
|
||||
virtual Element ScalarMultiply(const Element &a, const Integer &e) const;
|
||||
virtual Element CascadeScalarMultiply(const Element &x, const Integer &e1,
|
||||
const Element &y, const Integer &e2) const;
|
||||
|
||||
virtual void SimultaneousMultiply(Element *results, const Element &base,
|
||||
const Integer *exponents, unsigned int exponentsCount) const;
|
||||
};
|
||||
|
||||
// Abstract Ring
|
||||
class TAOCRYPT_NO_VTABLE AbstractRing : public AbstractGroup
|
||||
{
|
||||
public:
|
||||
typedef Integer Element;
|
||||
|
||||
AbstractRing() : AbstractGroup() {m_mg.m_pRing = this;}
|
||||
AbstractRing(const AbstractRing &source) : AbstractGroup()
|
||||
{m_mg.m_pRing = this;}
|
||||
AbstractRing& operator=(const AbstractRing &source) {return *this;}
|
||||
|
||||
virtual bool IsUnit(const Element &a) const =0;
|
||||
virtual const Element& MultiplicativeIdentity() const =0;
|
||||
virtual const Element& Multiply(const Element&, const Element&) const =0;
|
||||
virtual const Element& MultiplicativeInverse(const Element &a) const =0;
|
||||
|
||||
virtual const Element& Square(const Element &a) const;
|
||||
virtual const Element& Divide(const Element &a, const Element &b) const;
|
||||
|
||||
virtual Element Exponentiate(const Element &a, const Integer &e) const;
|
||||
virtual Element CascadeExponentiate(const Element &x, const Integer &e1,
|
||||
const Element &y, const Integer &e2) const;
|
||||
|
||||
virtual void SimultaneousExponentiate(Element *results, const Element&,
|
||||
const Integer *exponents, unsigned int exponentsCount) const;
|
||||
|
||||
virtual const AbstractGroup& MultiplicativeGroup() const
|
||||
{return m_mg;}
|
||||
|
||||
private:
|
||||
class MultiplicativeGroupT : public AbstractGroup
|
||||
{
|
||||
public:
|
||||
const AbstractRing& GetRing() const
|
||||
{return *m_pRing;}
|
||||
|
||||
bool Equal(const Element &a, const Element &b) const
|
||||
{return GetRing().Equal(a, b);}
|
||||
|
||||
const Element& Identity() const
|
||||
{return GetRing().MultiplicativeIdentity();}
|
||||
|
||||
const Element& Add(const Element &a, const Element &b) const
|
||||
{return GetRing().Multiply(a, b);}
|
||||
|
||||
Element& Accumulate(Element &a, const Element &b) const
|
||||
{return a = GetRing().Multiply(a, b);}
|
||||
|
||||
const Element& Inverse(const Element &a) const
|
||||
{return GetRing().MultiplicativeInverse(a);}
|
||||
|
||||
const Element& Subtract(const Element &a, const Element &b) const
|
||||
{return GetRing().Divide(a, b);}
|
||||
|
||||
Element& Reduce(Element &a, const Element &b) const
|
||||
{return a = GetRing().Divide(a, b);}
|
||||
|
||||
const Element& Double(const Element &a) const
|
||||
{return GetRing().Square(a);}
|
||||
|
||||
Element ScalarMultiply(const Element &a, const Integer &e) const
|
||||
{return GetRing().Exponentiate(a, e);}
|
||||
|
||||
Element CascadeScalarMultiply(const Element &x, const Integer &e1,
|
||||
const Element &y, const Integer &e2) const
|
||||
{return GetRing().CascadeExponentiate(x, e1, y, e2);}
|
||||
|
||||
void SimultaneousMultiply(Element *results, const Element &base,
|
||||
const Integer *exponents, unsigned int exponentsCount) const
|
||||
{GetRing().SimultaneousExponentiate(results, base, exponents,
|
||||
exponentsCount);}
|
||||
|
||||
const AbstractRing* m_pRing;
|
||||
};
|
||||
|
||||
MultiplicativeGroupT m_mg;
|
||||
};
|
||||
|
||||
|
||||
// Abstract Euclidean Domain
|
||||
class TAOCRYPT_NO_VTABLE AbstractEuclideanDomain
|
||||
: public AbstractRing
|
||||
{
|
||||
public:
|
||||
typedef Integer Element;
|
||||
|
||||
virtual void DivisionAlgorithm(Element &r, Element &q, const Element &a,
|
||||
const Element &d) const =0;
|
||||
|
||||
virtual const Element& Mod(const Element &a, const Element &b) const =0;
|
||||
virtual const Element& Gcd(const Element &a, const Element &b) const;
|
||||
|
||||
protected:
|
||||
mutable Element result;
|
||||
};
|
||||
|
||||
|
||||
// EuclideanDomainOf
|
||||
class EuclideanDomainOf : public AbstractEuclideanDomain
|
||||
{
|
||||
public:
|
||||
typedef Integer Element;
|
||||
|
||||
EuclideanDomainOf() {}
|
||||
|
||||
bool Equal(const Element &a, const Element &b) const
|
||||
{return a==b;}
|
||||
|
||||
const Element& Identity() const
|
||||
{return Element::Zero();}
|
||||
|
||||
const Element& Add(const Element &a, const Element &b) const
|
||||
{return result = a+b;}
|
||||
|
||||
Element& Accumulate(Element &a, const Element &b) const
|
||||
{return a+=b;}
|
||||
|
||||
const Element& Inverse(const Element &a) const
|
||||
{return result = -a;}
|
||||
|
||||
const Element& Subtract(const Element &a, const Element &b) const
|
||||
{return result = a-b;}
|
||||
|
||||
Element& Reduce(Element &a, const Element &b) const
|
||||
{return a-=b;}
|
||||
|
||||
const Element& Double(const Element &a) const
|
||||
{return result = a.Doubled();}
|
||||
|
||||
const Element& MultiplicativeIdentity() const
|
||||
{return Element::One();}
|
||||
|
||||
const Element& Multiply(const Element &a, const Element &b) const
|
||||
{return result = a*b;}
|
||||
|
||||
const Element& Square(const Element &a) const
|
||||
{return result = a.Squared();}
|
||||
|
||||
bool IsUnit(const Element &a) const
|
||||
{return a.IsUnit();}
|
||||
|
||||
const Element& MultiplicativeInverse(const Element &a) const
|
||||
{return result = a.MultiplicativeInverse();}
|
||||
|
||||
const Element& Divide(const Element &a, const Element &b) const
|
||||
{return result = a/b;}
|
||||
|
||||
const Element& Mod(const Element &a, const Element &b) const
|
||||
{return result = a%b;}
|
||||
|
||||
void DivisionAlgorithm(Element &r, Element &q, const Element &a,
|
||||
const Element &d) const
|
||||
{Element::Divide(r, q, a, d);}
|
||||
|
||||
private:
|
||||
mutable Element result;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_ALGEBRA_HPP
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* arc4.hpp defines ARC4
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_ARC4_HPP
|
||||
#define TAO_CRYPT_ARC4_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// ARC4 encryption and decryption
|
||||
class ARC4 {
|
||||
public:
|
||||
enum { STATE_SIZE = 256 };
|
||||
|
||||
typedef ARC4 Encryption;
|
||||
typedef ARC4 Decryption;
|
||||
|
||||
ARC4() {}
|
||||
|
||||
void Process(byte*, const byte*, word32);
|
||||
void SetKey(const byte*, word32);
|
||||
private:
|
||||
byte x_;
|
||||
byte y_;
|
||||
byte state_[STATE_SIZE];
|
||||
|
||||
ARC4(const ARC4&); // hide copy
|
||||
const ARC4 operator=(const ARC4&); // and assign
|
||||
|
||||
void AsmProcess(byte*, const byte*, word32);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif // TAO_CRYPT_ARC4_HPP
|
||||
|
||||
@@ -1,373 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* asn.hpp provides ASN1 BER, PublicKey, and x509v3 decoding
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_ASN_HPP
|
||||
#define TAO_CRYPT_ASN_HPP
|
||||
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "block.hpp"
|
||||
#include "error.hpp"
|
||||
#ifdef USE_SYS_STL
|
||||
#include <list>
|
||||
#else
|
||||
#include "list.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
// these tags and flags are not complete
|
||||
enum ASNTag
|
||||
{
|
||||
BOOLEAN = 0x01,
|
||||
INTEGER = 0x02,
|
||||
BIT_STRING = 0x03,
|
||||
OCTET_STRING = 0x04,
|
||||
TAG_NULL = 0x05,
|
||||
OBJECT_IDENTIFIER = 0x06,
|
||||
OBJECT_DESCRIPTOR = 0x07,
|
||||
EXTERNAL = 0x08,
|
||||
REAL = 0x09,
|
||||
ENUMERATED = 0x0a,
|
||||
UTF8_STRING = 0x0c,
|
||||
SEQUENCE = 0x10,
|
||||
SET = 0x11,
|
||||
NUMERIC_STRING = 0x12,
|
||||
PRINTABLE_STRING = 0x13,
|
||||
T61_STRING = 0x14,
|
||||
VIDEOTEXT_STRING = 0x15,
|
||||
IA5_STRING = 0x16,
|
||||
UTC_TIME = 0x17,
|
||||
GENERALIZED_TIME = 0x18,
|
||||
GRAPHIC_STRING = 0x19,
|
||||
VISIBLE_STRING = 0x1a,
|
||||
GENERAL_STRING = 0x1b,
|
||||
LONG_LENGTH = 0x80
|
||||
};
|
||||
|
||||
enum ASNIdFlag
|
||||
{
|
||||
UNIVERSAL = 0x00,
|
||||
DATA = 0x01,
|
||||
HEADER = 0x02,
|
||||
CONSTRUCTED = 0x20,
|
||||
APPLICATION = 0x40,
|
||||
CONTEXT_SPECIFIC = 0x80,
|
||||
PRIVATE = 0xc0
|
||||
};
|
||||
|
||||
|
||||
enum DNTags
|
||||
{
|
||||
COMMON_NAME = 0x03, // CN
|
||||
SUR_NAME = 0x04, // SN
|
||||
COUNTRY_NAME = 0x06, // C
|
||||
LOCALITY_NAME = 0x07, // L
|
||||
STATE_NAME = 0x08, // ST
|
||||
ORG_NAME = 0x0a, // O
|
||||
ORGUNIT_NAME = 0x0b // OU
|
||||
};
|
||||
|
||||
|
||||
enum PCKS12_Tags
|
||||
{
|
||||
/* DATA = 1, */ // from ASN1
|
||||
SIGNED_DATA = 2,
|
||||
ENVELOPED_DATA = 3,
|
||||
SIGNED_AND_ENVELOPED_DATA = 4,
|
||||
DIGESTED_DATA = 5,
|
||||
ENCRYPTED_DATA = 6
|
||||
};
|
||||
|
||||
|
||||
enum Constants
|
||||
{
|
||||
MIN_DATE_SZ = 13,
|
||||
MAX_DATE_SZ = 16,
|
||||
MAX_ALGO_SZ = 16,
|
||||
MAX_LENGTH_SZ = 5,
|
||||
MAX_SEQ_SZ = 5, // enum(seq|con) + length(4)
|
||||
MAX_ALGO_SIZE = 9,
|
||||
MAX_DIGEST_SZ = 25, // SHA + enum(Bit or Octet) + length(4)
|
||||
DSA_SIG_SZ = 40,
|
||||
ASN_NAME_MAX = 512 // max total of all included names
|
||||
};
|
||||
|
||||
|
||||
class Source;
|
||||
class RSA_PublicKey;
|
||||
class RSA_PrivateKey;
|
||||
class DSA_PublicKey;
|
||||
class DSA_PrivateKey;
|
||||
class Integer;
|
||||
class DH;
|
||||
|
||||
|
||||
// General BER decoding
|
||||
class BER_Decoder : public virtual_base {
|
||||
protected:
|
||||
Source& source_;
|
||||
public:
|
||||
explicit BER_Decoder(Source& s) : source_(s) {}
|
||||
virtual ~BER_Decoder() {}
|
||||
|
||||
Integer& GetInteger(Integer&);
|
||||
word32 GetSequence();
|
||||
word32 GetSet();
|
||||
word32 GetVersion();
|
||||
word32 GetExplicitVersion();
|
||||
|
||||
Error GetError();
|
||||
private:
|
||||
virtual void ReadHeader() = 0;
|
||||
|
||||
BER_Decoder(const BER_Decoder&); // hide copy
|
||||
BER_Decoder& operator=(const BER_Decoder&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// RSA Private Key BER Decoder
|
||||
class RSA_Private_Decoder : public BER_Decoder {
|
||||
public:
|
||||
explicit RSA_Private_Decoder(Source& s) : BER_Decoder(s) {}
|
||||
void Decode(RSA_PrivateKey&);
|
||||
private:
|
||||
void ReadHeader();
|
||||
};
|
||||
|
||||
|
||||
// RSA Public Key BER Decoder
|
||||
class RSA_Public_Decoder : public BER_Decoder {
|
||||
public:
|
||||
explicit RSA_Public_Decoder(Source& s) : BER_Decoder(s) {}
|
||||
void Decode(RSA_PublicKey&);
|
||||
private:
|
||||
void ReadHeader();
|
||||
};
|
||||
|
||||
|
||||
// DSA Private Key BER Decoder
|
||||
class DSA_Private_Decoder : public BER_Decoder {
|
||||
public:
|
||||
explicit DSA_Private_Decoder(Source& s) : BER_Decoder(s) {}
|
||||
void Decode(DSA_PrivateKey&);
|
||||
private:
|
||||
void ReadHeader();
|
||||
};
|
||||
|
||||
|
||||
// DSA Public Key BER Decoder
|
||||
class DSA_Public_Decoder : public BER_Decoder {
|
||||
public:
|
||||
explicit DSA_Public_Decoder(Source& s) : BER_Decoder(s) {}
|
||||
void Decode(DSA_PublicKey&);
|
||||
private:
|
||||
void ReadHeader();
|
||||
};
|
||||
|
||||
|
||||
// DH Key BER Decoder
|
||||
class DH_Decoder : public BER_Decoder {
|
||||
public:
|
||||
explicit DH_Decoder(Source& s) : BER_Decoder(s) {}
|
||||
void Decode(DH&);
|
||||
private:
|
||||
void ReadHeader();
|
||||
};
|
||||
|
||||
|
||||
// PKCS12 BER Decoder
|
||||
class PKCS12_Decoder : public BER_Decoder {
|
||||
public:
|
||||
explicit PKCS12_Decoder(Source& s) : BER_Decoder(s) {}
|
||||
void Decode();
|
||||
private:
|
||||
void ReadHeader();
|
||||
};
|
||||
|
||||
|
||||
// General PublicKey
|
||||
class PublicKey {
|
||||
byte* key_;
|
||||
word32 sz_;
|
||||
public:
|
||||
explicit PublicKey(const byte* k = 0, word32 s = 0);
|
||||
~PublicKey() { tcArrayDelete(key_); }
|
||||
|
||||
const byte* GetKey() const { return key_; }
|
||||
word32 size() const { return sz_; }
|
||||
|
||||
void SetKey(const byte*);
|
||||
void SetSize(word32 s);
|
||||
|
||||
void AddToEnd(const byte*, word32);
|
||||
private:
|
||||
PublicKey(const PublicKey&); // hide copy
|
||||
PublicKey& operator=(const PublicKey&); // and assign
|
||||
};
|
||||
|
||||
|
||||
enum { SHA_SIZE = 20 };
|
||||
|
||||
|
||||
// A Signing Authority
|
||||
class Signer {
|
||||
PublicKey key_;
|
||||
char name_[ASN_NAME_MAX];
|
||||
byte hash_[SHA_SIZE];
|
||||
public:
|
||||
Signer(const byte* k, word32 kSz, const char* n, const byte* h);
|
||||
~Signer();
|
||||
|
||||
const PublicKey& GetPublicKey() const { return key_; }
|
||||
const char* GetName() const { return name_; }
|
||||
const byte* GetHash() const { return hash_; }
|
||||
|
||||
private:
|
||||
Signer(const Signer&); // hide copy
|
||||
Signer& operator=(const Signer&); // and assign
|
||||
};
|
||||
|
||||
|
||||
typedef STL::list<Signer*> SignerList;
|
||||
|
||||
|
||||
enum ContentType { HUH = 651 };
|
||||
enum SigType { SHAwDSA = 517, MD2wRSA = 646, MD5wRSA = 648, SHAwRSA =649};
|
||||
enum HashType { MD2h = 646, MD5h = 649, SHAh = 88 };
|
||||
enum KeyType { DSAk = 515, RSAk = 645 }; // sums of algo OID
|
||||
|
||||
|
||||
// an x509v Certificate BER Decoder
|
||||
class CertDecoder : public BER_Decoder {
|
||||
public:
|
||||
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();
|
||||
|
||||
const PublicKey& GetPublicKey() const { return key_; }
|
||||
KeyType GetKeyType() const { return KeyType(keyOID_); }
|
||||
const char* GetIssuer() const { return issuer_; }
|
||||
const char* GetCommonName() const { return subject_; }
|
||||
const byte* GetHash() const { return subjectHash_; }
|
||||
const char* GetBeforeDate() const { return beforeDate_; }
|
||||
const char* GetAfterDate() const { return afterDate_; }
|
||||
|
||||
void DecodeToKey();
|
||||
private:
|
||||
PublicKey key_;
|
||||
word32 certBegin_; // offset to start of cert
|
||||
word32 sigIndex_; // offset to start of signature
|
||||
word32 sigLength_; // length of signature
|
||||
word32 signatureOID_; // sum of algorithm object id
|
||||
word32 keyOID_; // sum of key algo object id
|
||||
byte subjectHash_[SHA_SIZE]; // hash of all Names
|
||||
byte issuerHash_[SHA_SIZE]; // hash of all Names
|
||||
byte* signature_;
|
||||
char issuer_[ASN_NAME_MAX]; // Names
|
||||
char subject_[ASN_NAME_MAX]; // Names
|
||||
char beforeDate_[MAX_DATE_SZ]; // valid before date
|
||||
char afterDate_[MAX_DATE_SZ]; // valid after date
|
||||
bool verify_; // Default to yes, but could be off
|
||||
|
||||
void ReadHeader();
|
||||
void Decode(SignerList*, CertType);
|
||||
void StoreKey();
|
||||
void AddDSA();
|
||||
bool ValidateSelfSignature();
|
||||
bool ValidateSignature(SignerList*);
|
||||
bool ConfirmSignature(Source&);
|
||||
void GetKey();
|
||||
char* AddTag(char*, const char*, const char*, word32, word32);
|
||||
void GetName(NameType);
|
||||
void GetValidity();
|
||||
void GetDate(DateType);
|
||||
void GetCompareHash(const byte*, word32, byte*, word32);
|
||||
word32 GetAlgoId();
|
||||
word32 GetSignature();
|
||||
word32 GetDigest();
|
||||
};
|
||||
|
||||
|
||||
word32 GetLength(Source&);
|
||||
|
||||
word32 SetLength(word32, byte*);
|
||||
word32 SetSequence(word32, byte*);
|
||||
|
||||
word32 EncodeDSA_Signature(const byte* signature, byte* output);
|
||||
word32 EncodeDSA_Signature(const Integer& r, const Integer& s, byte* output);
|
||||
word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz);
|
||||
|
||||
|
||||
// General DER encoding
|
||||
class DER_Encoder : public virtual_base {
|
||||
public:
|
||||
DER_Encoder() {}
|
||||
virtual ~DER_Encoder() {}
|
||||
|
||||
word32 SetAlgoID(HashType, byte*);
|
||||
|
||||
Error GetError() const { return error_; }
|
||||
private:
|
||||
//virtual void WriteHeader() = 0;
|
||||
Error error_;
|
||||
|
||||
DER_Encoder(const DER_Encoder&); // hide copy
|
||||
DER_Encoder& operator=(const DER_Encoder&); // and assign
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Signature_Encoder : public DER_Encoder {
|
||||
const byte* digest_;
|
||||
word32 digestSz_;
|
||||
SigType digestOID_;
|
||||
public:
|
||||
explicit Signature_Encoder(const byte*, word32, HashType, Source&);
|
||||
|
||||
private:
|
||||
void WriteHeader();
|
||||
word32 SetDigest(const byte*, word32, byte*);
|
||||
|
||||
Signature_Encoder(const Signature_Encoder&); // hide copy
|
||||
Signature_Encoder& operator=(const Signature_Encoder&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// Get Cert in PEM format from BEGIN to END
|
||||
int GetCert(Source&);
|
||||
|
||||
// Get Cert in PEM format from pkcs12 file
|
||||
int GetPKCS_Cert(const char* password, Source&);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif // TAO_CRYPT_ASN_HPP
|
||||
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* block.hpp provides word and byte blocks with configurable allocators
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_BLOCK_HPP
|
||||
#define TAO_CRYPT_BLOCK_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
#include <string.h> // memcpy
|
||||
#include <stddef.h> // ptrdiff_t
|
||||
|
||||
#ifdef USE_SYS_STL
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include "algorithm.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// a Base class for Allocators
|
||||
template<class T>
|
||||
class AllocatorBase
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
|
||||
pointer address(reference r) const {return (&r);}
|
||||
const_pointer address(const_reference r) const {return (&r); }
|
||||
void construct(pointer p, const T& val) {new (p) T(val);}
|
||||
void destroy(pointer p) {p->~T();}
|
||||
size_type max_size() const {return ~size_type(0)/sizeof(T);}
|
||||
protected:
|
||||
static void CheckSize(size_t n)
|
||||
{
|
||||
assert(n <= ~size_t(0) / sizeof(T));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// General purpose realloc
|
||||
template<typename T, class A>
|
||||
typename A::pointer StdReallocate(A& a, T* p, typename A::size_type oldSize,
|
||||
typename A::size_type newSize, bool preserve)
|
||||
{
|
||||
if (oldSize == newSize)
|
||||
return p;
|
||||
|
||||
if (preserve) {
|
||||
A b = A();
|
||||
typename A::pointer newPointer = b.allocate(newSize, 0);
|
||||
memcpy(newPointer, p, sizeof(T) * min((word32) oldSize, (word32) newSize));
|
||||
a.deallocate(p, oldSize);
|
||||
STL::swap(a, b);
|
||||
return newPointer;
|
||||
}
|
||||
else {
|
||||
a.deallocate(p, oldSize);
|
||||
return a.allocate(newSize, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Allocator that zeros out memory on deletion
|
||||
template <class T>
|
||||
class AllocatorWithCleanup : public AllocatorBase<T>
|
||||
{
|
||||
public:
|
||||
typedef typename AllocatorBase<T>::pointer pointer;
|
||||
typedef typename AllocatorBase<T>::size_type size_type;
|
||||
|
||||
pointer allocate(size_type n, const void* = 0)
|
||||
{
|
||||
this->CheckSize(n);
|
||||
if (n == 0)
|
||||
return 0;
|
||||
return NEW_TC T[n];
|
||||
}
|
||||
|
||||
void deallocate(void* p, size_type n)
|
||||
{
|
||||
memset(p, 0, n * sizeof(T));
|
||||
tcArrayDelete((T*)p);
|
||||
}
|
||||
|
||||
pointer reallocate(T* p, size_type oldSize, size_type newSize,
|
||||
bool preserve)
|
||||
{
|
||||
return StdReallocate(*this, p, oldSize, newSize, preserve);
|
||||
}
|
||||
|
||||
// VS.NET STL enforces the policy of "All STL-compliant allocators have to
|
||||
// provide a template class member called rebind".
|
||||
template <class U> struct rebind { typedef AllocatorWithCleanup<U> other;};
|
||||
};
|
||||
|
||||
|
||||
// Block class template
|
||||
template<typename T, class A = AllocatorWithCleanup<T> >
|
||||
class Block {
|
||||
public:
|
||||
explicit Block(word32 s = 0) : sz_(s), buffer_(allocator_.allocate(sz_))
|
||||
{ CleanNew(sz_); }
|
||||
|
||||
Block(const T* buff, word32 s) : sz_(s), buffer_(allocator_.allocate(sz_))
|
||||
{ memcpy(buffer_, buff, sz_ * sizeof(T)); }
|
||||
|
||||
Block(const Block& that) : sz_(that.sz_), buffer_(allocator_.allocate(sz_))
|
||||
{ memcpy(buffer_, that.buffer_, sz_ * sizeof(T)); }
|
||||
|
||||
Block& operator=(const Block& that) {
|
||||
Block tmp(that);
|
||||
Swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& operator[] (word32 i) { assert(i < sz_); return buffer_[i]; }
|
||||
const T& operator[] (word32 i) const
|
||||
{ assert(i < sz_); return buffer_[i]; }
|
||||
|
||||
T* operator+ (word32 i) { return buffer_ + i; }
|
||||
const T* operator+ (word32 i) const { return buffer_ + i; }
|
||||
|
||||
word32 size() const { return sz_; }
|
||||
|
||||
T* get_buffer() const { return buffer_; }
|
||||
T* begin() const { return get_buffer(); }
|
||||
|
||||
void CleanGrow(word32 newSize)
|
||||
{
|
||||
if (newSize > sz_) {
|
||||
buffer_ = allocator_.reallocate(buffer_, sz_, newSize, true);
|
||||
memset(buffer_ + sz_, 0, (newSize - sz_) * sizeof(T));
|
||||
sz_ = newSize;
|
||||
}
|
||||
}
|
||||
|
||||
void CleanNew(word32 newSize)
|
||||
{
|
||||
New(newSize);
|
||||
memset(buffer_, 0, sz_ * sizeof(T));
|
||||
}
|
||||
|
||||
void New(word32 newSize)
|
||||
{
|
||||
buffer_ = allocator_.reallocate(buffer_, sz_, newSize, false);
|
||||
sz_ = newSize;
|
||||
}
|
||||
|
||||
void resize(word32 newSize)
|
||||
{
|
||||
buffer_ = allocator_.reallocate(buffer_, sz_, newSize, true);
|
||||
sz_ = newSize;
|
||||
}
|
||||
|
||||
void Swap(Block& other) {
|
||||
STL::swap(sz_, other.sz_);
|
||||
STL::swap(buffer_, other.buffer_);
|
||||
STL::swap(allocator_, other.allocator_);
|
||||
}
|
||||
|
||||
~Block() { allocator_.deallocate(buffer_, sz_); }
|
||||
private:
|
||||
word32 sz_; // size in Ts
|
||||
T* buffer_;
|
||||
A allocator_;
|
||||
};
|
||||
|
||||
|
||||
typedef Block<byte> ByteBlock;
|
||||
typedef Block<word> WordBlock;
|
||||
typedef Block<word32> Word32Block;
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_BLOCK_HPP
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* blowfish.hpp defines Blowfish
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_BLOWFISH_HPP
|
||||
#define TAO_CRYPT_BLOWFISH_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "modes.hpp"
|
||||
#ifdef USE_SYS_STL
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include "algorithm.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_BLOWFISH_ASM
|
||||
#endif
|
||||
|
||||
|
||||
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, MODE), sbox_(pbox_ + ROUNDS + 2) {}
|
||||
|
||||
#ifdef DO_BLOWFISH_ASM
|
||||
void Process(byte*, const byte*, word32);
|
||||
#endif
|
||||
void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION);
|
||||
void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }
|
||||
private:
|
||||
static const word32 p_init_[ROUNDS + 2];
|
||||
static const word32 s_init_[4 * 256];
|
||||
|
||||
word32 pbox_[ROUNDS + 2 + 4 * 256];
|
||||
word32* sbox_;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_BLOWFISH_HPP
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* coding.hpp defines hex and base64 encoding/decoing
|
||||
*/
|
||||
|
||||
#ifndef TAO_CRYPT_CODING_HPP
|
||||
#define TAO_CRYPT_CODING_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "block.hpp"
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
class Source;
|
||||
|
||||
|
||||
// Hex Encoding, see RFC 3548
|
||||
class HexEncoder {
|
||||
ByteBlock encoded_;
|
||||
Source& plain_;
|
||||
public:
|
||||
explicit HexEncoder(Source& s) : plain_(s) { Encode(); }
|
||||
private:
|
||||
void Encode();
|
||||
|
||||
HexEncoder(const HexEncoder&); // hide copy
|
||||
HexEncoder& operator=(const HexEncoder&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// Hex Decoding, see RFC 3548
|
||||
class HexDecoder {
|
||||
ByteBlock decoded_;
|
||||
Source& coded_;
|
||||
public:
|
||||
explicit HexDecoder(Source& s) : coded_(s) { Decode(); }
|
||||
private:
|
||||
void Decode();
|
||||
|
||||
HexDecoder(const HexDecoder&); // hide copy
|
||||
HexDecoder& operator=(const HexDecoder&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// Base 64 encoding, see RFC 3548
|
||||
class Base64Encoder {
|
||||
ByteBlock encoded_;
|
||||
Source& plain_;
|
||||
public:
|
||||
explicit Base64Encoder(Source& s) : plain_(s) { Encode(); }
|
||||
private:
|
||||
void Encode();
|
||||
|
||||
Base64Encoder(const Base64Encoder&); // hide copy
|
||||
Base64Encoder& operator=(const Base64Encoder&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// Base 64 decoding, see RFC 3548
|
||||
class Base64Decoder {
|
||||
ByteBlock decoded_;
|
||||
Source& coded_;
|
||||
public:
|
||||
explicit Base64Decoder(Source& s) : coded_(s) { Decode(); }
|
||||
private:
|
||||
void Decode();
|
||||
|
||||
Base64Decoder(const Base64Decoder&); // hide copy
|
||||
Base64Decoder& operator=(const Base64Decoder&); // and assign
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_CODING_HPP
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* des.hpp defines DES, DES_EDE2, and DES_EDE3
|
||||
see FIPS 46-2 and FIPS 81
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_DES_HPP
|
||||
#define TAO_CRYPT_DES_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "modes.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_DES_ASM
|
||||
#endif
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
enum { DES_BLOCK_SIZE = 8, DES_KEY_SIZE = 32 };
|
||||
|
||||
|
||||
class BasicDES {
|
||||
public:
|
||||
void SetKey(const byte*, word32, CipherDir dir);
|
||||
void RawProcessBlock(word32&, word32&) const;
|
||||
protected:
|
||||
word32 k_[DES_KEY_SIZE];
|
||||
};
|
||||
|
||||
|
||||
// DES
|
||||
class DES : public Mode_BASE, public BasicDES {
|
||||
public:
|
||||
DES(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}
|
||||
|
||||
private:
|
||||
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
|
||||
|
||||
DES(const DES&); // hide copy
|
||||
DES& operator=(const DES&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// DES_EDE2
|
||||
class DES_EDE2 : public Mode_BASE {
|
||||
public:
|
||||
DES_EDE2(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}
|
||||
|
||||
void SetKey(const byte*, word32, CipherDir dir);
|
||||
private:
|
||||
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
|
||||
class DES_EDE3 : public Mode_BASE {
|
||||
public:
|
||||
DES_EDE3(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}
|
||||
|
||||
void SetKey(const byte*, word32, CipherDir dir);
|
||||
void SetIV(const byte* iv) { memcpy(r_, iv, DES_BLOCK_SIZE); }
|
||||
#ifdef DO_DES_ASM
|
||||
void Process(byte*, const byte*, word32);
|
||||
#endif
|
||||
private:
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
typedef BlockCipher<ENCRYPTION, DES, ECB> DES_ECB_Encryption;
|
||||
typedef BlockCipher<DECRYPTION, DES, ECB> DES_ECB_Decryption;
|
||||
|
||||
typedef BlockCipher<ENCRYPTION, DES, CBC> DES_CBC_Encryption;
|
||||
typedef BlockCipher<DECRYPTION, DES, CBC> DES_CBC_Decryption;
|
||||
|
||||
typedef BlockCipher<ENCRYPTION, DES_EDE2, ECB> DES_EDE2_ECB_Encryption;
|
||||
typedef BlockCipher<DECRYPTION, DES_EDE2, ECB> DES_EDE2_ECB_Decryption;
|
||||
|
||||
typedef BlockCipher<ENCRYPTION, DES_EDE2, CBC> DES_EDE2_CBC_Encryption;
|
||||
typedef BlockCipher<DECRYPTION, DES_EDE2, CBC> DES_EDE2_CBC_Decryption;
|
||||
|
||||
typedef BlockCipher<ENCRYPTION, DES_EDE3, ECB> DES_EDE3_ECB_Encryption;
|
||||
typedef BlockCipher<DECRYPTION, DES_EDE3, ECB> DES_EDE3_ECB_Decryption;
|
||||
|
||||
typedef BlockCipher<ENCRYPTION, DES_EDE3, CBC> DES_EDE3_CBC_Encryption;
|
||||
typedef BlockCipher<DECRYPTION, DES_EDE3, CBC> DES_EDE3_CBC_Decryption;
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif // TAO_CRYPT_DES_HPP
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* dh.hpp provides Diffie-Hellman support
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_DH_HPP
|
||||
#define TAO_CRYPT_DH_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "integer.hpp"
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
class Source;
|
||||
|
||||
|
||||
// Diffie-Hellman
|
||||
class DH {
|
||||
public:
|
||||
DH() {}
|
||||
DH(Integer& p, Integer& g) : p_(p), g_(g) {}
|
||||
explicit DH(Source&);
|
||||
|
||||
DH(const DH& that) : p_(that.p_), g_(that.g_) {}
|
||||
DH& operator=(const DH& that)
|
||||
{
|
||||
DH tmp(that);
|
||||
Swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Swap(DH& other)
|
||||
{
|
||||
p_.Swap(other.p_);
|
||||
g_.Swap(other.g_);
|
||||
}
|
||||
|
||||
void Initialize(Source&);
|
||||
void Initialize(Integer& p, Integer& g)
|
||||
{
|
||||
SetP(p);
|
||||
SetG(g);
|
||||
}
|
||||
|
||||
void GenerateKeyPair(RandomNumberGenerator&, byte*, byte*);
|
||||
void Agree(byte*, const byte*, const byte*, word32 otherSz = 0);
|
||||
|
||||
void SetP(const Integer& p) { p_ = p; }
|
||||
void SetG(const Integer& g) { g_ = g; }
|
||||
|
||||
Integer& GetP() { return p_; }
|
||||
Integer& GetG() { return g_; }
|
||||
|
||||
// for p and agree
|
||||
word32 GetByteLength() const { return p_.ByteCount(); }
|
||||
private:
|
||||
// group parms
|
||||
Integer p_;
|
||||
Integer g_;
|
||||
|
||||
void GeneratePrivate(RandomNumberGenerator&, byte*);
|
||||
void GeneratePublic(const byte*, byte*);
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_DH_HPP
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* dsa.hpp provides Digitial Signautre Algorithm see FIPS 186-2
|
||||
*/
|
||||
|
||||
#ifndef TAO_CRYPT_DSA_HPP
|
||||
#define TAO_CRYPT_DSA_HPP
|
||||
|
||||
#include "integer.hpp"
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
class Source;
|
||||
|
||||
|
||||
class DSA_PublicKey {
|
||||
protected:
|
||||
Integer p_;
|
||||
Integer q_;
|
||||
Integer g_;
|
||||
Integer y_;
|
||||
public:
|
||||
DSA_PublicKey() {}
|
||||
explicit DSA_PublicKey(Source&);
|
||||
|
||||
void Initialize(Source&);
|
||||
void Initialize(const Integer& p, const Integer& q, const Integer& g,
|
||||
const Integer& y);
|
||||
|
||||
const Integer& GetModulus() const;
|
||||
const Integer& GetSubGroupOrder() const;
|
||||
const Integer& GetSubGroupGenerator() const;
|
||||
const Integer& GetPublicPart() const;
|
||||
|
||||
void SetModulus(const Integer&);
|
||||
void SetSubGroupOrder(const Integer&);
|
||||
void SetSubGroupGenerator(const Integer&);
|
||||
void SetPublicPart(const Integer&);
|
||||
|
||||
word32 SignatureLength() const;
|
||||
|
||||
DSA_PublicKey(const DSA_PublicKey&);
|
||||
DSA_PublicKey& operator=(const DSA_PublicKey&);
|
||||
|
||||
void Swap(DSA_PublicKey& other);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DSA_PrivateKey : public DSA_PublicKey {
|
||||
Integer x_;
|
||||
public:
|
||||
DSA_PrivateKey() {}
|
||||
explicit DSA_PrivateKey(Source&);
|
||||
|
||||
void Initialize(Source&);
|
||||
void Initialize(const Integer& p, const Integer& q, const Integer& g,
|
||||
const Integer& y, const Integer& x);
|
||||
|
||||
const Integer& GetPrivatePart() const;
|
||||
|
||||
void SetPrivatePart(const Integer&);
|
||||
private:
|
||||
DSA_PrivateKey(const DSA_PrivateKey&); // hide copy
|
||||
DSA_PrivateKey& operator=(const DSA_PrivateKey&); // and assign
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DSA_Signer {
|
||||
const DSA_PrivateKey& key_;
|
||||
Integer r_;
|
||||
Integer s_;
|
||||
public:
|
||||
explicit DSA_Signer(const DSA_PrivateKey&);
|
||||
|
||||
word32 Sign(const byte* sha_digest, byte* sig, RandomNumberGenerator&);
|
||||
|
||||
const Integer& GetR() const;
|
||||
const Integer& GetS() const;
|
||||
private:
|
||||
DSA_Signer(const DSA_Signer&); // hide copy
|
||||
DSA_Signer& operator=(DSA_Signer&); // and assign
|
||||
};
|
||||
|
||||
|
||||
class DSA_Verifier {
|
||||
const DSA_PublicKey& key_;
|
||||
Integer r_;
|
||||
Integer s_;
|
||||
public:
|
||||
explicit DSA_Verifier(const DSA_PublicKey&);
|
||||
|
||||
bool Verify(const byte* sha_digest, const byte* sig);
|
||||
|
||||
const Integer& GetR() const;
|
||||
const Integer& GetS() const;
|
||||
private:
|
||||
DSA_Verifier(const DSA_Verifier&); // hide copy
|
||||
DSA_Verifier& operator=(const DSA_Verifier&); // and assign
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_DSA_HPP
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* error.hpp provides a taocrypt error numbers
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_ERROR_HPP
|
||||
#define TAO_CRYPT_ERROR_HPP
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
enum ErrorNumber {
|
||||
|
||||
NO_ERROR_E = 0, // "not in error state"
|
||||
|
||||
// RandomNumberGenerator
|
||||
WINCRYPT_E = 1001, // "bad wincrypt acquire"
|
||||
CRYPTGEN_E = 1002, // "CryptGenRandom error"
|
||||
OPEN_RAN_E = 1003, // "open /dev/urandom error"
|
||||
READ_RAN_E = 1004, // "read /dev/urandom error"
|
||||
|
||||
// Integer
|
||||
INTEGER_E = 1010, // "bad DER Integer Header"
|
||||
|
||||
|
||||
// ASN.1
|
||||
SEQUENCE_E = 1020, // "bad Sequence Header"
|
||||
SET_E = 1021, // "bad Set Header"
|
||||
VERSION_E = 1022, // "version length not 1"
|
||||
SIG_OID_E = 1023, // "signature OID mismatch"
|
||||
BIT_STR_E = 1024, // "bad BitString Header"
|
||||
UNKNOWN_OID_E = 1025, // "unknown key OID type"
|
||||
OBJECT_ID_E = 1026, // "bad Ojbect ID Header"
|
||||
TAG_NULL_E = 1027, // "expected TAG NULL"
|
||||
EXPECT_0_E = 1028, // "expected 0"
|
||||
OCTET_STR_E = 1029, // "bad Octet String Header"
|
||||
TIME_E = 1030, // "bad TIME"
|
||||
|
||||
DATE_SZ_E = 1031, // "bad Date Size"
|
||||
SIG_LEN_E = 1032, // "bad Signature Length"
|
||||
UNKOWN_SIG_E = 1033, // "unknown signature OID"
|
||||
UNKOWN_HASH_E = 1034, // "unknown hash OID"
|
||||
DSA_SZ_E = 1035, // "bad DSA r or s size"
|
||||
BEFORE_DATE_E = 1036, // "before date in the future"
|
||||
AFTER_DATE_E = 1037, // "after date in the past"
|
||||
SIG_CONFIRM_E = 1038, // "bad self signature confirmation"
|
||||
SIG_OTHER_E = 1039, // "bad other signature confirmation"
|
||||
|
||||
CONTENT_E = 1040, // "bad content processing"
|
||||
PEM_E = 1041 // "bad pem format error"
|
||||
|
||||
// add error string to yassl/src/yassl_error.cpp !!!
|
||||
};
|
||||
|
||||
|
||||
struct Error {
|
||||
ErrorNumber what_; // description number, 0 for no error
|
||||
|
||||
explicit Error(ErrorNumber w = NO_ERROR_E) : what_(w) {}
|
||||
|
||||
ErrorNumber What() const { return what_; }
|
||||
void SetError(ErrorNumber w) { what_ = w; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace TaoCrypt
|
||||
|
||||
#endif // TAO_CRYPT_ERROR_HPP
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* file.hpp provies File Sources and Sinks
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_FILE_HPP
|
||||
#define TAO_CRYPT_FILE_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "block.hpp"
|
||||
#include "error.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
class Source {
|
||||
ByteBlock buffer_;
|
||||
word32 current_;
|
||||
Error error_;
|
||||
public:
|
||||
explicit Source(word32 sz = 0) : buffer_(sz), current_(0) {}
|
||||
Source(const byte* b, word32 sz) : buffer_(b, sz), current_(0) {}
|
||||
|
||||
word32 size() const { return buffer_.size(); }
|
||||
void grow(word32 sz) { buffer_.CleanGrow(sz); }
|
||||
|
||||
const byte* get_buffer() const { return buffer_.get_buffer(); }
|
||||
const byte* get_current() const { return &buffer_[current_]; }
|
||||
word32 get_index() const { return current_; }
|
||||
void set_index(word32 i) { current_ = i; }
|
||||
|
||||
byte operator[] (word32 i) { current_ = i; return next(); }
|
||||
byte next() { return buffer_[current_++]; }
|
||||
byte prev() { return buffer_[--current_]; }
|
||||
|
||||
void add(const byte* data, word32 len)
|
||||
{
|
||||
memcpy(buffer_.get_buffer() + current_, data, len);
|
||||
current_ += len;
|
||||
}
|
||||
|
||||
void advance(word32 i) { current_ += i; }
|
||||
void reset(ByteBlock&);
|
||||
|
||||
Error GetError() { return error_; }
|
||||
void SetError(ErrorNumber w) { error_.SetError(w); }
|
||||
|
||||
friend class FileSource; // for get()
|
||||
|
||||
Source(const Source& that)
|
||||
: buffer_(that.buffer_), current_(that.current_) {}
|
||||
|
||||
Source& operator=(const Source& that)
|
||||
{
|
||||
Source tmp(that);
|
||||
Swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Swap(Source& other)
|
||||
{
|
||||
buffer_.Swap(other.buffer_);
|
||||
STL::swap(current_, other.current_);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// File Source
|
||||
class FileSource {
|
||||
FILE* file_;
|
||||
public:
|
||||
FileSource(const char* fname, Source& source);
|
||||
~FileSource();
|
||||
|
||||
word32 size(bool use_current = false);
|
||||
private:
|
||||
word32 get(Source&);
|
||||
word32 size_left();
|
||||
|
||||
FileSource(const FileSource&); // hide
|
||||
FileSource& operator=(const FileSource&); // hide
|
||||
};
|
||||
|
||||
|
||||
// File Sink
|
||||
class FileSink {
|
||||
FILE* file_;
|
||||
public:
|
||||
FileSink(const char* fname, Source& source);
|
||||
~FileSink();
|
||||
|
||||
word32 size(bool use_current = false);
|
||||
private:
|
||||
void put(Source&);
|
||||
|
||||
FileSink(const FileSink&); // hide
|
||||
FileSink& operator=(const FileSink&); // hide
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_FILE_HPP
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* hash.hpp provides a base for digest types
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_HASH_HPP
|
||||
#define TAO_CRYPT_HASH_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// HASH
|
||||
class HASH : public virtual_base {
|
||||
public:
|
||||
virtual ~HASH() {}
|
||||
|
||||
virtual void Update(const byte*, word32) = 0;
|
||||
virtual void Final(byte*) = 0;
|
||||
|
||||
virtual void Init() = 0;
|
||||
|
||||
virtual word32 getBlockSize() const = 0;
|
||||
virtual word32 getDigestSize() const = 0;
|
||||
};
|
||||
|
||||
|
||||
// HASH with Transform
|
||||
class HASHwithTransform : public HASH {
|
||||
public:
|
||||
HASHwithTransform(word32 digSz, word32 buffSz);
|
||||
virtual ~HASHwithTransform() {}
|
||||
virtual ByteOrder getByteOrder() const = 0;
|
||||
virtual word32 getPadSize() const = 0;
|
||||
|
||||
virtual void Update(const byte*, word32);
|
||||
virtual void Final(byte*);
|
||||
|
||||
word32 GetBitCountLo() const { return loLen_ << 3; }
|
||||
word32 GetBitCountHi() const { return (loLen_ >> (8*sizeof(loLen_) - 3)) +
|
||||
(hiLen_ << 3); }
|
||||
enum { MaxDigestSz = 8, MaxBufferSz = 64 };
|
||||
protected:
|
||||
typedef word32 HashLengthType;
|
||||
word32 buffLen_; // in bytes
|
||||
HashLengthType loLen_; // length in bytes
|
||||
HashLengthType hiLen_; // length in bytes
|
||||
word32 digest_[MaxDigestSz];
|
||||
word32 buffer_[MaxBufferSz / sizeof(word32)];
|
||||
|
||||
virtual void Transform() = 0;
|
||||
|
||||
void AddLength(word32);
|
||||
};
|
||||
|
||||
|
||||
#ifdef WORD64_AVAILABLE
|
||||
|
||||
// 64-bit HASH with Transform
|
||||
class HASH64withTransform : public HASH {
|
||||
public:
|
||||
HASH64withTransform(word32 digSz, word32 buffSz);
|
||||
virtual ~HASH64withTransform() {}
|
||||
virtual ByteOrder getByteOrder() const = 0;
|
||||
virtual word32 getPadSize() const = 0;
|
||||
|
||||
virtual void Update(const byte*, word32);
|
||||
virtual void Final(byte*);
|
||||
|
||||
word32 GetBitCountLo() const { return loLen_ << 3; }
|
||||
word32 GetBitCountHi() const { return (loLen_ >> (8*sizeof(loLen_) - 3)) +
|
||||
(hiLen_ << 3); }
|
||||
enum { MaxDigestSz = 8, MaxBufferSz = 128 };
|
||||
protected:
|
||||
typedef word32 HashLengthType;
|
||||
word32 buffLen_; // in bytes
|
||||
HashLengthType loLen_; // length in bytes
|
||||
HashLengthType hiLen_; // length in bytes
|
||||
word64 digest_[MaxDigestSz];
|
||||
word64 buffer_[MaxBufferSz / sizeof(word64)];
|
||||
|
||||
virtual void Transform() = 0;
|
||||
|
||||
void AddLength(word32);
|
||||
};
|
||||
|
||||
#endif // WORD64_AVAILABLE
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_HASH_HPP
|
||||
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* hamc.hpp implements HMAC, see RFC 2104
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_HMAC_HPP
|
||||
#define TAO_CRYPT_HMAC_HPP
|
||||
|
||||
#include "hash.hpp"
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// HMAC class template
|
||||
template <class T>
|
||||
class HMAC {
|
||||
public:
|
||||
enum { IPAD = 0x36, OPAD = 0x5C };
|
||||
|
||||
HMAC() : ipad_(reinterpret_cast<byte*>(&ip_)),
|
||||
opad_(reinterpret_cast<byte*>(&op_)),
|
||||
innerHash_(reinterpret_cast<byte*>(&innerH_))
|
||||
{
|
||||
Init();
|
||||
}
|
||||
void Update(const byte*, word32);
|
||||
void Final(byte*);
|
||||
void Init();
|
||||
|
||||
void SetKey(const byte*, word32);
|
||||
private:
|
||||
byte* ipad_;
|
||||
byte* opad_;
|
||||
byte* innerHash_;
|
||||
bool innerHashKeyed_;
|
||||
T mac_;
|
||||
|
||||
// MSVC 6 HACK, gives compiler error if calculated in array
|
||||
enum { HMAC_BSIZE = T::BLOCK_SIZE / sizeof(word32),
|
||||
HMAC_DSIZE = T::DIGEST_SIZE / sizeof(word32) };
|
||||
|
||||
word32 ip_[HMAC_BSIZE]; // align ipad_ on word32
|
||||
word32 op_[HMAC_BSIZE]; // align opad_ on word32
|
||||
word32 innerH_[HMAC_DSIZE]; // align innerHash_ on word32
|
||||
|
||||
void KeyInnerHash();
|
||||
|
||||
HMAC(const HMAC&);
|
||||
HMAC& operator= (const HMAC&);
|
||||
};
|
||||
|
||||
|
||||
// Setup
|
||||
template <class T>
|
||||
void HMAC<T>::Init()
|
||||
{
|
||||
mac_.Init();
|
||||
innerHashKeyed_ = false;
|
||||
}
|
||||
|
||||
|
||||
// Key generation
|
||||
template <class T>
|
||||
void HMAC<T>::SetKey(const byte* key, word32 length)
|
||||
{
|
||||
Init();
|
||||
|
||||
if (length <= T::BLOCK_SIZE)
|
||||
memcpy(ipad_, key, length);
|
||||
else {
|
||||
mac_.Update(key, length);
|
||||
mac_.Final(ipad_);
|
||||
length = T::DIGEST_SIZE;
|
||||
}
|
||||
memset(ipad_ + length, 0, T::BLOCK_SIZE - length);
|
||||
|
||||
for (word32 i = 0; i < T::BLOCK_SIZE; i++) {
|
||||
opad_[i] = ipad_[i] ^ OPAD;
|
||||
ipad_[i] ^= IPAD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Inner Key Hash
|
||||
template <class T>
|
||||
void HMAC<T>::KeyInnerHash()
|
||||
{
|
||||
mac_.Update(ipad_, T::BLOCK_SIZE);
|
||||
innerHashKeyed_ = true;
|
||||
}
|
||||
|
||||
|
||||
// Update
|
||||
template <class T>
|
||||
void HMAC<T>::Update(const byte* msg, word32 length)
|
||||
{
|
||||
if (!innerHashKeyed_)
|
||||
KeyInnerHash();
|
||||
mac_.Update(msg, length);
|
||||
}
|
||||
|
||||
|
||||
// Final
|
||||
template <class T>
|
||||
void HMAC<T>::Final(byte* hash)
|
||||
{
|
||||
if (!innerHashKeyed_)
|
||||
KeyInnerHash();
|
||||
mac_.Final(innerHash_);
|
||||
|
||||
mac_.Update(opad_, T::BLOCK_SIZE);
|
||||
mac_.Update(innerHash_, T::DIGEST_SIZE);
|
||||
mac_.Final(hash);
|
||||
|
||||
innerHashKeyed_ = false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_HMAC_HPP
|
||||
@@ -1,328 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* based on Wei Dai's integer.h from CryptoPP */
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_INTEGER_HPP
|
||||
#define TAO_CRYPT_INTEGER_HPP
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// 4250: dominance
|
||||
// 4660: explicitly instantiating a class already implicitly instantiated
|
||||
// 4661: no suitable definition provided for explicit template request
|
||||
// 4786: identifer was truncated in debug information
|
||||
// 4355: 'this' : used in base member initializer list
|
||||
# pragma warning(disable: 4250 4660 4661 4786 4355)
|
||||
#endif
|
||||
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "block.hpp"
|
||||
#include "random.hpp"
|
||||
#include "file.hpp"
|
||||
#include <string.h>
|
||||
#ifdef USE_SYS_STL
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include "algorithm.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TAOCRYPT_X86ASM_AVAILABLE
|
||||
|
||||
#ifdef _M_IX86
|
||||
#if (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 500)) || \
|
||||
(defined(__ICL) && (__ICL >= 500))
|
||||
#define SSE2_INTRINSICS_AVAILABLE
|
||||
#define TAOCRYPT_MM_MALLOC_AVAILABLE
|
||||
#elif defined(_MSC_VER)
|
||||
// _mm_free seems to be the only way to tell if the Processor Pack is
|
||||
//installed or not
|
||||
#include <malloc.h>
|
||||
#if defined(_mm_free)
|
||||
#define SSE2_INTRINSICS_AVAILABLE
|
||||
#define TAOCRYPT_MM_MALLOC_AVAILABLE
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// SSE2 intrinsics work in GCC 3.3 or later
|
||||
#if defined(__SSE2__) && (__GNUC__ == 4 || __GNUC_MAJOR__ > 3 || \
|
||||
__GNUC_MINOR__ > 2)
|
||||
#define SSE2_INTRINSICS_AVAILABLE
|
||||
#endif
|
||||
|
||||
#endif // X86ASM
|
||||
|
||||
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
#if defined(SSE2_INTRINSICS_AVAILABLE)
|
||||
|
||||
// Allocator handling proper alignment
|
||||
template <class T>
|
||||
class AlignedAllocator : public AllocatorBase<T>
|
||||
{
|
||||
public:
|
||||
typedef typename AllocatorBase<T>::pointer pointer;
|
||||
typedef typename AllocatorBase<T>::size_type size_type;
|
||||
|
||||
pointer allocate(size_type n, const void* = 0);
|
||||
void deallocate(void* p, size_type n);
|
||||
pointer reallocate(T* p, size_type oldSize, size_type newSize,
|
||||
bool preserve)
|
||||
{
|
||||
return StdReallocate(*this, p, oldSize, newSize, preserve);
|
||||
}
|
||||
|
||||
#if !(defined(TAOCRYPT_MALLOC_ALIGNMENT_IS_16) || \
|
||||
defined(TAOCRYPT_MEMALIGN_AVAILABLE) || \
|
||||
defined(TAOCRYPT_MM_MALLOC_AVAILABLE))
|
||||
#define TAOCRYPT_NO_ALIGNED_ALLOC
|
||||
AlignedAllocator() : m_pBlock(0) {}
|
||||
protected:
|
||||
void *m_pBlock;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Block<word, AlignedAllocator<word> > AlignedWordBlock;
|
||||
#else
|
||||
typedef WordBlock AlignedWordBlock;
|
||||
#endif
|
||||
|
||||
|
||||
// general MIN
|
||||
template<typename T> inline
|
||||
const T& min(const T& a, const T& b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
|
||||
// general MAX
|
||||
template<typename T> inline
|
||||
const T& max(const T& a, const T& b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
|
||||
// Large Integer class
|
||||
class Integer {
|
||||
public:
|
||||
enum Sign {POSITIVE = 0, NEGATIVE = 1 };
|
||||
enum Signedness { UNSIGNED, SIGNED };
|
||||
enum RandomNumberType { ANY, PRIME };
|
||||
|
||||
class DivideByZero {};
|
||||
|
||||
Integer();
|
||||
Integer(const Integer& t);
|
||||
Integer(signed long value);
|
||||
Integer(Sign s, word highWord, word lowWord);
|
||||
|
||||
// BER Decode Source
|
||||
explicit Integer(Source&);
|
||||
|
||||
Integer(const byte* encodedInteger, unsigned int byteCount,
|
||||
Signedness s = UNSIGNED);
|
||||
|
||||
~Integer() {}
|
||||
|
||||
static const Integer& Zero();
|
||||
static const Integer& One();
|
||||
|
||||
Integer& Ref() { return *this; }
|
||||
|
||||
Integer(RandomNumberGenerator& rng, const Integer& min,
|
||||
const Integer& max);
|
||||
|
||||
static Integer Power2(unsigned int e);
|
||||
|
||||
unsigned int MinEncodedSize(Signedness = UNSIGNED) const;
|
||||
unsigned int Encode(byte* output, unsigned int outputLen,
|
||||
Signedness = UNSIGNED) const;
|
||||
|
||||
void Decode(const byte* input, unsigned int inputLen,
|
||||
Signedness = UNSIGNED);
|
||||
void Decode(Source&);
|
||||
|
||||
bool IsConvertableToLong() const;
|
||||
signed long ConvertToLong() const;
|
||||
|
||||
unsigned int BitCount() const;
|
||||
unsigned int ByteCount() const;
|
||||
unsigned int WordCount() const;
|
||||
|
||||
bool GetBit(unsigned int i) const;
|
||||
byte GetByte(unsigned int i) const;
|
||||
unsigned long GetBits(unsigned int i, unsigned int n) const;
|
||||
|
||||
bool IsZero() const { return !*this; }
|
||||
bool NotZero() const { return !IsZero(); }
|
||||
bool IsNegative() const { return sign_ == NEGATIVE; }
|
||||
bool NotNegative() const { return !IsNegative(); }
|
||||
bool IsPositive() const { return NotNegative() && NotZero(); }
|
||||
bool NotPositive() const { return !IsPositive(); }
|
||||
bool IsEven() const { return GetBit(0) == 0; }
|
||||
bool IsOdd() const { return GetBit(0) == 1; }
|
||||
|
||||
Integer& operator=(const Integer& t);
|
||||
Integer& operator+=(const Integer& t);
|
||||
Integer& operator-=(const Integer& t);
|
||||
Integer& operator*=(const Integer& t) { return *this = Times(t); }
|
||||
Integer& operator/=(const Integer& t)
|
||||
{ return *this = DividedBy(t);}
|
||||
Integer& operator%=(const Integer& t) { return *this = Modulo(t); }
|
||||
Integer& operator/=(word t) { return *this = DividedBy(t); }
|
||||
Integer& operator%=(word t) { return *this = Modulo(t); }
|
||||
Integer& operator<<=(unsigned int);
|
||||
Integer& operator>>=(unsigned int);
|
||||
|
||||
|
||||
void Randomize(RandomNumberGenerator &rng, unsigned int bitcount);
|
||||
void Randomize(RandomNumberGenerator &rng, const Integer &min,
|
||||
const Integer &max);
|
||||
|
||||
void SetBit(unsigned int n, bool value = 1);
|
||||
void SetByte(unsigned int n, byte value);
|
||||
|
||||
void Negate();
|
||||
void SetPositive() { sign_ = POSITIVE; }
|
||||
void SetNegative() { if (!!(*this)) sign_ = NEGATIVE; }
|
||||
void Swap(Integer& a);
|
||||
|
||||
bool operator!() const;
|
||||
Integer operator+() const {return *this;}
|
||||
Integer operator-() const;
|
||||
Integer& operator++();
|
||||
Integer& operator--();
|
||||
Integer operator++(int)
|
||||
{ Integer temp = *this; ++*this; return temp; }
|
||||
Integer operator--(int)
|
||||
{ Integer temp = *this; --*this; return temp; }
|
||||
|
||||
int Compare(const Integer& a) const;
|
||||
|
||||
Integer Plus(const Integer &b) const;
|
||||
Integer Minus(const Integer &b) const;
|
||||
Integer Times(const Integer &b) const;
|
||||
Integer DividedBy(const Integer &b) const;
|
||||
Integer Modulo(const Integer &b) const;
|
||||
Integer DividedBy(word b) const;
|
||||
word Modulo(word b) const;
|
||||
|
||||
Integer operator>>(unsigned int n) const { return Integer(*this)>>=n; }
|
||||
Integer operator<<(unsigned int n) const { return Integer(*this)<<=n; }
|
||||
|
||||
Integer AbsoluteValue() const;
|
||||
Integer Doubled() const { return Plus(*this); }
|
||||
Integer Squared() const { return Times(*this); }
|
||||
Integer SquareRoot() const;
|
||||
|
||||
bool IsSquare() const;
|
||||
bool IsUnit() const;
|
||||
|
||||
Integer MultiplicativeInverse() const;
|
||||
|
||||
friend Integer a_times_b_mod_c(const Integer& x, const Integer& y,
|
||||
const Integer& m);
|
||||
friend Integer a_exp_b_mod_c(const Integer& x, const Integer& e,
|
||||
const Integer& m);
|
||||
|
||||
static void Divide(Integer& r, Integer& q, const Integer& a,
|
||||
const Integer& d);
|
||||
static void Divide(word& r, Integer& q, const Integer& a, word d);
|
||||
static void DivideByPowerOf2(Integer& r, Integer& q, const Integer& a,
|
||||
unsigned int n);
|
||||
static Integer Gcd(const Integer& a, const Integer& n);
|
||||
|
||||
Integer InverseMod(const Integer& n) const;
|
||||
word InverseMod(word n) const;
|
||||
|
||||
private:
|
||||
friend class ModularArithmetic;
|
||||
friend class MontgomeryRepresentation;
|
||||
|
||||
Integer(word value, unsigned int length);
|
||||
int PositiveCompare(const Integer& t) const;
|
||||
|
||||
friend void PositiveAdd(Integer& sum, const Integer& a, const Integer& b);
|
||||
friend void PositiveSubtract(Integer& diff, const Integer& a,
|
||||
const Integer& b);
|
||||
friend void PositiveMultiply(Integer& product, const Integer& a,
|
||||
const Integer& b);
|
||||
friend void PositiveDivide(Integer& remainder, Integer& quotient, const
|
||||
Integer& dividend, const Integer& divisor);
|
||||
AlignedWordBlock reg_;
|
||||
Sign sign_;
|
||||
};
|
||||
|
||||
inline bool operator==(const Integer& a, const Integer& b)
|
||||
{return a.Compare(b)==0;}
|
||||
inline bool operator!=(const Integer& a, const Integer& b)
|
||||
{return a.Compare(b)!=0;}
|
||||
inline bool operator> (const Integer& a, const Integer& b)
|
||||
{return a.Compare(b)> 0;}
|
||||
inline bool operator>=(const Integer& a, const Integer& b)
|
||||
{return a.Compare(b)>=0;}
|
||||
inline bool operator< (const Integer& a, const Integer& b)
|
||||
{return a.Compare(b)< 0;}
|
||||
inline bool operator<=(const Integer& a, const Integer& b)
|
||||
{return a.Compare(b)<=0;}
|
||||
|
||||
inline Integer operator+(const Integer &a, const Integer &b)
|
||||
{return a.Plus(b);}
|
||||
inline Integer operator-(const Integer &a, const Integer &b)
|
||||
{return a.Minus(b);}
|
||||
inline Integer operator*(const Integer &a, const Integer &b)
|
||||
{return a.Times(b);}
|
||||
inline Integer operator/(const Integer &a, const Integer &b)
|
||||
{return a.DividedBy(b);}
|
||||
inline Integer operator%(const Integer &a, const Integer &b)
|
||||
{return a.Modulo(b);}
|
||||
inline Integer operator/(const Integer &a, word b) {return a.DividedBy(b);}
|
||||
inline word operator%(const Integer &a, word b) {return a.Modulo(b);}
|
||||
|
||||
inline void swap(Integer &a, Integer &b)
|
||||
{
|
||||
a.Swap(b);
|
||||
}
|
||||
|
||||
|
||||
Integer CRT(const Integer& xp, const Integer& p, const Integer& xq,
|
||||
const Integer& q, const Integer& u);
|
||||
|
||||
inline Integer ModularExponentiation(const Integer& a, const Integer& e,
|
||||
const Integer& m)
|
||||
{
|
||||
return a_exp_b_mod_c(a, e, m);
|
||||
}
|
||||
|
||||
Integer ModularRoot(const Integer& a, const Integer& dp, const Integer& dq,
|
||||
const Integer& p, const Integer& q, const Integer& u);
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_INTEGER_HPP
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 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
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* md2.hpp provides MD2 digest support, see RFC 1319
|
||||
*/
|
||||
|
||||
#ifndef TAO_CRYPT_MD2_HPP
|
||||
#define TAO_CRYPT_MD2_HPP
|
||||
|
||||
|
||||
#include "hash.hpp"
|
||||
#include "block.hpp"
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// MD2 digest
|
||||
class MD2 : public HASH {
|
||||
public:
|
||||
enum { BLOCK_SIZE = 16, DIGEST_SIZE = 16, PAD_SIZE = 16, X_SIZE = 48 };
|
||||
MD2();
|
||||
|
||||
word32 getBlockSize() const { return BLOCK_SIZE; }
|
||||
word32 getDigestSize() const { return DIGEST_SIZE; }
|
||||
|
||||
void Update(const byte*, word32);
|
||||
void Final(byte*);
|
||||
|
||||
void Init();
|
||||
void Swap(MD2&);
|
||||
private:
|
||||
ByteBlock X_, C_, buffer_;
|
||||
word32 count_; // bytes % PAD_SIZE
|
||||
|
||||
MD2(const MD2&);
|
||||
MD2& operator=(const MD2&);
|
||||
};
|
||||
|
||||
inline void swap(MD2& a, MD2& b)
|
||||
{
|
||||
a.Swap(b);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_MD2_HPP
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* md4.hpp provides MD4 digest support
|
||||
* WANRING: MD4 is considered insecure, only use if you have to, e.g., yaSSL
|
||||
* libcurl supports needs this for NTLM authentication
|
||||
*/
|
||||
|
||||
#ifndef TAO_CRYPT_MD4_HPP
|
||||
#define TAO_CRYPT_MD4_HPP
|
||||
|
||||
#include "hash.hpp"
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// MD4 digest
|
||||
class MD4 : public HASHwithTransform {
|
||||
public:
|
||||
enum { BLOCK_SIZE = 64, DIGEST_SIZE = 16, PAD_SIZE = 56,
|
||||
TAO_BYTE_ORDER = LittleEndianOrder }; // in Bytes
|
||||
MD4() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE)
|
||||
{ Init(); }
|
||||
ByteOrder getByteOrder() const { return ByteOrder(TAO_BYTE_ORDER); }
|
||||
word32 getBlockSize() const { return BLOCK_SIZE; }
|
||||
word32 getDigestSize() const { return DIGEST_SIZE; }
|
||||
word32 getPadSize() const { return PAD_SIZE; }
|
||||
|
||||
MD4(const MD4&);
|
||||
MD4& operator= (const MD4&);
|
||||
|
||||
void Init();
|
||||
void Swap(MD4&);
|
||||
private:
|
||||
void Transform();
|
||||
};
|
||||
|
||||
inline void swap(MD4& a, MD4& b)
|
||||
{
|
||||
a.Swap(b);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_MD4_HPP
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* md5.hpp provides MD5 digest support, see RFC 1321
|
||||
*/
|
||||
|
||||
#ifndef TAO_CRYPT_MD5_HPP
|
||||
#define TAO_CRYPT_MD5_HPP
|
||||
|
||||
#include "hash.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_MD5_ASM
|
||||
#endif
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// MD5 digest
|
||||
class MD5 : public HASHwithTransform {
|
||||
public:
|
||||
enum { BLOCK_SIZE = 64, DIGEST_SIZE = 16, PAD_SIZE = 56,
|
||||
TAO_BYTE_ORDER = LittleEndianOrder }; // in Bytes
|
||||
MD5() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE)
|
||||
{ Init(); }
|
||||
ByteOrder getByteOrder() const { return ByteOrder(TAO_BYTE_ORDER); }
|
||||
word32 getBlockSize() const { return BLOCK_SIZE; }
|
||||
word32 getDigestSize() const { return DIGEST_SIZE; }
|
||||
word32 getPadSize() const { return PAD_SIZE; }
|
||||
|
||||
MD5(const MD5&);
|
||||
MD5& operator= (const MD5&);
|
||||
|
||||
#ifdef DO_MD5_ASM
|
||||
void Update(const byte*, word32);
|
||||
#endif
|
||||
|
||||
void Init();
|
||||
void Swap(MD5&);
|
||||
private:
|
||||
void Transform();
|
||||
void AsmTransform(const byte* data, word32 times);
|
||||
};
|
||||
|
||||
inline void swap(MD5& a, MD5& b)
|
||||
{
|
||||
a.Swap(b);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_MD5_HPP
|
||||
|
||||
@@ -1,888 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* based on Wei Dai's misc.h from CryptoPP */
|
||||
|
||||
#ifndef TAO_CRYPT_MISC_HPP
|
||||
#define TAO_CRYPT_MISC_HPP
|
||||
|
||||
|
||||
#if !defined(DO_TAOCRYPT_KERNEL_MODE)
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#else
|
||||
#include "kernelc.hpp"
|
||||
#endif
|
||||
|
||||
#include "types.hpp"
|
||||
#include "type_traits.hpp"
|
||||
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// Delete static singleton holders
|
||||
void CleanUp();
|
||||
|
||||
|
||||
#ifdef YASSL_PURE_C
|
||||
|
||||
// library allocation
|
||||
struct new_t {}; // TaoCrypt New type
|
||||
extern new_t tc; // pass in parameter
|
||||
|
||||
} // namespace TaoCrypt
|
||||
|
||||
void* operator new (size_t, 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 {
|
||||
|
||||
template<typename T>
|
||||
void tcDelete(T* ptr)
|
||||
{
|
||||
if (ptr) ptr->~T();
|
||||
::operator delete(ptr, TaoCrypt::tc);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void tcArrayDelete(T* ptr)
|
||||
{
|
||||
// can't do array placement destruction since not tracking size in
|
||||
// allocation, only allow builtins to use array placement since they
|
||||
// don't need destructors called
|
||||
typedef char builtin[IsFundamentalType<T>::Yes ? 1 : -1];
|
||||
(void)sizeof(builtin);
|
||||
|
||||
::operator delete[](ptr, TaoCrypt::tc);
|
||||
}
|
||||
|
||||
#define NEW_TC new (TaoCrypt::tc)
|
||||
|
||||
|
||||
// to resolve compiler generated operator delete on base classes with
|
||||
// virtual destructors (when on stack), make sure doesn't get called
|
||||
class virtual_base {
|
||||
public:
|
||||
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__)
|
||||
#define INTEL_INTRINSICS
|
||||
#define FAST_ROTATE
|
||||
#elif defined(__MWERKS__) && TARGET_CPU_PPC
|
||||
#define PPC_INTRINSICS
|
||||
#define FAST_ROTATE
|
||||
#elif defined(__GNUC__) && defined(__i386__)
|
||||
// GCC does peephole optimizations which should result in using rotate
|
||||
// instructions
|
||||
#define FAST_ROTATE
|
||||
#endif
|
||||
|
||||
|
||||
// no gas on these systems ?, disable for now
|
||||
#if defined(__sun__) || defined (__QNX__) || defined (__APPLE__)
|
||||
#define TAOCRYPT_DISABLE_X86ASM
|
||||
#endif
|
||||
|
||||
// icc problem with -03 and integer, disable for now
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#define TAOCRYPT_DISABLE_X86ASM
|
||||
#endif
|
||||
|
||||
|
||||
// Turn on ia32 ASM for Big Integer
|
||||
// CodeWarrior defines _MSC_VER
|
||||
#if !defined(TAOCRYPT_DISABLE_X86ASM) && ((defined(_MSC_VER) && \
|
||||
!defined(__MWERKS__) && defined(_M_IX86)) || \
|
||||
(defined(__GNUC__) && defined(__i386__)))
|
||||
#define TAOCRYPT_X86ASM_AVAILABLE
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TAOCRYPT_X86ASM_AVAILABLE
|
||||
bool HaveCpuId();
|
||||
bool IsPentium();
|
||||
void CpuId(word32 input, word32 *output);
|
||||
|
||||
extern bool isMMX;
|
||||
#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__)
|
||||
# define TAOCRYPT_MALLOC_ALIGNMENT_IS_16
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__sun__) || defined(__CYGWIN__)
|
||||
# define TAOCRYPT_MEMALIGN_AVAILABLE
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define TAOCRYPT_WIN32_AVAILABLE
|
||||
#endif
|
||||
|
||||
#if defined(__unix__) || defined(__MACH__)
|
||||
#define TAOCRYPT_UNIX_AVAILABLE
|
||||
#endif
|
||||
|
||||
|
||||
// VC60 workaround: it doesn't allow typename in some places
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1300)
|
||||
#define CPP_TYPENAME
|
||||
#else
|
||||
#define CPP_TYPENAME typename
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define TAOCRYPT_NO_VTABLE __declspec(novtable)
|
||||
#else
|
||||
#define TAOCRYPT_NO_VTABLE
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_SYS_STL
|
||||
// use system STL
|
||||
#define STL_NAMESPACE std
|
||||
#else
|
||||
// use mySTL
|
||||
#define STL_NAMESPACE mySTL
|
||||
#endif
|
||||
|
||||
|
||||
// ***************** DLL related ********************
|
||||
|
||||
#ifdef TAOCRYPT_WIN32_AVAILABLE
|
||||
|
||||
#ifdef TAOCRYPT_EXPORTS
|
||||
#define TAOCRYPT_IS_DLL
|
||||
#define TAOCRYPT_DLL __declspec(dllexport)
|
||||
#elif defined(TAOCRYPT_IMPORTS)
|
||||
#define TAOCRYPT_IS_DLL
|
||||
#define TAOCRYPT_DLL __declspec(dllimport)
|
||||
#else
|
||||
#define TAOCRYPT_DLL
|
||||
#endif // EXPORTS
|
||||
|
||||
#define TAOCRYPT_API __stdcall
|
||||
#define TAOCRYPT_CDECL __cdecl
|
||||
|
||||
#else // TAOCRYPT_WIN32_AVAILABLE
|
||||
|
||||
#define TAOCRYPT_DLL
|
||||
#define TAOCRYPT_API
|
||||
#define TAOCRYPT_CDECL
|
||||
|
||||
#endif // TAOCRYPT_WIN32_AVAILABLE
|
||||
|
||||
|
||||
// ****************** tempalte stuff *******************
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_MANUALLY_INSTANTIATE_TEMPLATES) && \
|
||||
!defined(TAOCRYPT_IMPORTS)
|
||||
#define TAOCRYPT_DLL_TEMPLATE_CLASS template class TAOCRYPT_DLL
|
||||
#elif defined(__MWERKS__)
|
||||
#define TAOCRYPT_DLL_TEMPLATE_CLASS extern class TAOCRYPT_DLL
|
||||
#else
|
||||
#define TAOCRYPT_DLL_TEMPLATE_CLASS extern template class TAOCRYPT_DLL
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_MANUALLY_INSTANTIATE_TEMPLATES) && \
|
||||
!defined(TAOCRYPT_EXPORTS)
|
||||
#define TAOCRYPT_STATIC_TEMPLATE_CLASS template class
|
||||
#elif defined(__MWERKS__)
|
||||
#define TAOCRYPT_STATIC_TEMPLATE_CLASS extern class
|
||||
#else
|
||||
#define TAOCRYPT_STATIC_TEMPLATE_CLASS extern template class
|
||||
#endif
|
||||
|
||||
|
||||
// ************** compile-time assertion ***************
|
||||
|
||||
template <bool b>
|
||||
struct CompileAssert
|
||||
{
|
||||
static char dummy[2*b-1];
|
||||
};
|
||||
|
||||
#define TAOCRYPT_COMPILE_ASSERT(assertion) \
|
||||
TAOCRYPT_COMPILE_ASSERT_INSTANCE(assertion, __LINE__)
|
||||
|
||||
#if defined(TAOCRYPT_EXPORTS) || defined(TAOCRYPT_IMPORTS)
|
||||
#define TAOCRYPT_COMPILE_ASSERT_INSTANCE(assertion, instance)
|
||||
#else
|
||||
#define TAOCRYPT_COMPILE_ASSERT_INSTANCE(assertion, instance) \
|
||||
(void)sizeof(CompileAssert<(assertion)>)
|
||||
#endif
|
||||
|
||||
#define TAOCRYPT_ASSERT_JOIN(X, Y) TAOCRYPT_DO_ASSERT_JOIN(X, Y)
|
||||
|
||||
#define TAOCRYPT_DO_ASSERT_JOIN(X, Y) X##Y
|
||||
|
||||
|
||||
/*************** helpers *****************************/
|
||||
|
||||
inline unsigned int BitsToBytes(unsigned int bitCount)
|
||||
{
|
||||
return ((bitCount+7)/(8));
|
||||
}
|
||||
|
||||
inline unsigned int BytesToWords(unsigned int byteCount)
|
||||
{
|
||||
return ((byteCount+WORD_SIZE-1)/WORD_SIZE);
|
||||
}
|
||||
|
||||
inline unsigned int BitsToWords(unsigned int bitCount)
|
||||
{
|
||||
return ((bitCount+WORD_BITS-1)/(WORD_BITS));
|
||||
}
|
||||
|
||||
inline void CopyWords(word* r, const word* a, word32 n)
|
||||
{
|
||||
for (word32 i = 0; i < n; i++)
|
||||
r[i] = a[i];
|
||||
}
|
||||
|
||||
inline unsigned int CountWords(const word* X, unsigned int N)
|
||||
{
|
||||
while (N && X[N-1]==0)
|
||||
N--;
|
||||
return N;
|
||||
}
|
||||
|
||||
inline void SetWords(word* r, word a, unsigned int n)
|
||||
{
|
||||
for (unsigned int i=0; i<n; i++)
|
||||
r[i] = a;
|
||||
}
|
||||
|
||||
enum ByteOrder { LittleEndianOrder = 0, BigEndianOrder = 1 };
|
||||
enum CipherDir {ENCRYPTION, DECRYPTION};
|
||||
|
||||
inline CipherDir ReverseDir(CipherDir dir)
|
||||
{
|
||||
return (dir == ENCRYPTION) ? DECRYPTION : ENCRYPTION;
|
||||
}
|
||||
|
||||
template <typename ENUM_TYPE, int VALUE>
|
||||
struct EnumToType
|
||||
{
|
||||
static ENUM_TYPE ToEnum() { return (ENUM_TYPE)VALUE; }
|
||||
};
|
||||
|
||||
typedef EnumToType<ByteOrder, LittleEndianOrder> LittleEndian;
|
||||
typedef EnumToType<ByteOrder, BigEndianOrder> BigEndian;
|
||||
|
||||
|
||||
#ifndef BIG_ENDIAN_ORDER
|
||||
typedef LittleEndian HostByteOrder;
|
||||
#else
|
||||
typedef BigEndian HostByteOrder;
|
||||
#endif
|
||||
|
||||
inline ByteOrder GetHostByteOrder()
|
||||
{
|
||||
return HostByteOrder::ToEnum();
|
||||
}
|
||||
|
||||
inline bool HostByteOrderIs(ByteOrder order)
|
||||
{
|
||||
return order == GetHostByteOrder();
|
||||
}
|
||||
|
||||
|
||||
void xorbuf(byte*, const byte*, unsigned int);
|
||||
|
||||
|
||||
template <class T>
|
||||
inline bool IsPowerOf2(T n)
|
||||
{
|
||||
return n > 0 && (n & (n-1)) == 0;
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
inline T2 ModPowerOf2(T1 a, T2 b)
|
||||
{
|
||||
assert(IsPowerOf2(b));
|
||||
return T2(a) & (b-1);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T RoundDownToMultipleOf(T n, T m)
|
||||
{
|
||||
return n - (IsPowerOf2(m) ? ModPowerOf2(n, m) : (n%m));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T RoundUpToMultipleOf(T n, T m)
|
||||
{
|
||||
return RoundDownToMultipleOf(n+m-1, m);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline unsigned int GetAlignment(T* dummy = 0) // VC60 workaround
|
||||
{
|
||||
#if (_MSC_VER >= 1300)
|
||||
return __alignof(T);
|
||||
#elif defined(__GNUC__)
|
||||
return __alignof__(T);
|
||||
#else
|
||||
return sizeof(T);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool IsAlignedOn(const void* p, unsigned int alignment)
|
||||
{
|
||||
return IsPowerOf2(alignment) ? ModPowerOf2((size_t)p, alignment) == 0
|
||||
: (size_t)p % alignment == 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool IsAligned(const void* p, T* dummy = 0) // VC60 workaround
|
||||
{
|
||||
return IsAlignedOn(p, GetAlignment<T>());
|
||||
}
|
||||
|
||||
|
||||
template <class T> inline T rotlFixed(T x, unsigned int y)
|
||||
{
|
||||
assert(y < sizeof(T)*8);
|
||||
return (x<<y) | (x>>(sizeof(T)*8-y));
|
||||
}
|
||||
|
||||
template <class T> inline T rotrFixed(T x, unsigned int y)
|
||||
{
|
||||
assert(y < sizeof(T)*8);
|
||||
return (x>>y) | (x<<(sizeof(T)*8-y));
|
||||
}
|
||||
|
||||
#ifdef INTEL_INTRINSICS
|
||||
|
||||
#pragma intrinsic(_lrotl, _lrotr)
|
||||
|
||||
template<> inline word32 rotlFixed(word32 x, word32 y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return y ? _lrotl(x, y) : x;
|
||||
}
|
||||
|
||||
template<> inline word32 rotrFixed(word32 x, word32 y)
|
||||
{
|
||||
assert(y < 32);
|
||||
return y ? _lrotr(x, y) : x;
|
||||
}
|
||||
|
||||
#endif // INTEL_INTRINSICS
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
inline word32 min(word32 a, word32 b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
|
||||
inline word32 ByteReverse(word32 value)
|
||||
{
|
||||
#ifdef PPC_INTRINSICS
|
||||
// PPC: load reverse indexed instruction
|
||||
return (word32)__lwbrx(&value,0);
|
||||
#elif defined(FAST_ROTATE)
|
||||
// 5 instructions with rotate instruction, 9 without
|
||||
return (rotrFixed(value, 8U) & 0xff00ff00) |
|
||||
(rotlFixed(value, 8U) & 0x00ff00ff);
|
||||
#else
|
||||
// 6 instructions with rotate instruction, 8 without
|
||||
value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);
|
||||
return rotlFixed(value, 16U);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef WORD64_AVAILABLE
|
||||
|
||||
inline word64 ByteReverse(word64 value)
|
||||
{
|
||||
#ifdef TAOCRYPT_SLOW_WORD64
|
||||
return (word64(ByteReverse(word32(value))) << 32) |
|
||||
ByteReverse(word32(value>>32));
|
||||
#else
|
||||
value = ((value & W64LIT(0xFF00FF00FF00FF00)) >> 8) |
|
||||
((value & W64LIT(0x00FF00FF00FF00FF)) << 8);
|
||||
value = ((value & W64LIT(0xFFFF0000FFFF0000)) >> 16) |
|
||||
((value & W64LIT(0x0000FFFF0000FFFF)) << 16);
|
||||
return rotlFixed(value, 32U);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // WORD64_AVAILABLE
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline void ByteReverse(T* out, const T* in, word32 byteCount)
|
||||
{
|
||||
assert(byteCount % sizeof(T) == 0);
|
||||
word32 count = byteCount/sizeof(T);
|
||||
for (word32 i=0; i<count; i++)
|
||||
out[i] = ByteReverse(in[i]);
|
||||
}
|
||||
|
||||
inline void ByteReverse(byte* out, const byte* in, word32 byteCount)
|
||||
{
|
||||
word32* o = reinterpret_cast<word32*>(out);
|
||||
const word32* i = reinterpret_cast<const word32*>(in);
|
||||
ByteReverse(o, i, byteCount);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T ByteReverseIf(T value, ByteOrder order)
|
||||
{
|
||||
return HostByteOrderIs(order) ? value : ByteReverse(value);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline void ByteReverseIf(T* out, const T* in, word32 bc, ByteOrder order)
|
||||
{
|
||||
if (!HostByteOrderIs(order))
|
||||
ByteReverse(out, in, bc);
|
||||
else if (out != in)
|
||||
memcpy(out, in, bc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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>
|
||||
inline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in,
|
||||
word32 inlen)
|
||||
{
|
||||
const unsigned int U = sizeof(T);
|
||||
assert(inlen <= outlen*U);
|
||||
memcpy(out, in, inlen);
|
||||
memset((byte *)out+inlen, 0, outlen*U-inlen);
|
||||
ByteReverseIf(out, out, RoundUpToMultipleOf(inlen, U), order);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// disable conversion warning
|
||||
#pragma warning(disable:4244)
|
||||
#endif
|
||||
|
||||
|
||||
inline byte UnalignedGetWordNonTemplate(ByteOrder order, const byte *block,
|
||||
byte*)
|
||||
{
|
||||
return block[0];
|
||||
}
|
||||
|
||||
inline word16 UnalignedGetWordNonTemplate(ByteOrder order, const byte* block,
|
||||
word16*)
|
||||
{
|
||||
return (order == BigEndianOrder)
|
||||
? block[1] | (block[0] << 8)
|
||||
: block[0] | (block[1] << 8);
|
||||
}
|
||||
|
||||
inline word32 UnalignedGetWordNonTemplate(ByteOrder order, const byte* block,
|
||||
word32*)
|
||||
{
|
||||
return (order == BigEndianOrder)
|
||||
? word32(block[3]) | (word32(block[2]) << 8) | (word32(block[1]) << 16)
|
||||
| (word32(block[0]) << 24)
|
||||
: word32(block[0]) | (word32(block[1]) << 8) | (word32(block[2]) << 16)
|
||||
| (word32(block[3]) << 24);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T UnalignedGetWord(ByteOrder order, const byte *block, T* dummy = 0)
|
||||
{
|
||||
return UnalignedGetWordNonTemplate(order, block, dummy);
|
||||
}
|
||||
|
||||
inline void UnalignedPutWord(ByteOrder order, byte *block, byte value,
|
||||
const byte *xorBlock = 0)
|
||||
{
|
||||
block[0] = xorBlock ? (value ^ xorBlock[0]) : value;
|
||||
}
|
||||
|
||||
#define GETBYTE(x, y) (unsigned int)byte((x)>>(8*(y)))
|
||||
|
||||
inline void UnalignedPutWord(ByteOrder order, byte *block, word16 value,
|
||||
const byte *xorBlock = 0)
|
||||
{
|
||||
if (order == BigEndianOrder)
|
||||
{
|
||||
block[0] = GETBYTE(value, 1);
|
||||
block[1] = GETBYTE(value, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
block[0] = GETBYTE(value, 0);
|
||||
block[1] = GETBYTE(value, 1);
|
||||
}
|
||||
|
||||
if (xorBlock)
|
||||
{
|
||||
block[0] ^= xorBlock[0];
|
||||
block[1] ^= xorBlock[1];
|
||||
}
|
||||
}
|
||||
|
||||
inline void UnalignedPutWord(ByteOrder order, byte* block, word32 value,
|
||||
const byte* xorBlock = 0)
|
||||
{
|
||||
if (order == BigEndianOrder)
|
||||
{
|
||||
block[0] = GETBYTE(value, 3);
|
||||
block[1] = GETBYTE(value, 2);
|
||||
block[2] = GETBYTE(value, 1);
|
||||
block[3] = GETBYTE(value, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
block[0] = GETBYTE(value, 0);
|
||||
block[1] = GETBYTE(value, 1);
|
||||
block[2] = GETBYTE(value, 2);
|
||||
block[3] = GETBYTE(value, 3);
|
||||
}
|
||||
|
||||
if (xorBlock)
|
||||
{
|
||||
block[0] ^= xorBlock[0];
|
||||
block[1] ^= xorBlock[1];
|
||||
block[2] ^= xorBlock[2];
|
||||
block[3] ^= xorBlock[3];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T GetWord(bool assumeAligned, ByteOrder order, const byte *block)
|
||||
{
|
||||
if (assumeAligned)
|
||||
{
|
||||
assert(IsAligned<T>(block));
|
||||
return ByteReverseIf(*reinterpret_cast<const T *>(block), order);
|
||||
}
|
||||
else
|
||||
return UnalignedGetWord<T>(order, block);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void GetWord(bool assumeAligned, ByteOrder order, T &result,
|
||||
const byte *block)
|
||||
{
|
||||
result = GetWord<T>(assumeAligned, order, block);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void PutWord(bool assumeAligned, ByteOrder order, byte* block, T value,
|
||||
const byte *xorBlock = 0)
|
||||
{
|
||||
if (assumeAligned)
|
||||
{
|
||||
assert(IsAligned<T>(block));
|
||||
if (xorBlock)
|
||||
*reinterpret_cast<T *>(block) = ByteReverseIf(value, order)
|
||||
^ *reinterpret_cast<const T *>(xorBlock);
|
||||
else
|
||||
*reinterpret_cast<T *>(block) = ByteReverseIf(value, order);
|
||||
}
|
||||
else
|
||||
UnalignedPutWord(order, block, value, xorBlock);
|
||||
}
|
||||
|
||||
template <class T, class B, bool A=true>
|
||||
class GetBlock
|
||||
{
|
||||
public:
|
||||
GetBlock(const void *block)
|
||||
: m_block((const byte *)block) {}
|
||||
|
||||
template <class U>
|
||||
inline GetBlock<T, B, A> & operator()(U &x)
|
||||
{
|
||||
TAOCRYPT_COMPILE_ASSERT(sizeof(U) >= sizeof(T));
|
||||
x = GetWord<T>(A, B::ToEnum(), m_block);
|
||||
m_block += sizeof(T);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
const byte *m_block;
|
||||
};
|
||||
|
||||
template <class T, class B, bool A = true>
|
||||
class PutBlock
|
||||
{
|
||||
public:
|
||||
PutBlock(const void *xorBlock, void *block)
|
||||
: m_xorBlock((const byte *)xorBlock), m_block((byte *)block) {}
|
||||
|
||||
template <class U>
|
||||
inline PutBlock<T, B, A> & operator()(U x)
|
||||
{
|
||||
PutWord(A, B::ToEnum(), m_block, (T)x, m_xorBlock);
|
||||
m_block += sizeof(T);
|
||||
if (m_xorBlock)
|
||||
m_xorBlock += sizeof(T);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
const byte *m_xorBlock;
|
||||
byte *m_block;
|
||||
};
|
||||
|
||||
template <class T, class B, bool A=true>
|
||||
struct BlockGetAndPut
|
||||
{
|
||||
// function needed because of C++ grammatical ambiguity between
|
||||
// expression-statements and declarations
|
||||
static inline GetBlock<T, B, A> Get(const void *block)
|
||||
{return GetBlock<T, B, A>(block);}
|
||||
typedef PutBlock<T, B, A> Put;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <bool overflow> struct SafeShifter;
|
||||
|
||||
template<> struct SafeShifter<true>
|
||||
{
|
||||
template <class T>
|
||||
static inline T RightShift(T value, unsigned int bits)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static inline T LeftShift(T value, unsigned int bits)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct SafeShifter<false>
|
||||
{
|
||||
template <class T>
|
||||
static inline T RightShift(T value, unsigned int bits)
|
||||
{
|
||||
return value >> bits;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static inline T LeftShift(T value, unsigned int bits)
|
||||
{
|
||||
return value << bits;
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned int bits, class T>
|
||||
inline T SafeRightShift(T value)
|
||||
{
|
||||
return SafeShifter<(bits>=(8*sizeof(T)))>::RightShift(value, bits);
|
||||
}
|
||||
|
||||
template <unsigned int bits, class T>
|
||||
inline T SafeLeftShift(T value)
|
||||
{
|
||||
return SafeShifter<(bits>=(8*sizeof(T)))>::LeftShift(value, bits);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
word ShiftWordsLeftByBits(word* r, unsigned int n, unsigned int shiftBits)
|
||||
{
|
||||
assert (shiftBits<WORD_BITS);
|
||||
word u, carry=0;
|
||||
if (shiftBits)
|
||||
for (unsigned int i=0; i<n; i++)
|
||||
{
|
||||
u = r[i];
|
||||
r[i] = (u << shiftBits) | carry;
|
||||
carry = u >> (WORD_BITS-shiftBits);
|
||||
}
|
||||
return carry;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
word ShiftWordsRightByBits(word* r, unsigned int n, unsigned int shiftBits)
|
||||
{
|
||||
assert (shiftBits<WORD_BITS);
|
||||
word u, carry=0;
|
||||
if (shiftBits)
|
||||
for (int i=n-1; i>=0; i--)
|
||||
{
|
||||
u = r[i];
|
||||
r[i] = (u >> shiftBits) | carry;
|
||||
carry = u << (WORD_BITS-shiftBits);
|
||||
}
|
||||
return carry;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void ShiftWordsLeftByWords(word* r, unsigned int n, unsigned int shiftWords)
|
||||
{
|
||||
shiftWords = min(shiftWords, n);
|
||||
if (shiftWords)
|
||||
{
|
||||
for (unsigned int i=n-1; i>=shiftWords; i--)
|
||||
r[i] = r[i-shiftWords];
|
||||
SetWords(r, 0, shiftWords);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void ShiftWordsRightByWords(word* r, unsigned int n, unsigned int shiftWords)
|
||||
{
|
||||
shiftWords = min(shiftWords, n);
|
||||
if (shiftWords)
|
||||
{
|
||||
for (unsigned int i=0; i+shiftWords<n; i++)
|
||||
r[i] = r[i+shiftWords];
|
||||
SetWords(r+n-shiftWords, 0, shiftWords);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T1, class T2>
|
||||
inline T1 SaturatingSubtract(T1 a, T2 b)
|
||||
{
|
||||
TAOCRYPT_COMPILE_ASSERT_INSTANCE(T1(-1)>0, 0); // T1 is unsigned type
|
||||
TAOCRYPT_COMPILE_ASSERT_INSTANCE(T2(-1)>0, 1); // T2 is unsigned type
|
||||
return T1((a > b) ? (a - b) : 0);
|
||||
}
|
||||
|
||||
|
||||
// declares
|
||||
unsigned int BytePrecision(word value);
|
||||
unsigned int BitPrecision(word);
|
||||
word Crop(word value, unsigned int size);
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_MISC_HPP
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/* based on Wei Dai's modarith.h from CryptoPP */
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_MODARITH_HPP
|
||||
#define TAO_CRYPT_MODARITH_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "algebra.hpp"
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
// ModularArithmetic
|
||||
class ModularArithmetic : public AbstractRing
|
||||
{
|
||||
public:
|
||||
|
||||
typedef int RandomizationParameter;
|
||||
typedef Integer Element;
|
||||
|
||||
ModularArithmetic(const Integer &modulus = Integer::One())
|
||||
: modulus(modulus), result((word)0, modulus.reg_.size()) {}
|
||||
|
||||
ModularArithmetic(const ModularArithmetic &ma)
|
||||
: AbstractRing(),
|
||||
modulus(ma.modulus), result((word)0, modulus.reg_.size()) {}
|
||||
|
||||
const Integer& GetModulus() const {return modulus;}
|
||||
void SetModulus(const Integer &newModulus)
|
||||
{
|
||||
modulus = newModulus;
|
||||
result.reg_.resize(modulus.reg_.size());
|
||||
}
|
||||
|
||||
virtual bool IsMontgomeryRepresentation() const {return false;}
|
||||
|
||||
virtual Integer ConvertIn(const Integer &a) const
|
||||
{return a%modulus;}
|
||||
|
||||
virtual Integer ConvertOut(const Integer &a) const
|
||||
{return a;}
|
||||
|
||||
const Integer& Half(const Integer &a) const;
|
||||
|
||||
bool Equal(const Integer &a, const Integer &b) const
|
||||
{return a==b;}
|
||||
|
||||
const Integer& Identity() const
|
||||
{return Integer::Zero();}
|
||||
|
||||
const Integer& Add(const Integer &a, const Integer &b) const;
|
||||
|
||||
Integer& Accumulate(Integer &a, const Integer &b) const;
|
||||
|
||||
const Integer& Inverse(const Integer &a) const;
|
||||
|
||||
const Integer& Subtract(const Integer &a, const Integer &b) const;
|
||||
|
||||
Integer& Reduce(Integer &a, const Integer &b) const;
|
||||
|
||||
const Integer& Double(const Integer &a) const
|
||||
{return Add(a, a);}
|
||||
|
||||
const Integer& MultiplicativeIdentity() const
|
||||
{return Integer::One();}
|
||||
|
||||
const Integer& Multiply(const Integer &a, const Integer &b) const
|
||||
{return result1 = a*b%modulus;}
|
||||
|
||||
const Integer& Square(const Integer &a) const
|
||||
{return result1 = a.Squared()%modulus;}
|
||||
|
||||
bool IsUnit(const Integer &a) const
|
||||
{return Integer::Gcd(a, modulus).IsUnit();}
|
||||
|
||||
const Integer& MultiplicativeInverse(const Integer &a) const
|
||||
{return result1 = a.InverseMod(modulus);}
|
||||
|
||||
const Integer& Divide(const Integer &a, const Integer &b) const
|
||||
{return Multiply(a, MultiplicativeInverse(b));}
|
||||
|
||||
Integer CascadeExponentiate(const Integer &x, const Integer &e1,
|
||||
const Integer &y, const Integer &e2) const;
|
||||
|
||||
void SimultaneousExponentiate(Element *results, const Element &base,
|
||||
const Integer *exponents, unsigned int exponentsCount) const;
|
||||
|
||||
unsigned int MaxElementBitLength() const
|
||||
{return (modulus-1).BitCount();}
|
||||
|
||||
unsigned int MaxElementByteLength() const
|
||||
{return (modulus-1).ByteCount();}
|
||||
|
||||
|
||||
static const RandomizationParameter DefaultRandomizationParameter;
|
||||
|
||||
protected:
|
||||
Integer modulus;
|
||||
mutable Integer result, result1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
//! do modular arithmetics in Montgomery representation for increased speed
|
||||
class MontgomeryRepresentation : public ModularArithmetic
|
||||
{
|
||||
public:
|
||||
MontgomeryRepresentation(const Integer &modulus); // modulus must be odd
|
||||
|
||||
bool IsMontgomeryRepresentation() const {return true;}
|
||||
|
||||
Integer ConvertIn(const Integer &a) const
|
||||
{return (a<<(WORD_BITS*modulus.reg_.size()))%modulus;}
|
||||
|
||||
Integer ConvertOut(const Integer &a) const;
|
||||
|
||||
const Integer& MultiplicativeIdentity() const
|
||||
{return result1 = Integer::Power2(WORD_BITS*modulus.reg_.size())%modulus;}
|
||||
|
||||
const Integer& Multiply(const Integer &a, const Integer &b) const;
|
||||
|
||||
const Integer& Square(const Integer &a) const;
|
||||
|
||||
const Integer& MultiplicativeInverse(const Integer &a) const;
|
||||
|
||||
Integer CascadeExponentiate(const Integer &x, const Integer &e1,
|
||||
const Integer &y, const Integer &e2) const
|
||||
{return AbstractRing::CascadeExponentiate(x, e1, y, e2);}
|
||||
|
||||
void SimultaneousExponentiate(Element *results, const Element &base,
|
||||
const Integer *exponents, unsigned int exponentsCount) const
|
||||
{AbstractRing::SimultaneousExponentiate(results, base,
|
||||
exponents, exponentsCount);}
|
||||
|
||||
private:
|
||||
Integer u;
|
||||
mutable AlignedWordBlock workspace;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_MODARITH_HPP
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* modes.hpp provides ECB and CBC modes for block cipher encryption/decryption
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TAO_CRYPT_MODES_HPP
|
||||
#define TAO_CRYPT_MODES_HPP
|
||||
|
||||
#include "misc.hpp"
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
enum Mode { ECB, CBC };
|
||||
|
||||
|
||||
|
||||
// BlockCipher abstraction
|
||||
template<CipherDir DIR, class T, Mode MODE>
|
||||
class BlockCipher {
|
||||
public:
|
||||
BlockCipher() : cipher_(DIR, MODE) {}
|
||||
|
||||
void Process(byte* c, const byte* p, word32 sz)
|
||||
{ cipher_.Process(c, p, sz); }
|
||||
void SetKey(const byte* k, word32 sz)
|
||||
{ cipher_.SetKey(k, sz, DIR); }
|
||||
void SetKey(const byte* k, word32 sz, const byte* iv)
|
||||
{ cipher_.SetKey(k, sz, DIR); cipher_.SetIV(iv); }
|
||||
private:
|
||||
T cipher_;
|
||||
|
||||
BlockCipher(const BlockCipher&); // hide copy
|
||||
BlockCipher& operator=(const BlockCipher&); // and assign
|
||||
};
|
||||
|
||||
|
||||
// Mode Base for block ciphers, static size
|
||||
class Mode_BASE : public virtual_base {
|
||||
public:
|
||||
enum { MaxBlockSz = 16 };
|
||||
|
||||
explicit Mode_BASE(int sz, CipherDir dir, Mode mode)
|
||||
: blockSz_(sz), reg_(reinterpret_cast<byte*>(r_)),
|
||||
tmp_(reinterpret_cast<byte*>(t_)), dir_(dir), mode_(mode)
|
||||
{
|
||||
assert(sz <= MaxBlockSz);
|
||||
}
|
||||
virtual ~Mode_BASE() {}
|
||||
|
||||
virtual void Process(byte*, const byte*, word32);
|
||||
|
||||
void SetIV(const byte* iv) { memcpy(reg_, iv, blockSz_); }
|
||||
protected:
|
||||
int blockSz_;
|
||||
byte* reg_;
|
||||
byte* tmp_;
|
||||
|
||||
word32 r_[MaxBlockSz / sizeof(word32)]; // align reg_ on word32
|
||||
word32 t_[MaxBlockSz / sizeof(word32)]; // align tmp_ on word32
|
||||
|
||||
CipherDir dir_;
|
||||
Mode mode_;
|
||||
|
||||
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& operator=(const Mode_BASE&); // and assign
|
||||
|
||||
private:
|
||||
virtual void ProcessAndXorBlock(const byte*, const byte*, byte*) const = 0;
|
||||
};
|
||||
|
||||
|
||||
inline void Mode_BASE::Process(byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
if (mode_ == ECB)
|
||||
ECB_Process(out, in, sz);
|
||||
else if (mode_ == CBC)
|
||||
{
|
||||
if (dir_ == ENCRYPTION)
|
||||
CBC_Encrypt(out, in, sz);
|
||||
else
|
||||
CBC_Decrypt(out, in, sz);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ECB Process blocks
|
||||
inline void Mode_BASE::ECB_Process(byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
word32 blocks = sz / blockSz_;
|
||||
|
||||
while (blocks--) {
|
||||
ProcessAndXorBlock(in, 0, out);
|
||||
out += blockSz_;
|
||||
in += blockSz_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CBC Encrypt
|
||||
inline void Mode_BASE::CBC_Encrypt(byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
word32 blocks = sz / blockSz_;
|
||||
|
||||
while (blocks--) {
|
||||
xorbuf(reg_, in, blockSz_);
|
||||
ProcessAndXorBlock(reg_, 0, reg_);
|
||||
memcpy(out, reg_, blockSz_);
|
||||
out += blockSz_;
|
||||
in += blockSz_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CBC Decrypt
|
||||
inline void Mode_BASE::CBC_Decrypt(byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
word32 blocks = sz / blockSz_;
|
||||
byte hold[MaxBlockSz];
|
||||
|
||||
while (blocks--) {
|
||||
memcpy(tmp_, in, blockSz_);
|
||||
ProcessAndXorBlock(tmp_, 0, out);
|
||||
xorbuf(out, reg_, blockSz_);
|
||||
memcpy(hold, reg_, blockSz_); // swap reg_ and tmp_
|
||||
memcpy(reg_, tmp_, blockSz_);
|
||||
memcpy(tmp_, hold, blockSz_);
|
||||
out += blockSz_;
|
||||
in += blockSz_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // TAO_CRYPT_MODES_HPP
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2007 MySQL AB
|
||||
|
||||
This program 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; version 2 of the License.
|
||||
|
||||
This program 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; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
MA 02110-1301 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 = 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
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user