Merge neptunus.(none):/home/msvensson/mysql/bug20589/my50-bug20589
into neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
This commit is contained in:
commit
af5882a175
@ -334,6 +334,7 @@ client/sql_string.cpp
|
||||
client/ssl_test
|
||||
client/thimble
|
||||
client/thread_test
|
||||
client/tmp.diff
|
||||
client_debug/*
|
||||
client_release/*
|
||||
client_test
|
||||
@ -697,6 +698,7 @@ mysql-test/r/*.err
|
||||
mysql-test/r/*.log
|
||||
mysql-test/r/*.out
|
||||
mysql-test/r/*.reject
|
||||
mysql-test/r/*.warnings
|
||||
mysql-test/r/alter_table.err
|
||||
mysql-test/r/archive.err
|
||||
mysql-test/r/bdb-alter-table-1.err
|
||||
@ -762,10 +764,12 @@ mysql-test/r/rpl000016.eval
|
||||
mysql-test/r/rpl_log.eval
|
||||
mysql-test/r/slave-running.eval
|
||||
mysql-test/r/slave-stopped.eval
|
||||
mysql-test/r/tmp.result
|
||||
mysql-test/r/udf.log
|
||||
mysql-test/share/mysql
|
||||
mysql-test/std_data/*.pem
|
||||
mysql-test/t/index_merge.load
|
||||
mysql-test/t/tmp.test
|
||||
mysql-test/var
|
||||
mysql-test/var/*
|
||||
mysql.kdevprj
|
||||
|
@ -56,9 +56,9 @@ global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wch
|
||||
#debug_extra_warnings="-Wuninitialized"
|
||||
c_warnings="$global_warnings -Wunused"
|
||||
cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor"
|
||||
base_max_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-big-tables --with-blackhole-storage-engine --with-federated-storage-engine --with-csv-storage-engine $SSL_LIBRARY"
|
||||
base_max_no_ndb_configs="--with-innodb --with-berkeley-db --without-ndbcluster --with-archive-storage-engine --with-big-tables --with-blackhole-storage-engine --with-federated-storage-engine --with-csv-storage-engine $SSL_LIBRARY"
|
||||
max_leave_isam_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-federated-storage-engine --with-blackhole-storage-engine --with-csv-storage-engine $SSL_LIBRARY --with-embedded-server --with-big-tables"
|
||||
base_max_configs="--with-innodb --with-ndbcluster --with-archive-storage-engine --with-big-tables --with-blackhole-storage-engine --with-federated-storage-engine --with-csv-storage-engine $SSL_LIBRARY"
|
||||
base_max_no_ndb_configs="--with-innodb --without-ndbcluster --with-archive-storage-engine --with-big-tables --with-blackhole-storage-engine --with-federated-storage-engine --with-csv-storage-engine $SSL_LIBRARY"
|
||||
max_leave_isam_configs="--with-innodb --with-ndbcluster --with-archive-storage-engine --with-federated-storage-engine --with-blackhole-storage-engine --with-csv-storage-engine $SSL_LIBRARY --with-embedded-server --with-big-tables"
|
||||
max_configs="$base_max_configs --with-embedded-server"
|
||||
max_no_ndb_configs="$base_max_no_ndb_configs --with-embedded-server"
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
45214442pBGT9KuZEGixBH71jTzbOA
|
||||
45214a07hVsIGwvwa-WrO-jpeaSwVw
|
||||
452a92d0-31-8wSzSfZi165fcGcXPA
|
||||
452c6c6dAjuNghfc1ObZ_UQ5SCl85g
|
||||
4538a7b0EbDHHkWPbIwxO6ZIDdg6Dg
|
||||
454a7ef8gdvE_ddMlJyghvOAkKPNOQ
|
||||
454bb488ijVLOUK_GFjcoISE0GxPUA
|
||||
454bb9a8AwlGRC_wWLS2sNMoRBMRGw
|
||||
|
@ -35,9 +35,17 @@ fi
|
||||
|
||||
CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet`
|
||||
CSETKEY=`bk -R prs -r+ -h -d':KEY:' ChangeSet`
|
||||
BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/\1/p'`
|
||||
WL=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Ww][Ll] *# *\([0-9][0-9]*\).*$/ WL#\1/p'`
|
||||
|
||||
#
|
||||
# composing subject lines of commit mails.
|
||||
# if a fix targets to a WL and there is a bug referred
|
||||
# then X-Bug mail header will contain the first found bug's number
|
||||
#
|
||||
BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | \
|
||||
sed -ne 's/[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/BUG#\1/
|
||||
s/.*BUG#\([0-9][0-9]*\)/\1/p'`
|
||||
WL=`bk -R prs -r+ -h -d':C:' ChangeSet | \
|
||||
sed -ne 's/[Ww][Ll] *# *\([0-9][0-9]*\).*$/WL#\1/
|
||||
s/.*\(WL#[0-9][0-9]*\)/ \1/p'`
|
||||
if [ "$BUG" = "" ]
|
||||
then
|
||||
TO=dev-public@mysql.com
|
||||
|
@ -26,7 +26,7 @@ all-local: $(TXT_FILES)
|
||||
# make sure that "make install" installs the info page, too
|
||||
# automake only seems to take care of this automatically,
|
||||
# if we're building the info page from texi directly.
|
||||
install-data-hook: mysql.info
|
||||
install-data-hook: $(srcdir)/mysql.info
|
||||
$(mkinstalldirs) $(DESTDIR)$(infodir)
|
||||
$(INSTALL_DATA) $(srcdir)/mysql.info $(DESTDIR)$(infodir)
|
||||
|
||||
@ -44,23 +44,23 @@ CLEAN_FILES: $(TXT_FILES)
|
||||
|
||||
GT = $(srcdir)/Support/generate-text-files.pl
|
||||
|
||||
../INSTALL-SOURCE: mysql.info $(GT)
|
||||
perl -w $(GT) mysql.info "installing-source" "windows-source-build" > $@
|
||||
../INSTALL-SOURCE: $(srcdir)/mysql.info $(GT)
|
||||
perl -w $(GT) $(srcdir)/mysql.info "installing-source" "windows-source-build" > $@
|
||||
|
||||
../INSTALL-WIN-SOURCE: mysql.info $(GT)
|
||||
perl -w $(GT) mysql.info "windows-source-build" "post-installation" > $@
|
||||
../INSTALL-WIN-SOURCE: $(srcdir)/mysql.info $(GT)
|
||||
perl -w $(GT) $(srcdir)/mysql.info "windows-source-build" "post-installation" > $@
|
||||
|
||||
# We put the description for the binary installation here so that
|
||||
# people who download source wont have to see it. It is moved up to
|
||||
# the toplevel by the script that makes the binary tar files.
|
||||
INSTALL-BINARY: mysql.info $(GT)
|
||||
perl -w $(GT) mysql.info "installing-binary" "installing-source" > $@
|
||||
INSTALL-BINARY: $(srcdir)/mysql.info $(GT)
|
||||
perl -w $(GT) $(srcdir)/mysql.info "installing-binary" "installing-source" > $@
|
||||
|
||||
../EXCEPTIONS-CLIENT: mysql.info $(GT)
|
||||
perl -w $(GT) mysql.info "mysql-floss-license-exception" "function-index" > $@
|
||||
../EXCEPTIONS-CLIENT: $(srcdir)/mysql.info $(GT)
|
||||
perl -w $(GT) $(srcdir)/mysql.info "mysql-floss-license-exception" "function-index" > $@
|
||||
|
||||
../support-files/MacOSX/ReadMe.txt: mysql.info $(GT)
|
||||
perl -w $(GT) mysql.info "mac-os-x-installation" "netware-installation" > $@
|
||||
../support-files/MacOSX/ReadMe.txt: $(srcdir)/mysql.info $(GT)
|
||||
perl -w $(GT) $(srcdir)/mysql.info "mac-os-x-installation" "netware-installation" > $@
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
||||
|
@ -129,5 +129,6 @@ test-force-mem:
|
||||
./mysql-test-run --force --mem && \
|
||||
./mysql-test-run --ps-protocol --force --mem
|
||||
|
||||
#used by autopush.pl to run memory based tests
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug yassl taocrypt zlib wsock
|
||||
ADD_EXECUTABLE(mysqlimport mysqlimport.c)
|
||||
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug yassl taocrypt zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c)
|
||||
ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c)
|
||||
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient mysys dbug yassl taocrypt zlib wsock32)
|
||||
|
||||
ADD_EXECUTABLE(mysqlshow mysqlshow.c)
|
||||
|
@ -49,7 +49,8 @@ mysqlshow_SOURCES= mysqlshow.c
|
||||
mysqldump_SOURCES= mysqldump.c my_user.c \
|
||||
$(top_srcdir)/mysys/mf_getdate.c
|
||||
mysqlimport_SOURCES= mysqlimport.c
|
||||
mysql_upgrade_SOURCES= mysql_upgrade.c
|
||||
mysql_upgrade_SOURCES= mysql_upgrade.c \
|
||||
$(top_srcdir)/mysys/my_getpagesize.c
|
||||
sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc
|
||||
strings_src=decimal.c
|
||||
|
||||
|
@ -51,5 +51,6 @@ enum options_client
|
||||
#endif
|
||||
OPT_TRIGGERS,
|
||||
OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE,
|
||||
OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_SSL_VERIFY_SERVER_CERT
|
||||
OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_SSL_VERIFY_SERVER_CERT,
|
||||
OPT_DEBUG_INFO
|
||||
};
|
||||
|
@ -819,10 +819,23 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
default_charset_used= 1;
|
||||
break;
|
||||
case OPT_DELIMITER:
|
||||
if (argument == disabled_my_option)
|
||||
if (argument == disabled_my_option)
|
||||
{
|
||||
strmov(delimiter, DEFAULT_DELIMITER);
|
||||
else
|
||||
strmake(delimiter, argument, sizeof(delimiter) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check that delimiter does not contain a backslash */
|
||||
if (!strstr(argument, "\\"))
|
||||
{
|
||||
strmake(delimiter, argument, sizeof(delimiter) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
put_info("DELIMITER cannot contain a backslash character", INFO_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
delimiter_length= (uint)strlen(delimiter);
|
||||
delimiter_str= delimiter;
|
||||
break;
|
||||
@ -3041,6 +3054,14 @@ com_delimiter(String *buffer __attribute__((unused)), char *line)
|
||||
INFO_ERROR);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strstr(tmp, "\\"))
|
||||
{
|
||||
put_info("DELIMITER cannot contain a backslash character", INFO_ERROR);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
strmake(delimiter, tmp, sizeof(delimiter) - 1);
|
||||
delimiter_length= (int)strlen(delimiter);
|
||||
delimiter_str= delimiter;
|
||||
|
@ -375,22 +375,24 @@ static int comp_names(struct fileinfo *a, struct fileinfo *b)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
find_file(const char *name, const char *root, uint flags, char *result, size_t len, ...)
|
||||
static int find_file(const char *name, const char *root,
|
||||
uint flags, char *result, size_t len, ...)
|
||||
{
|
||||
int ret;
|
||||
int ret= 1;
|
||||
va_list va;
|
||||
FILEINFO key= { (char*)name, NULL };
|
||||
const char *subdir;
|
||||
char *cp;
|
||||
|
||||
FILEINFO key;
|
||||
|
||||
/* Init key with name of the file to look for */
|
||||
key.name= (char*)name;
|
||||
|
||||
DBUG_ASSERT(root != NULL);
|
||||
|
||||
cp= strmake(result, root, len);
|
||||
if (cp[-1] != FN_LIBCHAR)
|
||||
*cp++= FN_LIBCHAR;
|
||||
|
||||
ret= 1;
|
||||
va_start(va, len);
|
||||
subdir= (!(flags & MY_SEARCH_SELF)) ? va_arg(va, char *) : "";
|
||||
while (subdir)
|
||||
@ -597,7 +599,7 @@ fix_priv_tables:
|
||||
|
||||
if (find_file(MYSQL_FIX_PRIV_TABLES_NAME, basedir, MYF(0),
|
||||
path, sizeof(path),
|
||||
"support_files", "share/mysql", "scripts",
|
||||
"support_files", "share", "share/mysql", "scripts",
|
||||
NullS)
|
||||
&& find_file(MYSQL_FIX_PRIV_TABLES_NAME, "/usr/local/mysql", MYF(0),
|
||||
path, sizeof(path),
|
||||
|
@ -1088,7 +1088,7 @@ could be out of memory");
|
||||
}
|
||||
if (len < 8 && net->read_pos[0] == 254)
|
||||
break; // end of data
|
||||
DBUG_PRINT("info",( "len= %u, net->read_pos[5] = %d\n",
|
||||
DBUG_PRINT("info",( "len: %lu, net->read_pos[5]: %d\n",
|
||||
len, net->read_pos[5]));
|
||||
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
|
||||
len - 1, &error_msg,
|
||||
|
@ -30,14 +30,14 @@
|
||||
** master/autocommit code by Brian Aker <brian@tangent.org>
|
||||
** SSL by
|
||||
** Andrei Errapart <andreie@no.spam.ee>
|
||||
** Tõnu Samuel <tonu@please.do.not.remove.this.spam.ee>
|
||||
** Tõnu Samuel <tonu@please.do.not.remove.this.spam.ee>
|
||||
** XML by Gary Huntress <ghuntress@mediaone.net> 10/10/01, cleaned up
|
||||
** and adapted to mysqldump 05/11/01 by Jani Tolonen
|
||||
** Added --single-transaction option 06/06/2002 by Peter Zaitsev
|
||||
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
|
||||
*/
|
||||
|
||||
#define DUMP_VERSION "10.10"
|
||||
#define DUMP_VERSION "10.11"
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
@ -99,7 +99,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
|
||||
opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1;
|
||||
static ulong opt_max_allowed_packet, opt_net_buffer_length;
|
||||
static MYSQL mysql_connection,*mysql=0;
|
||||
static my_bool insert_pat_inited=0;
|
||||
static my_bool insert_pat_inited= 0, info_flag;
|
||||
static DYNAMIC_STRING insert_pat;
|
||||
static char *opt_password=0,*current_user=0,
|
||||
*current_host=0,*path=0,*fields_terminated=0,
|
||||
@ -107,6 +107,7 @@ static char *opt_password=0,*current_user=0,
|
||||
*where=0, *order_by=0,
|
||||
*opt_compatible_mode_str= 0,
|
||||
*err_ptr= 0;
|
||||
static char **defaults_argv= 0;
|
||||
static char compatible_mode_normal_str[255];
|
||||
static ulong opt_compatible_mode= 0;
|
||||
#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
|
||||
@ -116,7 +117,7 @@ static my_string opt_mysql_unix_port=0;
|
||||
static int first_error=0;
|
||||
static DYNAMIC_STRING extended_row;
|
||||
#include <sslopt-vars.h>
|
||||
FILE *md_result_file;
|
||||
FILE *md_result_file= 0;
|
||||
#ifdef HAVE_SMEM
|
||||
static char *shared_memory_base_name=0;
|
||||
#endif
|
||||
@ -215,6 +216,8 @@ static struct my_option my_long_options[] =
|
||||
{"debug", '#', "Output debug log", (gptr*) &default_dbug_option,
|
||||
(gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#endif
|
||||
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag,
|
||||
(gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"default-character-set", OPT_DEFAULT_CHARSET,
|
||||
"Set the default character set.", (gptr*) &default_charset,
|
||||
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@ -628,14 +631,6 @@ byte* get_table_key(const char *entry, uint *length,
|
||||
}
|
||||
|
||||
|
||||
void init_table_rule_hash(HASH* h)
|
||||
{
|
||||
if (hash_init(h, charset_info, 16, 0, 0,
|
||||
(hash_get_key) get_table_key,
|
||||
(hash_free_key) free_table_ent, 0))
|
||||
exit(EX_EOM);
|
||||
}
|
||||
|
||||
static my_bool
|
||||
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
char *argument)
|
||||
@ -678,6 +673,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
break;
|
||||
case '#':
|
||||
DBUG_PUSH(argument ? argument : default_dbug_option);
|
||||
info_flag= 1;
|
||||
break;
|
||||
#include <sslopt-case.h>
|
||||
case 'V': print_version(); exit(0);
|
||||
@ -718,9 +714,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
fprintf(stderr, "Illegal use of option --ignore-table=<database>.<table>\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!hash_inited(&ignore_table))
|
||||
init_table_rule_hash(&ignore_table);
|
||||
|
||||
if (my_hash_insert(&ignore_table, (byte*)my_strdup(argument, MYF(0))))
|
||||
exit(EX_EOM);
|
||||
break;
|
||||
@ -796,9 +789,21 @@ static int get_options(int *argc, char ***argv)
|
||||
|
||||
md_result_file= stdout;
|
||||
load_defaults("my",load_default_groups,argc,argv);
|
||||
defaults_argv= *argv;
|
||||
|
||||
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
|
||||
exit(ho_error);
|
||||
if (hash_init(&ignore_table, charset_info, 16, 0, 0,
|
||||
(hash_get_key) get_table_key,
|
||||
(hash_free_key) free_table_ent, 0))
|
||||
return(EX_EOM);
|
||||
/* Don't copy cluster internal log tables */
|
||||
if (my_hash_insert(&ignore_table,
|
||||
(byte*) my_strdup("mysql.apply_status", MYF(MY_WME))) ||
|
||||
my_hash_insert(&ignore_table,
|
||||
(byte*) my_strdup("mysql.schema", MYF(MY_WME))))
|
||||
return(EX_EOM);
|
||||
|
||||
if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
|
||||
return(ho_error);
|
||||
|
||||
*mysql_params->p_max_allowed_packet= opt_max_allowed_packet;
|
||||
*mysql_params->p_net_buffer_length= opt_net_buffer_length;
|
||||
@ -810,7 +815,7 @@ static int get_options(int *argc, char ***argv)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: You must use option --tab with --fields-...\n", my_progname);
|
||||
return(1);
|
||||
return(EX_USAGE);
|
||||
}
|
||||
|
||||
/* Ensure consistency of the set of binlog & locking options */
|
||||
@ -820,7 +825,7 @@ static int get_options(int *argc, char ***argv)
|
||||
{
|
||||
fprintf(stderr, "%s: You can't use --single-transaction and "
|
||||
"--lock-all-tables at the same time.\n", my_progname);
|
||||
return(1);
|
||||
return(EX_USAGE);
|
||||
}
|
||||
if (opt_master_data)
|
||||
opt_lock_all_tables= !opt_single_transaction;
|
||||
@ -829,14 +834,14 @@ static int get_options(int *argc, char ***argv)
|
||||
if (enclosed && opt_enclosed)
|
||||
{
|
||||
fprintf(stderr, "%s: You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n", my_progname);
|
||||
return(1);
|
||||
return(EX_USAGE);
|
||||
}
|
||||
if ((opt_databases || opt_alldbs) && path)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: --databases or --all-databases can't be used with --tab.\n",
|
||||
my_progname);
|
||||
return(1);
|
||||
return(EX_USAGE);
|
||||
}
|
||||
if (strcmp(default_charset, charset_info->csname) &&
|
||||
!(charset_info= get_charset_by_csname(default_charset,
|
||||
@ -845,7 +850,7 @@ static int get_options(int *argc, char ***argv)
|
||||
if ((*argc < 1 && !opt_alldbs) || (*argc > 0 && opt_alldbs))
|
||||
{
|
||||
short_usage();
|
||||
return 1;
|
||||
return EX_USAGE;
|
||||
}
|
||||
if (tty_password)
|
||||
opt_password=get_tty_password(NullS);
|
||||
@ -920,6 +925,23 @@ static FILE* open_sql_file_for_table(const char* table)
|
||||
}
|
||||
|
||||
|
||||
static void free_resources()
|
||||
{
|
||||
if (md_result_file && md_result_file != stdout)
|
||||
my_fclose(md_result_file, MYF(0));
|
||||
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
|
||||
if (hash_inited(&ignore_table))
|
||||
hash_free(&ignore_table);
|
||||
if (extended_insert)
|
||||
dynstr_free(&extended_row);
|
||||
if (insert_pat_inited)
|
||||
dynstr_free(&insert_pat);
|
||||
if (defaults_argv)
|
||||
free_defaults(defaults_argv);
|
||||
my_end(info_flag ? MY_CHECK_ERROR : 0);
|
||||
}
|
||||
|
||||
|
||||
static void safe_exit(int error)
|
||||
{
|
||||
if (!first_error)
|
||||
@ -928,18 +950,19 @@ static void safe_exit(int error)
|
||||
return;
|
||||
if (mysql)
|
||||
mysql_close(mysql);
|
||||
free_resources();
|
||||
exit(error);
|
||||
}
|
||||
/* safe_exit */
|
||||
|
||||
|
||||
/*
|
||||
** dbConnect -- connects to the host and selects DB.
|
||||
db_connect -- connects to the host and selects DB.
|
||||
*/
|
||||
static int dbConnect(char *host, char *user,char *passwd)
|
||||
|
||||
static int connect_to_db(char *host, char *user,char *passwd)
|
||||
{
|
||||
char buff[20+FN_REFLEN];
|
||||
DBUG_ENTER("dbConnect");
|
||||
DBUG_ENTER("connect_to_db");
|
||||
|
||||
verbose_msg("-- Connecting to %s...\n", host ? host : "localhost");
|
||||
mysql_init(&mysql_connection);
|
||||
@ -960,11 +983,11 @@ static int dbConnect(char *host, char *user,char *passwd)
|
||||
#endif
|
||||
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
|
||||
if (!(mysql= mysql_real_connect(&mysql_connection,host,user,passwd,
|
||||
NULL,opt_mysql_port,opt_mysql_unix_port,
|
||||
0)))
|
||||
NULL,opt_mysql_port,opt_mysql_unix_port,
|
||||
0)))
|
||||
{
|
||||
DB_error(&mysql_connection, "when trying to connect");
|
||||
return 1;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
/*
|
||||
Don't dump SET NAMES with a pre-4.1 server (bug#7997).
|
||||
@ -981,7 +1004,7 @@ static int dbConnect(char *host, char *user,char *passwd)
|
||||
if (mysql_query_with_error_report(mysql, 0, buff))
|
||||
{
|
||||
safe_exit(EX_MYSQLERR);
|
||||
return 1;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
/*
|
||||
set time_zone to UTC to allow dumping date types between servers with
|
||||
@ -993,11 +1016,11 @@ static int dbConnect(char *host, char *user,char *passwd)
|
||||
if (mysql_query_with_error_report(mysql, 0, buff))
|
||||
{
|
||||
safe_exit(EX_MYSQLERR);
|
||||
return 1;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} /* dbConnect */
|
||||
DBUG_RETURN(0);
|
||||
} /* connect_to_db */
|
||||
|
||||
|
||||
/*
|
||||
@ -1519,7 +1542,11 @@ static uint get_table_structure(char *table, char *db, char *table_type,
|
||||
{
|
||||
complete_insert= opt_complete_insert;
|
||||
if (!insert_pat_inited)
|
||||
insert_pat_inited= init_dynamic_string(&insert_pat, "", 1024, 1024);
|
||||
{
|
||||
insert_pat_inited= 1;
|
||||
if (init_dynamic_string(&insert_pat, "", 1024, 1024))
|
||||
safe_exit(EX_MYSQLERR);
|
||||
}
|
||||
else
|
||||
dynstr_set(&insert_pat, "");
|
||||
}
|
||||
@ -1988,7 +2015,7 @@ continue_xml:
|
||||
|
||||
*/
|
||||
|
||||
static void dump_triggers_for_table (char *table, char *db)
|
||||
static void dump_triggers_for_table(char *table, char *db)
|
||||
{
|
||||
char *result_table;
|
||||
char name_buff[NAME_LEN*4+3], table_buff[NAME_LEN*2+3];
|
||||
@ -2176,7 +2203,7 @@ static void dump_table(char *table, char *db)
|
||||
The "table" could be a view. If so, we don't do anything here.
|
||||
*/
|
||||
if (strcmp (table_type, "VIEW") == 0)
|
||||
return;
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
/* Check --no-data flag */
|
||||
if (opt_no_data)
|
||||
@ -2693,6 +2720,8 @@ static int dump_databases(char **db_names)
|
||||
{
|
||||
int result=0;
|
||||
char **db;
|
||||
DBUG_ENTER("dump_databases");
|
||||
|
||||
for (db= db_names ; *db ; db++)
|
||||
{
|
||||
if (dump_all_tables_in_db(*db))
|
||||
@ -2706,7 +2735,7 @@ static int dump_databases(char **db_names)
|
||||
result=1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
DBUG_RETURN(result);
|
||||
} /* dump_databases */
|
||||
|
||||
|
||||
@ -2721,7 +2750,7 @@ RETURN VALUES
|
||||
0 Success.
|
||||
1 Failure.
|
||||
*/
|
||||
int init_dumping_views(char *qdatabase)
|
||||
int init_dumping_views(char *qdatabase __attribute__((unused)))
|
||||
{
|
||||
return 0;
|
||||
} /* init_dumping_views */
|
||||
@ -2818,12 +2847,11 @@ static int init_dumping(char *database, int init_func(char*))
|
||||
} /* init_dumping */
|
||||
|
||||
|
||||
/* Return 1 if we should copy the table */
|
||||
|
||||
my_bool include_table(byte* hash_key, uint len)
|
||||
{
|
||||
if (hash_search(&ignore_table, (byte*) hash_key, len))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return !hash_search(&ignore_table, (byte*) hash_key, len);
|
||||
}
|
||||
|
||||
|
||||
@ -2832,16 +2860,16 @@ static int dump_all_tables_in_db(char *database)
|
||||
char *table;
|
||||
uint numrows;
|
||||
char table_buff[NAME_LEN*2+3];
|
||||
|
||||
char hash_key[2*NAME_LEN+2]; /* "db.tablename" */
|
||||
char *afterdot;
|
||||
int using_mysql_db= my_strcasecmp(&my_charset_latin1, database, "mysql");
|
||||
DBUG_ENTER("dump_all_tables_in_db");
|
||||
|
||||
afterdot= strmov(hash_key, database);
|
||||
*afterdot++= '.';
|
||||
|
||||
if (init_dumping(database, init_dumping_tables))
|
||||
return 1;
|
||||
DBUG_RETURN(1);
|
||||
if (opt_xml)
|
||||
print_xml_tag(md_result_file, "", "\n", "database", "name=", database, NullS);
|
||||
if (lock_tables)
|
||||
@ -2895,7 +2923,7 @@ static int dump_all_tables_in_db(char *database)
|
||||
fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n");
|
||||
fprintf(md_result_file,"\n/*! FLUSH PRIVILEGES */;\n");
|
||||
}
|
||||
return 0;
|
||||
DBUG_RETURN(0);
|
||||
} /* dump_all_tables_in_db */
|
||||
|
||||
|
||||
@ -3257,7 +3285,6 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
|
||||
|
||||
|
||||
/*
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
Check if we the table is one of the table types that should be ignored:
|
||||
@ -3297,8 +3324,8 @@ char check_if_ignore_table(const char *table_name, char *table_type)
|
||||
{
|
||||
if (mysql_errno(mysql) != ER_PARSE_ERROR)
|
||||
{ /* If old MySQL version */
|
||||
verbose_msg("-- Warning: Couldn't get status information for " \
|
||||
"table %s (%s)\n", table_name,mysql_error(mysql));
|
||||
verbose_msg("-- Warning: Couldn't get status information for "
|
||||
"table %s (%s)\n", table_name, mysql_error(mysql));
|
||||
DBUG_RETURN(result); /* assume table is ok */
|
||||
}
|
||||
}
|
||||
@ -3653,19 +3680,24 @@ static my_bool get_view_structure(char *table, char* db)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int exit_code;
|
||||
MY_INIT("mysqldump");
|
||||
|
||||
compatible_mode_normal_str[0]= 0;
|
||||
default_charset= (char *)mysql_universal_client_charset;
|
||||
bzero((char*) &ignore_table, sizeof(ignore_table));
|
||||
|
||||
if (get_options(&argc, &argv))
|
||||
exit_code= get_options(&argc, &argv);
|
||||
if (exit_code)
|
||||
{
|
||||
my_end(0);
|
||||
exit(EX_USAGE);
|
||||
free_resources(0);
|
||||
exit(exit_code);
|
||||
}
|
||||
if (dbConnect(current_host, current_user, opt_password))
|
||||
if (connect_to_db(current_host, current_user, opt_password))
|
||||
{
|
||||
free_resources(0);
|
||||
exit(EX_MYSQLERR);
|
||||
}
|
||||
if (!path)
|
||||
write_header(md_result_file, *argv);
|
||||
|
||||
@ -3712,15 +3744,6 @@ err:
|
||||
dbDisconnect(current_host);
|
||||
if (!path)
|
||||
write_footer(md_result_file);
|
||||
if (md_result_file != stdout)
|
||||
my_fclose(md_result_file, MYF(0));
|
||||
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
|
||||
if (hash_inited(&ignore_table))
|
||||
hash_free(&ignore_table);
|
||||
if (extended_insert)
|
||||
dynstr_free(&extended_row);
|
||||
if (insert_pat_inited)
|
||||
dynstr_free(&insert_pat);
|
||||
my_end(0);
|
||||
free_resources();
|
||||
return(first_error);
|
||||
} /* main */
|
||||
|
@ -29,9 +29,10 @@
|
||||
Matt Wagner <matt@mysql.com>
|
||||
Monty
|
||||
Jani
|
||||
Holyfoot
|
||||
*/
|
||||
|
||||
#define MTEST_VERSION "3.0"
|
||||
#define MTEST_VERSION "3.1"
|
||||
|
||||
#include <my_global.h>
|
||||
#include <mysql_embed.h>
|
||||
@ -220,6 +221,12 @@ struct st_connection
|
||||
MYSQL* util_mysql;
|
||||
char *name;
|
||||
MYSQL_STMT* stmt;
|
||||
|
||||
const char *cur_query;
|
||||
int cur_query_len;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
int query_done;
|
||||
};
|
||||
struct st_connection connections[128];
|
||||
struct st_connection* cur_con, *next_con, *connections_end;
|
||||
@ -264,6 +271,7 @@ enum enum_commands {
|
||||
Q_DISABLE_PARSING, Q_ENABLE_PARSING,
|
||||
Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST,
|
||||
Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT,
|
||||
Q_CHMOD_FILE,
|
||||
|
||||
Q_UNKNOWN, /* Unknown command. */
|
||||
Q_COMMENT, /* Comments, ignored. */
|
||||
@ -344,8 +352,10 @@ const char *command_names[]=
|
||||
"copy_file",
|
||||
"perl",
|
||||
"die",
|
||||
|
||||
/* Don't execute any more commands, compare result */
|
||||
"exit",
|
||||
"chmod",
|
||||
0
|
||||
};
|
||||
|
||||
@ -458,7 +468,6 @@ void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
|
||||
int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
|
||||
my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
|
||||
#endif
|
||||
|
||||
void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
|
||||
int len);
|
||||
void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
|
||||
@ -469,7 +478,56 @@ void handle_error(struct st_command*,
|
||||
const char *err_sqlstate, DYNAMIC_STRING *ds);
|
||||
void handle_no_error(struct st_command*);
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
/*
|
||||
send_one_query executes query in separate thread what is
|
||||
necessary in embedded library to run 'send' in proper way.
|
||||
This implementation doesn't handle errors returned
|
||||
by mysql_send_query. It's technically possible, though
|
||||
i don't see where it is needed.
|
||||
*/
|
||||
pthread_handler_t send_one_query(void *arg)
|
||||
{
|
||||
struct st_connection *cn= (struct st_connection*)arg;
|
||||
|
||||
mysql_thread_init();
|
||||
VOID(mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len));
|
||||
|
||||
mysql_thread_end();
|
||||
pthread_mutex_lock(&cn->mutex);
|
||||
cn->query_done= 1;
|
||||
VOID(pthread_cond_signal(&cn->cond));
|
||||
pthread_mutex_unlock(&cn->mutex);
|
||||
pthread_exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_send_query(struct st_connection *cn, const char *q, int q_len,
|
||||
int flags)
|
||||
{
|
||||
pthread_t tid;
|
||||
|
||||
if (flags & QUERY_REAP_FLAG)
|
||||
return mysql_send_query(&cn->mysql, q, q_len);
|
||||
|
||||
if (pthread_mutex_init(&cn->mutex, NULL) ||
|
||||
pthread_cond_init(&cn->cond, NULL))
|
||||
die("Error in the thread library");
|
||||
|
||||
cn->cur_query= q;
|
||||
cn->cur_query_len= q_len;
|
||||
cn->query_done= 0;
|
||||
if (pthread_create(&tid, NULL, send_one_query, (void*)cn))
|
||||
die("Cannot start new thread for query");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /*EMBEDDED_LIBRARY*/
|
||||
|
||||
#define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len)
|
||||
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
|
||||
void do_eval(DYNAMIC_STRING *query_eval, const char *query,
|
||||
const char *query_end, my_bool pass_through_escape_chars)
|
||||
@ -1752,6 +1810,46 @@ void do_copy_file(struct st_command *command)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SYNOPSIS
|
||||
do_chmod_file
|
||||
command command handle
|
||||
|
||||
DESCRIPTION
|
||||
chmod <octal> <file>
|
||||
Change file permission of <file>
|
||||
|
||||
*/
|
||||
|
||||
void do_chmod_file(struct st_command *command)
|
||||
{
|
||||
ulong mode= 0;
|
||||
static DYNAMIC_STRING ds_mode;
|
||||
static DYNAMIC_STRING ds_file;
|
||||
const struct command_arg chmod_file_args[] = {
|
||||
"mode", ARG_STRING, TRUE, &ds_mode, "Mode of file",
|
||||
"file", ARG_STRING, TRUE, &ds_file, "Filename of file to modify"
|
||||
};
|
||||
DBUG_ENTER("do_chmod_file");
|
||||
|
||||
check_command_args(command, command->first_argument,
|
||||
chmod_file_args,
|
||||
sizeof(chmod_file_args)/sizeof(struct command_arg),
|
||||
' ');
|
||||
|
||||
/* Parse what mode to set */
|
||||
if (ds_mode.length != 4 ||
|
||||
str2int(ds_mode.str, 8, 0, INT_MAX, &mode) == NullS)
|
||||
die("You must write a 4 digit octal number for mode");
|
||||
|
||||
DBUG_PRINT("info", ("chmod %o %s", (uint)mode, ds_file.str));
|
||||
handle_command_error(command, chmod(ds_file.str, mode));
|
||||
dynstr_free(&ds_mode);
|
||||
dynstr_free(&ds_file);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SYNOPSIS
|
||||
do_file_exists
|
||||
@ -4506,7 +4604,6 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Run query using MySQL C API
|
||||
|
||||
@ -4523,11 +4620,12 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
|
||||
error - function will not return
|
||||
*/
|
||||
|
||||
void run_query_normal(MYSQL *mysql, struct st_command *command,
|
||||
void run_query_normal(struct st_connection *cn, struct st_command *command,
|
||||
int flags, char *query, int query_len,
|
||||
DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings)
|
||||
{
|
||||
MYSQL_RES *res= 0;
|
||||
MYSQL *mysql= &cn->mysql;
|
||||
int err= 0, counter= 0;
|
||||
DBUG_ENTER("run_query_normal");
|
||||
DBUG_PRINT("enter",("flags: %d", flags));
|
||||
@ -4538,14 +4636,26 @@ void run_query_normal(MYSQL *mysql, struct st_command *command,
|
||||
/*
|
||||
Send the query
|
||||
*/
|
||||
if (mysql_send_query(mysql, query, query_len))
|
||||
if (do_send_query(cn, query, query_len, flags))
|
||||
{
|
||||
handle_error(command, mysql_errno(mysql), mysql_error(mysql),
|
||||
mysql_sqlstate(mysql), ds);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
/*
|
||||
Here we handle 'reap' command, so we need to check if the
|
||||
query's thread was finished and probably wait
|
||||
*/
|
||||
else if (flags & QUERY_REAP_FLAG)
|
||||
{
|
||||
pthread_mutex_lock(&cn->mutex);
|
||||
while (!cn->query_done)
|
||||
pthread_cond_wait(&cn->cond, &cn->mutex);
|
||||
pthread_mutex_unlock(&cn->mutex);
|
||||
}
|
||||
#endif /*EMBEDDED_LIBRARY*/
|
||||
if (!(flags & QUERY_REAP_FLAG))
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
@ -5036,8 +5146,9 @@ int util_query(MYSQL* org_mysql, const char* query){
|
||||
|
||||
*/
|
||||
|
||||
void run_query(MYSQL *mysql, struct st_command *command, int flags)
|
||||
void run_query(struct st_connection *cn, struct st_command *command, int flags)
|
||||
{
|
||||
MYSQL *mysql= &cn->mysql;
|
||||
DYNAMIC_STRING *ds;
|
||||
DYNAMIC_STRING ds_result;
|
||||
DYNAMIC_STRING ds_warnings;
|
||||
@ -5194,7 +5305,7 @@ void run_query(MYSQL *mysql, struct st_command *command, int flags)
|
||||
match_re(&ps_re, query))
|
||||
run_query_stmt(mysql, command, query, query_len, ds, &ds_warnings);
|
||||
else
|
||||
run_query_normal(mysql, command, flags, query, query_len,
|
||||
run_query_normal(cn, command, flags, query, query_len,
|
||||
ds, &ds_warnings);
|
||||
|
||||
if (sp_created)
|
||||
@ -5624,6 +5735,7 @@ int main(int argc, char **argv)
|
||||
case Q_FILE_EXIST: do_file_exist(command); break;
|
||||
case Q_WRITE_FILE: do_write_file(command); break;
|
||||
case Q_COPY_FILE: do_copy_file(command); break;
|
||||
case Q_CHMOD_FILE: do_chmod_file(command); break;
|
||||
case Q_PERL: do_perl(command); break;
|
||||
case Q_DELIMITER:
|
||||
do_delimiter(command);
|
||||
@ -5659,7 +5771,7 @@ int main(int argc, char **argv)
|
||||
strmake(command->require_file, save_file, sizeof(save_file));
|
||||
save_file[0]= 0;
|
||||
}
|
||||
run_query(&cur_con->mysql, command, QUERY_REAP_FLAG|QUERY_SEND_FLAG);
|
||||
run_query(cur_con, command, QUERY_REAP_FLAG|QUERY_SEND_FLAG);
|
||||
display_result_vertically= old_display_result_vertically;
|
||||
command->last_argument= command->end;
|
||||
command_executed++;
|
||||
@ -5690,7 +5802,7 @@ int main(int argc, char **argv)
|
||||
strmake(command->require_file, save_file, sizeof(save_file));
|
||||
save_file[0]= 0;
|
||||
}
|
||||
run_query(&cur_con->mysql, command, flags);
|
||||
run_query(cur_con, command, flags);
|
||||
command_executed++;
|
||||
command->last_argument= command->end;
|
||||
break;
|
||||
@ -5716,7 +5828,7 @@ int main(int argc, char **argv)
|
||||
the query and read the result some time later when reap instruction
|
||||
is given on this connection.
|
||||
*/
|
||||
run_query(&cur_con->mysql, command, QUERY_SEND_FLAG);
|
||||
run_query(cur_con, command, QUERY_SEND_FLAG);
|
||||
command_executed++;
|
||||
command->last_argument= command->end;
|
||||
break;
|
||||
|
@ -51,7 +51,8 @@ char *batch_readline(LINE_BUFFER *line_buff)
|
||||
if (!(pos=intern_read_line(line_buff,&out_length)))
|
||||
return 0;
|
||||
if (out_length && pos[out_length-1] == '\n')
|
||||
out_length--; /* Remove '\n' */
|
||||
if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */
|
||||
out_length--; /* Remove '\r' */
|
||||
line_buff->read_length=out_length;
|
||||
pos[out_length]=0;
|
||||
return pos;
|
||||
|
@ -434,7 +434,7 @@ rl_translate_keyseq (seq, array, len)
|
||||
{
|
||||
register int i, c, l, temp;
|
||||
|
||||
for (i = l = 0; c = seq[i]; i++)
|
||||
for (i = l = 0; (c = seq[i]); i++)
|
||||
{
|
||||
if (c == '\\')
|
||||
{
|
||||
@ -765,8 +765,8 @@ _rl_read_file (filename, sizep)
|
||||
|
||||
/* Re-read the current keybindings file. */
|
||||
int
|
||||
rl_re_read_init_file (count, ignore)
|
||||
int count, ignore;
|
||||
rl_re_read_init_file (int count __attribute__((unused)),
|
||||
int ignore __attribute__((unused)))
|
||||
{
|
||||
int r;
|
||||
r = rl_read_init_file ((const char *)NULL);
|
||||
@ -987,8 +987,7 @@ parser_if (args)
|
||||
|
||||
/* Invert the current parser state if there is anything on the stack. */
|
||||
static int
|
||||
parser_else (args)
|
||||
char *args;
|
||||
parser_else (char *args __attribute__((unused)))
|
||||
{
|
||||
register int i;
|
||||
|
||||
@ -1018,8 +1017,7 @@ parser_else (args)
|
||||
/* Terminate a conditional, popping the value of
|
||||
_rl_parsing_conditionalized_out from the stack. */
|
||||
static int
|
||||
parser_endif (args)
|
||||
char *args;
|
||||
parser_endif (char *args __attribute__((unused)))
|
||||
{
|
||||
if (if_stack_depth)
|
||||
_rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
|
||||
@ -1142,7 +1140,7 @@ rl_parse_and_bind (string)
|
||||
{
|
||||
int passc = 0;
|
||||
|
||||
for (i = 1; c = string[i]; i++)
|
||||
for (i = 1; (c = string[i]); i++)
|
||||
{
|
||||
if (passc)
|
||||
{
|
||||
@ -1218,7 +1216,7 @@ rl_parse_and_bind (string)
|
||||
{
|
||||
int delimiter = string[i++], passc;
|
||||
|
||||
for (passc = 0; c = string[i]; i++)
|
||||
for (passc = 0; (c = string[i]); i++)
|
||||
{
|
||||
if (passc)
|
||||
{
|
||||
@ -1377,7 +1375,7 @@ static struct {
|
||||
#if defined (VISIBLE_STATS)
|
||||
{ "visible-stats", &rl_visible_stats, 0 },
|
||||
#endif /* VISIBLE_STATS */
|
||||
{ (char *)NULL, (int *)NULL }
|
||||
{ (char *)NULL, (int *)NULL, 0 }
|
||||
};
|
||||
|
||||
static int
|
||||
@ -1446,7 +1444,7 @@ static struct {
|
||||
{ "editing-mode", V_STRING, sv_editmode },
|
||||
{ "isearch-terminators", V_STRING, sv_isrchterm },
|
||||
{ "keymap", V_STRING, sv_keymap },
|
||||
{ (char *)NULL, 0 }
|
||||
{ (char *)NULL, 0, 0 }
|
||||
};
|
||||
|
||||
static int
|
||||
@ -1466,7 +1464,7 @@ find_string_var (name)
|
||||
values result in 0 (false). */
|
||||
static int
|
||||
bool_to_int (value)
|
||||
char *value;
|
||||
const char *value;
|
||||
{
|
||||
return (value == 0 || *value == '\0' ||
|
||||
(_rl_stricmp (value, "on") == 0) ||
|
||||
@ -1725,13 +1723,13 @@ char *
|
||||
rl_get_keymap_name_from_edit_mode ()
|
||||
{
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
return "emacs";
|
||||
return (char*) "emacs";
|
||||
#if defined (VI_MODE)
|
||||
else if (rl_editing_mode == vi_mode)
|
||||
return "vi";
|
||||
return (char*) "vi";
|
||||
#endif /* VI_MODE */
|
||||
else
|
||||
return "none";
|
||||
return (char*) "none";
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
@ -1966,7 +1964,7 @@ rl_function_dumper (print_readably)
|
||||
|
||||
fprintf (rl_outstream, "\n");
|
||||
|
||||
for (i = 0; name = names[i]; i++)
|
||||
for (i = 0; (name = names[i]); i++)
|
||||
{
|
||||
rl_command_func_t *function;
|
||||
char **invokers;
|
||||
@ -2025,8 +2023,8 @@ rl_function_dumper (print_readably)
|
||||
rl_outstream. If an explicit argument is given, then print
|
||||
the output in such a way that it can be read back in. */
|
||||
int
|
||||
rl_dump_functions (count, key)
|
||||
int count, key;
|
||||
rl_dump_functions (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
if (rl_dispatching)
|
||||
fprintf (rl_outstream, "\r\n");
|
||||
@ -2105,8 +2103,7 @@ rl_macro_dumper (print_readably)
|
||||
}
|
||||
|
||||
int
|
||||
rl_dump_macros (count, key)
|
||||
int count, key;
|
||||
rl_dump_macros(int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
if (rl_dispatching)
|
||||
fprintf (rl_outstream, "\r\n");
|
||||
@ -2195,8 +2192,7 @@ rl_variable_dumper (print_readably)
|
||||
rl_outstream. If an explicit argument is given, then print
|
||||
the output in such a way that it can be read back in. */
|
||||
int
|
||||
rl_dump_variables (count, key)
|
||||
int count, key;
|
||||
rl_dump_variables(int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
if (rl_dispatching)
|
||||
fprintf (rl_outstream, "\r\n");
|
||||
|
@ -59,7 +59,11 @@
|
||||
#define largest_char 255 /* Largest character value. */
|
||||
|
||||
#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
|
||||
#if largest_char >= 255
|
||||
#define META_CHAR(c) ((c) > meta_character_threshold)
|
||||
#else
|
||||
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
|
||||
#endif
|
||||
|
||||
#define CTRL(c) ((c) & control_character_mask)
|
||||
#define META(c) ((c) | meta_character_bit)
|
||||
|
@ -360,15 +360,15 @@ rl_complete (ignore, invoking_key)
|
||||
|
||||
/* List the possible completions. See description of rl_complete (). */
|
||||
int
|
||||
rl_possible_completions (ignore, invoking_key)
|
||||
int ignore, invoking_key;
|
||||
rl_possible_completions (int ignore __attribute__((unused)),
|
||||
int invoking_key __attribute__((unused)))
|
||||
{
|
||||
return (rl_complete_internal ('?'));
|
||||
}
|
||||
|
||||
int
|
||||
rl_insert_completions (ignore, invoking_key)
|
||||
int ignore, invoking_key;
|
||||
rl_insert_completions (int ignore __attribute__((unused)),
|
||||
int invoking_key __attribute__((unused)))
|
||||
{
|
||||
return (rl_complete_internal ('*'));
|
||||
}
|
||||
@ -760,10 +760,7 @@ print_filename (to_print, full_pathname)
|
||||
}
|
||||
|
||||
static char *
|
||||
rl_quote_filename (s, rtype, qcp)
|
||||
char *s;
|
||||
int rtype;
|
||||
char *qcp;
|
||||
rl_quote_filename (char *s, int rtype __attribute__((unused)), char *qcp)
|
||||
{
|
||||
char *r;
|
||||
|
||||
@ -871,7 +868,7 @@ _rl_find_completion_word (fp, dp)
|
||||
completion, so use the word break characters to find the
|
||||
substring on which to complete. */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
while (rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_ANY))
|
||||
while ((rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_ANY)))
|
||||
#else
|
||||
while (--rl_point)
|
||||
#endif
|
||||
@ -1805,7 +1802,7 @@ rl_completion_matches (text, entry_function)
|
||||
match_list = (char **)xmalloc ((match_list_size + 1) * sizeof (char *));
|
||||
match_list[1] = (char *)NULL;
|
||||
|
||||
while (string = (*entry_function) (text, matches))
|
||||
while ((string = (*entry_function) (text, matches)))
|
||||
{
|
||||
if (matches + 1 == match_list_size)
|
||||
match_list = (char **)xrealloc
|
||||
@ -1855,7 +1852,7 @@ rl_username_completion_function (text, state)
|
||||
setpwent ();
|
||||
}
|
||||
|
||||
while (entry = getpwent ())
|
||||
while ((entry = getpwent ()))
|
||||
{
|
||||
/* Null usernames should result in all users as possible completions. */
|
||||
if (namelen == 0 || (STREQN (username, entry->pw_name, namelen)))
|
||||
@ -2091,8 +2088,7 @@ rl_filename_completion_function (text, state)
|
||||
hit the end of the match list, we restore the original unmatched text,
|
||||
ring the bell, and reset the counter to zero. */
|
||||
int
|
||||
rl_menu_complete (count, ignore)
|
||||
int count, ignore;
|
||||
rl_menu_complete (int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
rl_compentry_func_t *our_func;
|
||||
int matching_filenames, found_quote;
|
||||
|
@ -218,7 +218,7 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
|
||||
if (niflp)
|
||||
*niflp = 0;
|
||||
if (vlp)
|
||||
*vlp = lp ? *lp : strlen (r);
|
||||
*vlp = lp ? *lp : (int) strlen (r);
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -435,7 +435,7 @@ rl_redisplay ()
|
||||
return;
|
||||
|
||||
if (!rl_display_prompt)
|
||||
rl_display_prompt = "";
|
||||
rl_display_prompt = (char*) "";
|
||||
|
||||
if (invisible_line == 0)
|
||||
{
|
||||
@ -757,7 +757,7 @@ rl_redisplay ()
|
||||
c_pos = out;
|
||||
lb_linenum = newlines;
|
||||
}
|
||||
for (i = in; i < in+wc_bytes; i++)
|
||||
for (i = in; i < (int) (in+wc_bytes); i++)
|
||||
line[out++] = rl_line_buffer[i];
|
||||
for (i = 0; i < wc_width; i++)
|
||||
CHECK_LPOS();
|
||||
@ -835,7 +835,7 @@ rl_redisplay ()
|
||||
#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
|
||||
#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
|
||||
#define VIS_CHARS(line) (visible_line + vis_lbreaks[line])
|
||||
#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
|
||||
#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? (char*) "" : VIS_CHARS(line)
|
||||
#define INV_LINE(line) (invisible_line + inv_lbreaks[line])
|
||||
|
||||
/* For each line in the buffer, do the updating display. */
|
||||
@ -876,7 +876,7 @@ rl_redisplay ()
|
||||
_rl_move_vert (linenum);
|
||||
_rl_move_cursor_relative (0, tt);
|
||||
_rl_clear_to_eol
|
||||
((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth);
|
||||
((linenum == _rl_vis_botlin) ? (int) strlen (tt) : _rl_screenwidth);
|
||||
}
|
||||
}
|
||||
_rl_vis_botlin = inv_botlin;
|
||||
@ -1086,7 +1086,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
||||
int col_lendiff, col_temp;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
mbstate_t ps_new, ps_old;
|
||||
int new_offset, old_offset, tmp;
|
||||
int new_offset, old_offset;
|
||||
#endif
|
||||
|
||||
/* If we're at the right edge of a terminal that supports xn, we're
|
||||
@ -1837,7 +1837,7 @@ rl_reset_line_state ()
|
||||
{
|
||||
rl_on_new_line ();
|
||||
|
||||
rl_display_prompt = rl_prompt ? rl_prompt : "";
|
||||
rl_display_prompt = rl_prompt ? rl_prompt : (char*) "";
|
||||
forced_display = 1;
|
||||
return 0;
|
||||
}
|
||||
@ -2212,7 +2212,7 @@ _rl_col_width (str, start, end)
|
||||
int start, end;
|
||||
{
|
||||
wchar_t wc;
|
||||
mbstate_t ps = {0};
|
||||
mbstate_t ps;
|
||||
int tmp, point, width, max;
|
||||
|
||||
if (end <= start)
|
||||
@ -2221,6 +2221,7 @@ _rl_col_width (str, start, end)
|
||||
point = 0;
|
||||
max = end;
|
||||
|
||||
memset (&ps, 0, sizeof(ps));
|
||||
while (point < start)
|
||||
{
|
||||
tmp = mbrlen (str + point, max, &ps);
|
||||
|
@ -87,14 +87,14 @@ char history_comment_char = '\0';
|
||||
|
||||
/* The list of characters which inhibit the expansion of text if found
|
||||
immediately following history_expansion_char. */
|
||||
char *history_no_expand_chars = " \t\n\r=";
|
||||
char *history_no_expand_chars = (char*) " \t\n\r=";
|
||||
|
||||
/* If set to a non-zero value, single quotes inhibit history expansion.
|
||||
The default is 0. */
|
||||
int history_quotes_inhibit_expansion = 0;
|
||||
|
||||
/* Used to split words by history_tokenize_internal. */
|
||||
char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
|
||||
char *history_word_delimiters = (char*) HISTORY_WORD_DELIMITERS;
|
||||
|
||||
/* If set, this points to a function that is called to verify that a
|
||||
particular history expansion should be performed. */
|
||||
@ -203,7 +203,7 @@ get_history_event (string, caller_index, delimiting_quote)
|
||||
}
|
||||
|
||||
/* Only a closing `?' or a newline delimit a substring search string. */
|
||||
for (local_index = i; c = string[i]; i++)
|
||||
for (local_index = i; (c = string[i]); i++)
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
|
@ -405,7 +405,7 @@ rl_read_key ()
|
||||
else
|
||||
{
|
||||
/* If input is coming from a macro, then use that. */
|
||||
if (c = _rl_next_macro_key ())
|
||||
if ((c= _rl_next_macro_key ()))
|
||||
return (c);
|
||||
|
||||
/* If the user has an event function, then call it periodically. */
|
||||
|
@ -68,7 +68,7 @@ static char *prev_line_found;
|
||||
static char *last_isearch_string;
|
||||
static int last_isearch_string_len;
|
||||
|
||||
static char *default_isearch_terminators = "\033\012";
|
||||
static char *default_isearch_terminators = (char*) "\033\012";
|
||||
|
||||
/* Search backwards through the history looking for a string which is typed
|
||||
interactively. Start with the current line. */
|
||||
@ -94,9 +94,8 @@ rl_forward_search_history (sign, key)
|
||||
WHERE is the history list number of the current line. If it is
|
||||
-1, then this line is the starting one. */
|
||||
static void
|
||||
rl_display_search (search_string, reverse_p, where)
|
||||
char *search_string;
|
||||
int reverse_p, where;
|
||||
rl_display_search (char *search_string, int reverse_p,
|
||||
int where __attribute__((unused)))
|
||||
{
|
||||
char *message;
|
||||
int msglen, searchlen;
|
||||
@ -143,8 +142,7 @@ rl_display_search (search_string, reverse_p, where)
|
||||
DIRECTION is which direction to search; >= 0 means forward, < 0 means
|
||||
backwards. */
|
||||
static int
|
||||
rl_search_history (direction, invoking_key)
|
||||
int direction, invoking_key;
|
||||
rl_search_history (int direction, int invoking_key __attribute__((unused)))
|
||||
{
|
||||
/* The string that the user types in to search for. */
|
||||
char *search_string;
|
||||
|
@ -76,8 +76,7 @@ static int rl_yank_nth_arg_internal PARAMS((int, int, int));
|
||||
/* How to say that you only want to save a certain amount
|
||||
of kill material. */
|
||||
int
|
||||
rl_set_retained_kills (num)
|
||||
int num;
|
||||
rl_set_retained_kills (int num __attribute__((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -293,8 +292,8 @@ rl_backward_kill_line (direction, ignore)
|
||||
|
||||
/* Kill the whole line, no matter where point is. */
|
||||
int
|
||||
rl_kill_full_line (count, ignore)
|
||||
int count, ignore;
|
||||
rl_kill_full_line (int count __attribute__((unused)),
|
||||
int ignore __attribute__((unused)))
|
||||
{
|
||||
rl_begin_undo_group ();
|
||||
rl_point = 0;
|
||||
@ -311,8 +310,7 @@ rl_kill_full_line (count, ignore)
|
||||
/* This does what C-w does in Unix. We can't prevent people from
|
||||
using behaviour that they expect. */
|
||||
int
|
||||
rl_unix_word_rubout (count, key)
|
||||
int count, key;
|
||||
rl_unix_word_rubout (int count, int key __attribute__((unused)))
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
@ -344,8 +342,7 @@ rl_unix_word_rubout (count, key)
|
||||
/* This deletes one filename component in a Unix pathname. That is, it
|
||||
deletes backward to directory separator (`/') or whitespace. */
|
||||
int
|
||||
rl_unix_filename_rubout (count, key)
|
||||
int count, key;
|
||||
rl_unix_filename_rubout (int count, int key __attribute__((unused)))
|
||||
{
|
||||
int orig_point, c;
|
||||
|
||||
@ -388,8 +385,8 @@ rl_unix_filename_rubout (count, key)
|
||||
into the line at all, and if you aren't, then you know what you are
|
||||
doing. */
|
||||
int
|
||||
rl_unix_line_discard (count, key)
|
||||
int count, key;
|
||||
rl_unix_line_discard (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
if (rl_point == 0)
|
||||
rl_ding ();
|
||||
@ -425,16 +422,16 @@ region_kill_internal (delete)
|
||||
|
||||
/* Copy the text in the region to the kill ring. */
|
||||
int
|
||||
rl_copy_region_to_kill (count, ignore)
|
||||
int count, ignore;
|
||||
rl_copy_region_to_kill (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
return (region_kill_internal (0));
|
||||
}
|
||||
|
||||
/* Kill the text between the point and mark. */
|
||||
int
|
||||
rl_kill_region (count, ignore)
|
||||
int count, ignore;
|
||||
rl_kill_region (int count __attribute__((unused)),
|
||||
int ignore __attribute__((unused)))
|
||||
{
|
||||
int r, npoint;
|
||||
|
||||
@ -498,8 +495,7 @@ rl_copy_backward_word (count, key)
|
||||
|
||||
/* Yank back the last killed text. This ignores arguments. */
|
||||
int
|
||||
rl_yank (count, ignore)
|
||||
int count, ignore;
|
||||
rl_yank (int count __attribute__((unused)), int ignore __attribute__((unused)))
|
||||
{
|
||||
if (rl_kill_ring == 0)
|
||||
{
|
||||
@ -517,8 +513,7 @@ rl_yank (count, ignore)
|
||||
delete that text from the line, rotate the index down, and
|
||||
yank back some other text. */
|
||||
int
|
||||
rl_yank_pop (count, key)
|
||||
int count, key;
|
||||
rl_yank_pop (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
int l, n;
|
||||
|
||||
|
@ -189,8 +189,8 @@ _rl_kill_kbd_macro ()
|
||||
definition to the end of the existing macro, and start by
|
||||
re-executing the existing macro. */
|
||||
int
|
||||
rl_start_kbd_macro (ignore1, ignore2)
|
||||
int ignore1, ignore2;
|
||||
rl_start_kbd_macro (int ignore1 __attribute__((unused)),
|
||||
int ignore2 __attribute__((unused)))
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF))
|
||||
{
|
||||
@ -214,8 +214,7 @@ rl_start_kbd_macro (ignore1, ignore2)
|
||||
A numeric argument says to execute the macro right now,
|
||||
that many times, counting the definition as the first time. */
|
||||
int
|
||||
rl_end_kbd_macro (count, ignore)
|
||||
int count, ignore;
|
||||
rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
|
||||
{
|
||||
@ -234,8 +233,7 @@ rl_end_kbd_macro (count, ignore)
|
||||
/* Execute the most recently defined keyboard macro.
|
||||
COUNT says how many times to execute it. */
|
||||
int
|
||||
rl_call_last_kbd_macro (count, ignore)
|
||||
int count, ignore;
|
||||
rl_call_last_kbd_macro (int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
if (current_macro == 0)
|
||||
_rl_abort_internal ();
|
||||
|
@ -154,8 +154,7 @@ rl_digit_loop ()
|
||||
|
||||
/* Add the current digit to the argument in progress. */
|
||||
int
|
||||
rl_digit_argument (ignore, key)
|
||||
int ignore, key;
|
||||
rl_digit_argument (int ignore __attribute__((unused)), int key)
|
||||
{
|
||||
rl_execute_next (key);
|
||||
return (rl_digit_loop ());
|
||||
@ -184,8 +183,8 @@ _rl_init_argument ()
|
||||
Read a key. If the key has nothing to do with arguments, then
|
||||
dispatch on it. If the key is the abort character then abort. */
|
||||
int
|
||||
rl_universal_argument (count, key)
|
||||
int count, key;
|
||||
rl_universal_argument (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
rl_numeric_arg *= 4;
|
||||
return (rl_digit_loop ());
|
||||
@ -314,9 +313,7 @@ _rl_history_set_point ()
|
||||
}
|
||||
|
||||
void
|
||||
rl_replace_from_history (entry, flags)
|
||||
HIST_ENTRY *entry;
|
||||
int flags; /* currently unused */
|
||||
rl_replace_from_history (HIST_ENTRY *entry, int flags __attribute__((unused)))
|
||||
{
|
||||
/* Can't call with `1' because rl_undo_list might point to an undo list
|
||||
from a history entry, just like we're setting up here. */
|
||||
@ -342,16 +339,15 @@ rl_replace_from_history (entry, flags)
|
||||
|
||||
/* Meta-< goes to the start of the history. */
|
||||
int
|
||||
rl_beginning_of_history (count, key)
|
||||
int count, key;
|
||||
rl_beginning_of_history (int count __attribute__((unused)), int key)
|
||||
{
|
||||
return (rl_get_previous_history (1 + where_history (), key));
|
||||
}
|
||||
|
||||
/* Meta-> goes to the end of the history. (The current line). */
|
||||
int
|
||||
rl_end_of_history (count, key)
|
||||
int count, key;
|
||||
rl_end_of_history (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
rl_maybe_replace_line ();
|
||||
using_history ();
|
||||
@ -455,8 +451,7 @@ rl_get_previous_history (count, key)
|
||||
/* **************************************************************** */
|
||||
/* How to toggle back and forth between editing modes. */
|
||||
int
|
||||
rl_vi_editing_mode (count, key)
|
||||
int count, key;
|
||||
rl_vi_editing_mode (int count __attribute__((unused)), int key)
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
|
||||
@ -468,8 +463,8 @@ rl_vi_editing_mode (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_emacs_editing_mode (count, key)
|
||||
int count, key;
|
||||
rl_emacs_editing_mode (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
rl_editing_mode = emacs_mode;
|
||||
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
|
||||
@ -479,8 +474,7 @@ rl_emacs_editing_mode (count, key)
|
||||
|
||||
/* Function for the rest of the library to use to set insert/overwrite mode. */
|
||||
void
|
||||
_rl_set_insert_mode (im, force)
|
||||
int im, force;
|
||||
_rl_set_insert_mode (int im, int force __attribute__((unused)))
|
||||
{
|
||||
#ifdef CURSOR_MODE
|
||||
_rl_set_cursor (im, force);
|
||||
@ -492,8 +486,7 @@ _rl_set_insert_mode (im, force)
|
||||
/* Toggle overwrite mode. A positive explicit argument selects overwrite
|
||||
mode. A negative or zero explicit argument selects insert mode. */
|
||||
int
|
||||
rl_overwrite_mode (count, key)
|
||||
int count, key;
|
||||
rl_overwrite_mode (int count, int key __attribute__((unused)))
|
||||
{
|
||||
if (rl_explicit_arg == 0)
|
||||
_rl_set_insert_mode (rl_insert_mode ^ 1, 0);
|
||||
|
@ -111,7 +111,7 @@ _rl_init_eightbit ()
|
||||
if (lspec == 0 || *lspec == 0)
|
||||
lspec = setlocale (LC_CTYPE, (char *)NULL);
|
||||
if (lspec == 0)
|
||||
lspec = "";
|
||||
lspec = (char*) "";
|
||||
t = setlocale (LC_CTYPE, lspec);
|
||||
|
||||
if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0))
|
||||
|
@ -83,7 +83,9 @@ static void bind_arrow_keys_internal PARAMS((Keymap));
|
||||
static void bind_arrow_keys PARAMS((void));
|
||||
|
||||
static void readline_default_bindings PARAMS((void));
|
||||
#ifdef NOT_USED
|
||||
static void reset_default_bindings PARAMS((void));
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
@ -866,12 +868,14 @@ readline_default_bindings ()
|
||||
|
||||
/* Reset the default bindings for the terminal special characters we're
|
||||
interested in back to rl_insert and read the new ones. */
|
||||
#ifdef NOT_USED
|
||||
static void
|
||||
reset_default_bindings ()
|
||||
{
|
||||
rl_tty_unset_default_bindings (_rl_keymap);
|
||||
rl_tty_set_default_bindings (_rl_keymap);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Bind some common arrow key sequences in MAP. */
|
||||
static void
|
||||
|
@ -716,8 +716,7 @@ rl_deprep_terminal ()
|
||||
/* **************************************************************** */
|
||||
|
||||
int
|
||||
rl_restart_output (count, key)
|
||||
int count, key;
|
||||
rl_restart_output(int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
int fildes = fileno (rl_outstream);
|
||||
#if defined (TIOCSTART)
|
||||
@ -749,8 +748,7 @@ rl_restart_output (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_stop_output (count, key)
|
||||
int count, key;
|
||||
rl_stop_output(int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
int fildes = fileno (rl_instream);
|
||||
|
||||
@ -867,7 +865,6 @@ rltty_set_default_bindings (kmap)
|
||||
{
|
||||
TIOTYPE ttybuff;
|
||||
int tty;
|
||||
static int called = 0;
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
|
@ -303,8 +303,7 @@ noninc_search (dir, pchar)
|
||||
/* Search forward through the history list for a string. If the vi-mode
|
||||
code calls this, KEY will be `?'. */
|
||||
int
|
||||
rl_noninc_forward_search (count, key)
|
||||
int count, key;
|
||||
rl_noninc_forward_search (int count __attribute__((unused)), int key)
|
||||
{
|
||||
noninc_search (1, (key == '?') ? '?' : 0);
|
||||
return 0;
|
||||
@ -313,8 +312,7 @@ rl_noninc_forward_search (count, key)
|
||||
/* Reverse search the history list for a string. If the vi-mode code
|
||||
calls this, KEY will be `/'. */
|
||||
int
|
||||
rl_noninc_reverse_search (count, key)
|
||||
int count, key;
|
||||
rl_noninc_reverse_search (int count __attribute__((unused)), int key)
|
||||
{
|
||||
noninc_search (-1, (key == '/') ? '/' : 0);
|
||||
return 0;
|
||||
@ -323,8 +321,8 @@ rl_noninc_reverse_search (count, key)
|
||||
/* Search forward through the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
int
|
||||
rl_noninc_forward_search_again (count, key)
|
||||
int count, key;
|
||||
rl_noninc_forward_search_again (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
@ -338,8 +336,8 @@ rl_noninc_forward_search_again (count, key)
|
||||
/* Reverse search in the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
int
|
||||
rl_noninc_reverse_search_again (count, key)
|
||||
int count, key;
|
||||
rl_noninc_reverse_search_again (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
|
@ -344,7 +344,7 @@ get_term_capabilities (bp)
|
||||
#if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < NUM_TC_STRINGS; i++)
|
||||
for (i = 0; i < (int) NUM_TC_STRINGS; i++)
|
||||
*(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp);
|
||||
#endif
|
||||
tcap_initialized = 1;
|
||||
@ -410,7 +410,7 @@ _rl_init_terminal_io (terminal_name)
|
||||
|
||||
/* Everything below here is used by the redisplay code (tputs). */
|
||||
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
|
||||
_rl_term_cr = "\r";
|
||||
_rl_term_cr = (char*) "\r";
|
||||
_rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
|
||||
_rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
|
||||
_rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
|
||||
@ -427,7 +427,7 @@ _rl_init_terminal_io (terminal_name)
|
||||
tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
|
||||
change that later... */
|
||||
PC = '\0';
|
||||
BC = _rl_term_backspace = "\b";
|
||||
BC = _rl_term_backspace = (char*) "\b";
|
||||
UP = _rl_term_up;
|
||||
|
||||
return 0;
|
||||
@ -442,7 +442,7 @@ _rl_init_terminal_io (terminal_name)
|
||||
UP = _rl_term_up;
|
||||
|
||||
if (!_rl_term_cr)
|
||||
_rl_term_cr = "\r";
|
||||
_rl_term_cr = (char*) "\r";
|
||||
|
||||
_rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
|
||||
|
||||
@ -502,7 +502,7 @@ rl_get_termcap (cap)
|
||||
|
||||
if (tcap_initialized == 0)
|
||||
return ((char *)NULL);
|
||||
for (i = 0; i < NUM_TC_STRINGS; i++)
|
||||
for (i = 0; i < (int) NUM_TC_STRINGS; i++)
|
||||
{
|
||||
if (tc_strings[i].tc_var[0] == cap[0] && strcmp (tc_strings[i].tc_var, cap) == 0)
|
||||
return *(tc_strings[i].tc_value);
|
||||
|
@ -402,8 +402,7 @@ rl_backward (count, key)
|
||||
|
||||
/* Move to the beginning of the line. */
|
||||
int
|
||||
rl_beg_of_line (count, key)
|
||||
int count, key;
|
||||
rl_beg_of_line (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
rl_point = 0;
|
||||
return 0;
|
||||
@ -411,8 +410,7 @@ rl_beg_of_line (count, key)
|
||||
|
||||
/* Move to the end of the line. */
|
||||
int
|
||||
rl_end_of_line (count, key)
|
||||
int count, key;
|
||||
rl_end_of_line (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
rl_point = rl_end;
|
||||
return 0;
|
||||
@ -508,8 +506,7 @@ rl_backward_word (count, key)
|
||||
|
||||
/* Clear the current line. Numeric argument to C-l does this. */
|
||||
int
|
||||
rl_refresh_line (ignore1, ignore2)
|
||||
int ignore1, ignore2;
|
||||
rl_refresh_line (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
int curr_line;
|
||||
|
||||
@ -547,8 +544,7 @@ rl_clear_screen (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_arrow_keys (count, c)
|
||||
int count, c;
|
||||
rl_arrow_keys (int count, int c __attribute__((unused)))
|
||||
{
|
||||
int ch;
|
||||
|
||||
@ -596,7 +592,7 @@ rl_arrow_keys (count, c)
|
||||
#ifdef HANDLE_MULTIBYTE
|
||||
static char pending_bytes[MB_LEN_MAX];
|
||||
static int pending_bytes_length = 0;
|
||||
static mbstate_t ps = {0};
|
||||
static mbstate_t ps;
|
||||
#endif
|
||||
|
||||
/* Insert the character C at the current location, moving point forward.
|
||||
@ -832,8 +828,7 @@ rl_insert (count, c)
|
||||
|
||||
/* Insert the next typed character verbatim. */
|
||||
int
|
||||
rl_quoted_insert (count, key)
|
||||
int count, key;
|
||||
rl_quoted_insert (int count, int key __attribute__((unused)))
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -854,8 +849,7 @@ rl_quoted_insert (count, key)
|
||||
|
||||
/* Insert a tab character. */
|
||||
int
|
||||
rl_tab_insert (count, key)
|
||||
int count, key;
|
||||
rl_tab_insert (int count, int key __attribute__((unused)))
|
||||
{
|
||||
return (_rl_insert_char (count, '\t'));
|
||||
}
|
||||
@ -864,8 +858,7 @@ rl_tab_insert (count, key)
|
||||
KEY is the key that invoked this command. I guess it could have
|
||||
meaning in the future. */
|
||||
int
|
||||
rl_newline (count, key)
|
||||
int count, key;
|
||||
rl_newline (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
rl_done = 1;
|
||||
|
||||
@ -898,8 +891,8 @@ rl_newline (count, key)
|
||||
is just a stub, you bind keys to it and the code in _rl_dispatch ()
|
||||
is special cased. */
|
||||
int
|
||||
rl_do_lowercase_version (ignore1, ignore2)
|
||||
int ignore1, ignore2;
|
||||
rl_do_lowercase_version (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -1093,8 +1086,8 @@ rl_rubout_or_delete (count, key)
|
||||
|
||||
/* Delete all spaces and tabs around point. */
|
||||
int
|
||||
rl_delete_horizontal_space (count, ignore)
|
||||
int count, ignore;
|
||||
rl_delete_horizontal_space (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
int start = rl_point;
|
||||
|
||||
@ -1134,14 +1127,13 @@ rl_delete_or_show_completions (count, key)
|
||||
/* Turn the current line into a comment in shell history.
|
||||
A K*rn shell style function. */
|
||||
int
|
||||
rl_insert_comment (count, key)
|
||||
int count, key;
|
||||
rl_insert_comment (int count __attribute__((unused)), int key)
|
||||
{
|
||||
char *rl_comment_text;
|
||||
int rl_comment_len;
|
||||
|
||||
rl_beg_of_line (1, key);
|
||||
rl_comment_text = _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT;
|
||||
rl_comment_text = _rl_comment_begin ? _rl_comment_begin : (char*) RL_COMMENT_BEGIN_DEFAULT;
|
||||
|
||||
if (rl_explicit_arg == 0)
|
||||
rl_insert_text (rl_comment_text);
|
||||
@ -1173,24 +1165,21 @@ rl_insert_comment (count, key)
|
||||
|
||||
/* Uppercase the word at point. */
|
||||
int
|
||||
rl_upcase_word (count, key)
|
||||
int count, key;
|
||||
rl_upcase_word (int count, int key __attribute__((unused)))
|
||||
{
|
||||
return (rl_change_case (count, UpCase));
|
||||
}
|
||||
|
||||
/* Lowercase the word at point. */
|
||||
int
|
||||
rl_downcase_word (count, key)
|
||||
int count, key;
|
||||
rl_downcase_word (int count, int key __attribute__((unused)))
|
||||
{
|
||||
return (rl_change_case (count, DownCase));
|
||||
}
|
||||
|
||||
/* Upcase the first letter, downcase the rest. */
|
||||
int
|
||||
rl_capitalize_word (count, key)
|
||||
int count, key;
|
||||
rl_capitalize_word (int count, int key __attribute__((unused)))
|
||||
{
|
||||
return (rl_change_case (count, CapCase));
|
||||
}
|
||||
@ -1314,8 +1303,7 @@ rl_transpose_words (count, key)
|
||||
/* Transpose the characters at point. If point is at the end of the line,
|
||||
then transpose the characters before point. */
|
||||
int
|
||||
rl_transpose_chars (count, key)
|
||||
int count, key;
|
||||
rl_transpose_chars (int count, int key __attribute__((unused)))
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
char *dummy;
|
||||
@ -1486,15 +1474,13 @@ _rl_char_search (count, fdir, bdir)
|
||||
#endif /* !HANDLE_MULTIBYTE */
|
||||
|
||||
int
|
||||
rl_char_search (count, key)
|
||||
int count, key;
|
||||
rl_char_search (int count, int key __attribute__((unused)))
|
||||
{
|
||||
return (_rl_char_search (count, FFIND, BFIND));
|
||||
}
|
||||
|
||||
int
|
||||
rl_backward_char_search (count, key)
|
||||
int count, key;
|
||||
rl_backward_char_search (int count, int key __attribute__((unused)))
|
||||
{
|
||||
return (_rl_char_search (count, BFIND, FFIND));
|
||||
}
|
||||
@ -1519,16 +1505,15 @@ _rl_set_mark_at_pos (position)
|
||||
|
||||
/* A bindable command to set the mark. */
|
||||
int
|
||||
rl_set_mark (count, key)
|
||||
int count, key;
|
||||
rl_set_mark (int count, int key __attribute__((unused)))
|
||||
{
|
||||
return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point));
|
||||
}
|
||||
|
||||
/* Exchange the position of mark and point. */
|
||||
int
|
||||
rl_exchange_point_and_mark (count, key)
|
||||
int count, key;
|
||||
rl_exchange_point_and_mark (int count __attribute__((unused)),
|
||||
int key __attribute__((unused)))
|
||||
{
|
||||
if (rl_mark > rl_end)
|
||||
rl_mark = -1;
|
||||
|
@ -190,7 +190,7 @@ tilde_expand (string)
|
||||
int result_size, result_index;
|
||||
|
||||
result_index = result_size = 0;
|
||||
if (result = strchr (string, '~'))
|
||||
if ((result = strchr (string, '~')))
|
||||
result = (char *)xmalloc (result_size = (strlen (string) + 16));
|
||||
else
|
||||
result = (char *)xmalloc (result_size = (strlen (string) + 1));
|
||||
|
@ -175,7 +175,7 @@ _rl_fix_last_undo_of_type (type, start, end)
|
||||
|
||||
for (rl = rl_undo_list; rl; rl = rl->next)
|
||||
{
|
||||
if (rl->what == type)
|
||||
if (rl->what == (uint) type)
|
||||
{
|
||||
rl->start = start;
|
||||
rl->end = end;
|
||||
@ -226,8 +226,7 @@ rl_modifying (start, end)
|
||||
|
||||
/* Revert the current line to its previous state. */
|
||||
int
|
||||
rl_revert_line (count, key)
|
||||
int count, key;
|
||||
rl_revert_line (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
if (!rl_undo_list)
|
||||
rl_ding ();
|
||||
@ -241,8 +240,7 @@ rl_revert_line (count, key)
|
||||
|
||||
/* Do some undoing of things that were done. */
|
||||
int
|
||||
rl_undo_command (count, key)
|
||||
int count, key;
|
||||
rl_undo_command (int count, int key __attribute__((unused)))
|
||||
{
|
||||
if (count < 0)
|
||||
return 0; /* Nothing to do. */
|
||||
|
@ -95,15 +95,13 @@ _rl_abort_internal ()
|
||||
}
|
||||
|
||||
int
|
||||
rl_abort (count, key)
|
||||
int count, key;
|
||||
rl_abort (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
return (_rl_abort_internal ());
|
||||
}
|
||||
|
||||
int
|
||||
rl_tty_status (count, key)
|
||||
int count, key;
|
||||
rl_tty_status (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
#if defined (TIOCSTAT)
|
||||
ioctl (1, TIOCSTAT, (char *)0);
|
||||
@ -152,8 +150,7 @@ rl_extend_line_buffer (len)
|
||||
|
||||
/* A function for simple tilde expansion. */
|
||||
int
|
||||
rl_tilde_expand (ignore, key)
|
||||
int ignore, key;
|
||||
rl_tilde_expand (int ignore __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
register int start, end;
|
||||
char *homedir, *temp;
|
||||
|
@ -112,7 +112,7 @@ _rl_vi_initialize_line ()
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++)
|
||||
for (i = 0; i < (int) (sizeof (vi_mark_chars) / sizeof (int)); i++)
|
||||
vi_mark_chars[i] = -1;
|
||||
}
|
||||
|
||||
@ -166,8 +166,7 @@ _rl_vi_stuff_insert (count)
|
||||
redo a text modification command. The default for _rl_vi_last_command
|
||||
puts you back into insert mode. */
|
||||
int
|
||||
rl_vi_redo (count, c)
|
||||
int count, c;
|
||||
rl_vi_redo (int count, int c __attribute__((unused)))
|
||||
{
|
||||
int r;
|
||||
|
||||
@ -205,8 +204,7 @@ rl_vi_undo (count, key)
|
||||
|
||||
/* Yank the nth arg from the previous line into this line at point. */
|
||||
int
|
||||
rl_vi_yank_arg (count, key)
|
||||
int count, key;
|
||||
rl_vi_yank_arg (int count, int key __attribute__((unused)))
|
||||
{
|
||||
/* Readline thinks that the first word on a line is the 0th, while vi
|
||||
thinks the first word on a line is the 1st. Compensate. */
|
||||
@ -286,8 +284,7 @@ rl_vi_search (count, key)
|
||||
|
||||
/* Completion, from vi's point of view. */
|
||||
int
|
||||
rl_vi_complete (ignore, key)
|
||||
int ignore, key;
|
||||
rl_vi_complete (int ignore __attribute__((unused)), int key)
|
||||
{
|
||||
if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
|
||||
{
|
||||
@ -313,8 +310,7 @@ rl_vi_complete (ignore, key)
|
||||
|
||||
/* Tilde expansion for vi mode. */
|
||||
int
|
||||
rl_vi_tilde_expand (ignore, key)
|
||||
int ignore, key;
|
||||
rl_vi_tilde_expand (int ignore __attribute__((unused)), int key)
|
||||
{
|
||||
rl_tilde_expand (0, key);
|
||||
rl_vi_start_inserting (key, 1, rl_arg_sign);
|
||||
@ -384,8 +380,7 @@ rl_vi_end_word (count, key)
|
||||
|
||||
/* Move forward a word the way that 'W' does. */
|
||||
int
|
||||
rl_vi_fWord (count, ignore)
|
||||
int count, ignore;
|
||||
rl_vi_fWord (int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
while (count-- && rl_point < (rl_end - 1))
|
||||
{
|
||||
@ -401,8 +396,7 @@ rl_vi_fWord (count, ignore)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_bWord (count, ignore)
|
||||
int count, ignore;
|
||||
rl_vi_bWord (int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
while (count-- && rl_point > 0)
|
||||
{
|
||||
@ -425,8 +419,7 @@ rl_vi_bWord (count, ignore)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_eWord (count, ignore)
|
||||
int count, ignore;
|
||||
rl_vi_eWord(int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
while (count-- && rl_point < (rl_end - 1))
|
||||
{
|
||||
@ -456,8 +449,7 @@ rl_vi_eWord (count, ignore)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_fword (count, ignore)
|
||||
int count, ignore;
|
||||
rl_vi_fword (int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
while (count-- && rl_point < (rl_end - 1))
|
||||
{
|
||||
@ -482,8 +474,7 @@ rl_vi_fword (count, ignore)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_bword (count, ignore)
|
||||
int count, ignore;
|
||||
rl_vi_bword (int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
while (count-- && rl_point > 0)
|
||||
{
|
||||
@ -521,8 +512,7 @@ rl_vi_bword (count, ignore)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_eword (count, ignore)
|
||||
int count, ignore;
|
||||
rl_vi_eword (int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
while (count-- && rl_point < rl_end - 1)
|
||||
{
|
||||
@ -546,8 +536,7 @@ rl_vi_eword (count, ignore)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_insert_beg (count, key)
|
||||
int count, key;
|
||||
rl_vi_insert_beg (int count __attribute__((unused)), int key)
|
||||
{
|
||||
rl_beg_of_line (1, key);
|
||||
rl_vi_insertion_mode (1, key);
|
||||
@ -555,8 +544,7 @@ rl_vi_insert_beg (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_append_mode (count, key)
|
||||
int count, key;
|
||||
rl_vi_append_mode (int count __attribute__((unused)), int key)
|
||||
{
|
||||
if (rl_point < rl_end)
|
||||
{
|
||||
@ -575,8 +563,7 @@ rl_vi_append_mode (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_append_eol (count, key)
|
||||
int count, key;
|
||||
rl_vi_append_eol (int count __attribute__((unused)), int key)
|
||||
{
|
||||
rl_end_of_line (1, key);
|
||||
rl_vi_append_mode (1, key);
|
||||
@ -585,8 +572,7 @@ rl_vi_append_eol (count, key)
|
||||
|
||||
/* What to do in the case of C-d. */
|
||||
int
|
||||
rl_vi_eof_maybe (count, c)
|
||||
int count, c;
|
||||
rl_vi_eof_maybe (int count __attribute__((unused)), int c __attribute__((unused)))
|
||||
{
|
||||
return (rl_newline (1, '\n'));
|
||||
}
|
||||
@ -596,8 +582,7 @@ rl_vi_eof_maybe (count, c)
|
||||
/* Switching from one mode to the other really just involves
|
||||
switching keymaps. */
|
||||
int
|
||||
rl_vi_insertion_mode (count, key)
|
||||
int count, key;
|
||||
rl_vi_insertion_mode (int count __attribute__((unused)), int key)
|
||||
{
|
||||
_rl_keymap = vi_insertion_keymap;
|
||||
_rl_vi_last_key_before_insert = key;
|
||||
@ -659,8 +644,7 @@ _rl_vi_done_inserting ()
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_movement_mode (count, key)
|
||||
int count, key;
|
||||
rl_vi_movement_mode (int count __attribute__((unused)), int key)
|
||||
{
|
||||
if (rl_point > 0)
|
||||
rl_backward_char (1, key);
|
||||
@ -729,8 +713,7 @@ _rl_vi_change_mbchar_case (count)
|
||||
#endif
|
||||
|
||||
int
|
||||
rl_vi_change_case (count, ignore)
|
||||
int count, ignore;
|
||||
rl_vi_change_case (int count, int ignore __attribute__((unused)))
|
||||
{
|
||||
int c, p;
|
||||
|
||||
@ -959,8 +942,7 @@ rl_digit_loop1 ()
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_delete_to (count, key)
|
||||
int count, key;
|
||||
rl_vi_delete_to (int count __attribute__((unused)), int key)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -985,8 +967,7 @@ rl_vi_delete_to (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_change_to (count, key)
|
||||
int count, key;
|
||||
rl_vi_change_to (int count __attribute__((unused)), int key)
|
||||
{
|
||||
int c, start_pos;
|
||||
|
||||
@ -1038,8 +1019,7 @@ rl_vi_change_to (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_yank_to (count, key)
|
||||
int count, key;
|
||||
rl_vi_yank_to (int count __attribute__((unused)), int key)
|
||||
{
|
||||
int c, save = rl_point;
|
||||
|
||||
@ -1094,8 +1074,7 @@ rl_vi_delete (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_back_to_indent (count, key)
|
||||
int count, key;
|
||||
rl_vi_back_to_indent (int count __attribute__((unused)), int key)
|
||||
{
|
||||
rl_beg_of_line (1, key);
|
||||
while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
|
||||
@ -1104,8 +1083,7 @@ rl_vi_back_to_indent (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_first_print (count, key)
|
||||
int count, key;
|
||||
rl_vi_first_print (int count __attribute__((unused)), int key)
|
||||
{
|
||||
return (rl_vi_back_to_indent (1, key));
|
||||
}
|
||||
@ -1173,8 +1151,7 @@ rl_vi_char_search (count, key)
|
||||
|
||||
/* Match brackets */
|
||||
int
|
||||
rl_vi_match (ignore, key)
|
||||
int ignore, key;
|
||||
rl_vi_match (int ignore __attribute__((unused)), int key)
|
||||
{
|
||||
int count = 1, brack, pos, tmp, pre;
|
||||
|
||||
@ -1284,8 +1261,7 @@ rl_vi_bracktype (c)
|
||||
for test against 033 or ^C. Make sure that _rl_read_mbchar does
|
||||
this right. */
|
||||
int
|
||||
rl_vi_change_char (count, key)
|
||||
int count, key;
|
||||
rl_vi_change_char (int count, int key __attribute__((unused)))
|
||||
{
|
||||
int c, p;
|
||||
|
||||
@ -1389,8 +1365,7 @@ rl_vi_overstrike_delete (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_replace (count, key)
|
||||
int count, key;
|
||||
rl_vi_replace (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -1450,8 +1425,7 @@ rl_vi_possible_completions()
|
||||
|
||||
/* Functions to save and restore marks. */
|
||||
int
|
||||
rl_vi_set_mark (count, key)
|
||||
int count, key;
|
||||
rl_vi_set_mark (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
int ch;
|
||||
|
||||
@ -1470,8 +1444,7 @@ rl_vi_set_mark (count, key)
|
||||
}
|
||||
|
||||
int
|
||||
rl_vi_goto_mark (count, key)
|
||||
int count, key;
|
||||
rl_vi_goto_mark (int count __attribute__((unused)), int key __attribute__((unused)))
|
||||
{
|
||||
int ch;
|
||||
|
||||
|
@ -243,20 +243,20 @@ bdb_version_ok=yes
|
||||
])
|
||||
|
||||
AC_DEFUN([MYSQL_TOP_BUILDDIR], [
|
||||
# Remove trailing "./" if any
|
||||
[$1]=`echo $[$1] | sed -e 's,^\./,,'`
|
||||
case "$[$1]" in
|
||||
/* ) ;; # don't do anything with an absolute path
|
||||
"$srcdir"/* )
|
||||
"bdb" | "$srcdir/bdb" | "$top_srcdir/bdb" | "$abs_top_srcdir/bdb" )
|
||||
# If BDB is under the source directory, we need to look under the
|
||||
# build directory for bdb/build_unix.
|
||||
# NOTE: I'm being lazy, and assuming the user did not specify
|
||||
# something like --with-berkeley-db=bdb (it would be missing "./").
|
||||
[$1]="\$(top_builddir)/"`echo "$[$1]" | sed -e "s,^$srcdir/,,"`
|
||||
[$1]="\$(top_builddir)/bdb"
|
||||
;;
|
||||
/* ) ;; # Other absolute path is assume to be external BDB directory
|
||||
* )
|
||||
AC_MSG_ERROR([The BDB directory must be directly under the MySQL source directory, or be specified using the full path. ('$srcdir'; '$[$1]')])
|
||||
;;
|
||||
esac
|
||||
if test X"$[$1]" != "/"
|
||||
if test X"$[$1]" != X"/"
|
||||
then
|
||||
[$1]=`echo $[$1] | sed -e 's,/$,,'`
|
||||
fi
|
||||
|
@ -20,7 +20,7 @@ AC_DEFUN([MYSQL_CHECK_INNODB], [
|
||||
AC_MSG_RESULT([Using Innodb])
|
||||
AC_DEFINE([HAVE_INNOBASE_DB], [1], [Using Innobase DB])
|
||||
have_innodb="yes"
|
||||
innodb_includes="-I../innobase/include"
|
||||
innodb_includes="-I\$(top_builddir)/innobase/include -I\$(top_srcdir)/innobase/include"
|
||||
innodb_system_libs=""
|
||||
dnl Some libs are listed several times, in order for gcc to sort out
|
||||
dnl circular references.
|
||||
|
@ -140,7 +140,7 @@ AC_DEFUN([MYSQL_CHECK_NDBCLUSTER], [
|
||||
AC_MSG_RESULT([Using NDB Cluster])
|
||||
AC_DEFINE([HAVE_NDBCLUSTER_DB], [1], [Using Ndb Cluster DB])
|
||||
have_ndbcluster="yes"
|
||||
ndbcluster_includes="-I../ndb/include -I../ndb/include/ndbapi -I../ndb/include/mgmapi"
|
||||
ndbcluster_includes="-I\$(top_builddir)/ndb/include -I\$(top_srcdir)/ndb/include -I\$(top_srcdir)/ndb/include/ndbapi -I\$(top_srcdir)/ndb/include/mgmapi"
|
||||
ndbcluster_libs="\$(top_builddir)/ndb/src/.libs/libndbclient.a"
|
||||
ndbcluster_system_libs=""
|
||||
ndb_mgmclient_libs="\$(top_builddir)/ndb/src/mgmclient/libndbmgmclient.la"
|
||||
|
@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc)
|
||||
AC_CANONICAL_SYSTEM
|
||||
# The Docs Makefile.am parses this line!
|
||||
# remember to also change ndb version below and update version.c in ndb
|
||||
AM_INIT_AUTOMAKE(mysql, 5.0.30)
|
||||
AM_INIT_AUTOMAKE(mysql, 5.0.32)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
PROTOCOL_VERSION=10
|
||||
@ -19,7 +19,7 @@ SHARED_LIB_VERSION=$SHARED_LIB_MAJOR_VERSION:0:0
|
||||
# ndb version
|
||||
NDB_VERSION_MAJOR=5
|
||||
NDB_VERSION_MINOR=0
|
||||
NDB_VERSION_BUILD=30
|
||||
NDB_VERSION_BUILD=32
|
||||
NDB_VERSION_STATUS=""
|
||||
|
||||
# Set all version vars based on $VERSION. How do we do this more elegant ?
|
||||
|
@ -169,7 +169,7 @@ register unsigned long *child_time;
|
||||
*name_pos = temp->pos;
|
||||
*time_entered = temp->time;
|
||||
*child_time = temp->children;
|
||||
DBUG_PRINT ("pop", ("%d %d %d",*name_pos,*time_entered,*child_time));
|
||||
DBUG_PRINT ("pop", ("%d %lu %lu",*name_pos,*time_entered,*child_time));
|
||||
rtnval = stacktop--;
|
||||
}
|
||||
DBUG_RETURN (rtnval);
|
||||
@ -334,12 +334,12 @@ FILE *inf;
|
||||
* function is found on the stack.
|
||||
*/
|
||||
while (pop (&oldpos, &oldtime, &oldchild)) {
|
||||
DBUG_PRINT ("popped", ("%d %d", oldtime, oldchild));
|
||||
DBUG_PRINT ("popped", ("%lu %lu", oldtime, oldchild));
|
||||
time = fn_time - oldtime;
|
||||
t = top ();
|
||||
t -> children += time;
|
||||
DBUG_PRINT ("update", ("%s", modules[t -> pos].name));
|
||||
DBUG_PRINT ("update", ("%d", t -> children));
|
||||
DBUG_PRINT ("update", ("%lu", t -> children));
|
||||
time -= oldchild;
|
||||
modules[oldpos].m_time += time;
|
||||
modules[oldpos].m_calls++;
|
||||
@ -520,19 +520,19 @@ register unsigned long int *s_calls, *s_time;
|
||||
unsigned long int calls, time;
|
||||
|
||||
DBUG_ENTER ("out_body");
|
||||
DBUG_PRINT ("out_body", ("%d,%d",*s_calls,*s_time));
|
||||
DBUG_PRINT ("out_body", ("%lu,%lu",*s_calls,*s_time));
|
||||
if (root == MAXPROCS) {
|
||||
DBUG_PRINT ("out_body", ("%d,%d",*s_calls,*s_time));
|
||||
DBUG_PRINT ("out_body", ("%lu,%lu",*s_calls,*s_time));
|
||||
} else {
|
||||
while (root != MAXPROCS) {
|
||||
out_body (outf, s_table[root].lchild,s_calls,s_time);
|
||||
out_item (outf, &modules[s_table[root].pos],&calls,&time);
|
||||
DBUG_PRINT ("out_body", ("-- %d -- %d --", calls, time));
|
||||
DBUG_PRINT ("out_body", ("-- %lu -- %lu --", calls, time));
|
||||
*s_calls += calls;
|
||||
*s_time += time;
|
||||
root = s_table[root].rchild;
|
||||
}
|
||||
DBUG_PRINT ("out_body", ("%d,%d", *s_calls, *s_time));
|
||||
DBUG_PRINT ("out_body", ("%lu,%lu", *s_calls, *s_time));
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -1,4 +1,56 @@
|
||||
yaSSL Release notes, version 1.4.0 (08/13/06)
|
||||
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,
|
||||
@ -122,18 +174,6 @@ Choose (Re)Build All from the project workspace
|
||||
run Debug\testsuite.exe from yaSSL-Home\testsuite to test the build
|
||||
|
||||
|
||||
--To enable ia32 assembly for TaoCrypt ciphers and message digests
|
||||
|
||||
On MSVC this is always on
|
||||
|
||||
On GCC **, use ./configure --enable-ia32-asm
|
||||
|
||||
** This isn't on by default because of the use of intel syntax and the
|
||||
problem that olders versions of gas have with some addressing statements.
|
||||
If you enable this and get assemler errors during compilation or can't
|
||||
pass the TaoCrypt tests, please send todd@yassl.com a message and disable
|
||||
this option in the meantime.
|
||||
|
||||
|
||||
***************** yaSSL Release notes, version 1.0.5
|
||||
|
||||
|
@ -5,6 +5,35 @@
|
||||
//#define TEST_RESUME
|
||||
|
||||
|
||||
void ClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)
|
||||
{
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_free(ssl);
|
||||
tcp_close(sockfd);
|
||||
err_sys(msg);
|
||||
}
|
||||
|
||||
|
||||
#ifdef NON_BLOCKING
|
||||
void NonBlockingSSL_Connect(SSL* ssl, SSL_CTX* ctx, SOCKET_T& sockfd)
|
||||
{
|
||||
int ret = SSL_connect(ssl);
|
||||
while (ret =! SSL_SUCCESS && SSL_get_error(ssl, 0) ==
|
||||
SSL_ERROR_WANT_READ) {
|
||||
printf("... client would block\n");
|
||||
#ifdef _WIN32
|
||||
Sleep(1000);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
ret = SSL_connect(ssl);
|
||||
}
|
||||
if (ret != SSL_SUCCESS)
|
||||
ClientError(ctx, ssl, sockfd, "SSL_connect failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void client_test(void* args)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -18,6 +47,9 @@ void client_test(void* args)
|
||||
|
||||
set_args(argc, argv, *static_cast<func_args*>(args));
|
||||
tcp_connect(sockfd);
|
||||
#ifdef NON_BLOCKING
|
||||
tcp_set_nonblocking(sockfd);
|
||||
#endif
|
||||
|
||||
SSL_METHOD* method = TLSv1_client_method();
|
||||
SSL_CTX* ctx = SSL_CTX_new(method);
|
||||
@ -27,13 +59,13 @@ void client_test(void* args)
|
||||
|
||||
SSL_set_fd(ssl, sockfd);
|
||||
|
||||
|
||||
#ifdef NON_BLOCKING
|
||||
NonBlockingSSL_Connect(ssl, ctx, sockfd);
|
||||
#else
|
||||
if (SSL_connect(ssl) != SSL_SUCCESS)
|
||||
{
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_free(ssl);
|
||||
tcp_close(sockfd);
|
||||
err_sys("SSL_connect failed");
|
||||
}
|
||||
ClientError(ctx, ssl, sockfd, "SSL_connect failed");
|
||||
#endif
|
||||
showPeer(ssl);
|
||||
|
||||
const char* cipher = 0;
|
||||
@ -49,16 +81,14 @@ void client_test(void* args)
|
||||
|
||||
char msg[] = "hello yassl!";
|
||||
if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))
|
||||
{
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_free(ssl);
|
||||
tcp_close(sockfd);
|
||||
err_sys("SSL_write failed");
|
||||
}
|
||||
ClientError(ctx, ssl, sockfd, "SSL_write failed");
|
||||
|
||||
char reply[1024];
|
||||
reply[SSL_read(ssl, reply, sizeof(reply))] = 0;
|
||||
int input = SSL_read(ssl, reply, sizeof(reply));
|
||||
if (input > 0) {
|
||||
reply[input] = 0;
|
||||
printf("Server response: %s\n", reply);
|
||||
}
|
||||
|
||||
#ifdef TEST_RESUME
|
||||
SSL_SESSION* session = SSL_get_session(ssl);
|
||||
@ -75,24 +105,17 @@ void client_test(void* args)
|
||||
SSL_set_session(sslResume, session);
|
||||
|
||||
if (SSL_connect(sslResume) != SSL_SUCCESS)
|
||||
{
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_free(ssl);
|
||||
tcp_close(sockfd);
|
||||
err_sys("SSL resume failed");
|
||||
}
|
||||
ClientError(ctx, sslResume, sockfd, "SSL_resume failed");
|
||||
showPeer(sslResume);
|
||||
|
||||
if (SSL_write(sslResume, msg, sizeof(msg)) != sizeof(msg))
|
||||
{
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_free(ssl);
|
||||
tcp_close(sockfd);
|
||||
err_sys("SSL_write failed");
|
||||
}
|
||||
ClientError(ctx, sslResume, sockfd, "SSL_write failed");
|
||||
|
||||
reply[SSL_read(sslResume, reply, sizeof(reply))] = 0;
|
||||
input = SSL_read(sslResume, reply, sizeof(reply));
|
||||
if (input > 0) {
|
||||
reply[input] = 0;
|
||||
printf("Server response: %s\n", reply);
|
||||
}
|
||||
|
||||
SSL_shutdown(sslResume);
|
||||
SSL_free(sslResume);
|
||||
|
@ -3,6 +3,15 @@
|
||||
#include "../../testsuite/test.hpp"
|
||||
|
||||
|
||||
void EchoClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)
|
||||
{
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_free(ssl);
|
||||
tcp_close(sockfd);
|
||||
err_sys(msg);
|
||||
}
|
||||
|
||||
|
||||
void echoclient_test(void* args)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -35,7 +44,7 @@ void echoclient_test(void* args)
|
||||
|
||||
tcp_connect(sockfd);
|
||||
|
||||
SSL_METHOD* method = TLSv1_client_method();
|
||||
SSL_METHOD* method = SSLv23_client_method();
|
||||
SSL_CTX* ctx = SSL_CTX_new(method);
|
||||
set_certs(ctx);
|
||||
SSL* ssl = SSL_new(ctx);
|
||||
@ -43,12 +52,7 @@ void echoclient_test(void* args)
|
||||
SSL_set_fd(ssl, sockfd);
|
||||
|
||||
if (SSL_connect(ssl) != SSL_SUCCESS)
|
||||
{
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_free(ssl);
|
||||
tcp_close(sockfd);
|
||||
err_sys("SSL_connect failed");
|
||||
}
|
||||
EchoClientError(ctx, ssl, sockfd, "SSL_connect failed");
|
||||
|
||||
char send[1024];
|
||||
char reply[1024];
|
||||
@ -57,12 +61,7 @@ void echoclient_test(void* args)
|
||||
|
||||
int sendSz = strlen(send) + 1;
|
||||
if (SSL_write(ssl, send, sendSz) != sendSz)
|
||||
{
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_free(ssl);
|
||||
tcp_close(sockfd);
|
||||
err_sys("SSL_write failed");
|
||||
}
|
||||
EchoClientError(ctx, ssl, sockfd, "SSL_write failed");
|
||||
|
||||
if (strncmp(send, "quit", 4) == 0) {
|
||||
fputs("sending server shutdown command: quit!\n", fout);
|
||||
|
@ -56,7 +56,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
|
||||
|
||||
tcp_listen(sockfd);
|
||||
|
||||
SSL_METHOD* method = TLSv1_server_method();
|
||||
SSL_METHOD* method = SSLv23_server_method();
|
||||
SSL_CTX* ctx = SSL_CTX_new(method);
|
||||
|
||||
set_serverCerts(ctx);
|
||||
@ -87,8 +87,12 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
|
||||
|
||||
SSL* ssl = SSL_new(ctx);
|
||||
SSL_set_fd(ssl, clientfd);
|
||||
if (SSL_accept(ssl) != SSL_SUCCESS)
|
||||
EchoError(ctx, ssl, sockfd, clientfd, "SSL_accept failed");
|
||||
if (SSL_accept(ssl) != SSL_SUCCESS) {
|
||||
printf("SSL_accept failed\n");
|
||||
SSL_free(ssl);
|
||||
tcp_close(clientfd);
|
||||
continue;
|
||||
}
|
||||
|
||||
char command[1024];
|
||||
int echoSz(0);
|
||||
@ -130,6 +134,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args)
|
||||
if (SSL_write(ssl, command, echoSz) != echoSz)
|
||||
EchoError(ctx, ssl, sockfd, clientfd, "SSL_write failed");
|
||||
}
|
||||
SSL_shutdown(ssl);
|
||||
SSL_free(ssl);
|
||||
tcp_close(clientfd);
|
||||
}
|
||||
|
@ -13,6 +13,26 @@ void ServerError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)
|
||||
}
|
||||
|
||||
|
||||
#ifdef NON_BLOCKING
|
||||
void NonBlockingSSL_Accept(SSL* ssl, SSL_CTX* ctx, SOCKET_T& clientfd)
|
||||
{
|
||||
int ret = SSL_accept(ssl);
|
||||
while (ret != SSL_SUCCESS && SSL_get_error(ssl, 0) ==
|
||||
SSL_ERROR_WANT_READ) {
|
||||
printf("... server would block\n");
|
||||
#ifdef _WIN32
|
||||
Sleep(1000);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
ret = SSL_accept(ssl);
|
||||
}
|
||||
if (ret != SSL_SUCCESS)
|
||||
ServerError(ctx, ssl, clientfd, "SSL_accept failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
THREAD_RETURN YASSL_API server_test(void* args)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -33,7 +53,7 @@ THREAD_RETURN YASSL_API server_test(void* args)
|
||||
SSL_METHOD* method = TLSv1_server_method();
|
||||
SSL_CTX* ctx = SSL_CTX_new(method);
|
||||
|
||||
//SSL_CTX_set_cipher_list(ctx, "RC4-SHA");
|
||||
//SSL_CTX_set_cipher_list(ctx, "RC4-SHA:RC4-MD5");
|
||||
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);
|
||||
set_serverCerts(ctx);
|
||||
DH* dh = set_tmpDH(ctx);
|
||||
@ -41,15 +61,22 @@ THREAD_RETURN YASSL_API server_test(void* args)
|
||||
SSL* ssl = SSL_new(ctx);
|
||||
SSL_set_fd(ssl, clientfd);
|
||||
|
||||
#ifdef NON_BLOCKING
|
||||
NonBlockingSSL_Accept(ssl, ctx, clientfd);
|
||||
#else
|
||||
if (SSL_accept(ssl) != SSL_SUCCESS)
|
||||
ServerError(ctx, ssl, clientfd, "SSL_accept failed");
|
||||
#endif
|
||||
|
||||
showPeer(ssl);
|
||||
printf("Using Cipher Suite: %s\n", SSL_get_cipher(ssl));
|
||||
|
||||
char command[1024];
|
||||
command[SSL_read(ssl, command, sizeof(command))] = 0;
|
||||
int input = SSL_read(ssl, command, sizeof(command));
|
||||
if (input > 0) {
|
||||
command[input] = 0;
|
||||
printf("First client command: %s\n", command);
|
||||
}
|
||||
|
||||
char msg[] = "I hear you, fa shizzle!";
|
||||
if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))
|
||||
@ -57,6 +84,7 @@ THREAD_RETURN YASSL_API server_test(void* args)
|
||||
|
||||
DH_free(dh);
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_shutdown(ssl);
|
||||
SSL_free(ssl);
|
||||
|
||||
tcp_close(clientfd);
|
||||
@ -82,3 +110,4 @@ THREAD_RETURN YASSL_API server_test(void* args)
|
||||
}
|
||||
|
||||
#endif // NO_MAIN_DRIVER
|
||||
|
||||
|
@ -42,12 +42,7 @@
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
|
||||
|
||||
namespace yaSSL {
|
||||
|
@ -52,6 +52,7 @@
|
||||
#define SSL_set_session yaSSL_set_session
|
||||
#define SSL_get_session yaSSL_get_session
|
||||
#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
|
||||
@ -98,6 +99,8 @@
|
||||
#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
|
||||
@ -159,3 +162,4 @@
|
||||
#define MD5_Init yaMD5_Init
|
||||
#define MD5_Update yaMD5_Update
|
||||
#define MD5_Final yaMD5_Final
|
||||
#define SSL_set_compression yaSSL_set_compression
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "rsa.h"
|
||||
|
||||
|
||||
#define YASSL_VERSION "1.4.3"
|
||||
#define YASSL_VERSION "1.5.0"
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@ -228,6 +228,7 @@ void SSL_load_error_strings(void);
|
||||
int SSL_set_session(SSL *ssl, SSL_SESSION *session);
|
||||
SSL_SESSION* SSL_get_session(SSL* ssl);
|
||||
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*);
|
||||
|
||||
@ -361,6 +362,8 @@ 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);
|
||||
@ -531,6 +534,10 @@ void MD5_Final(unsigned char*, MD5_CTX*);
|
||||
#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)
|
||||
|
@ -70,8 +70,8 @@ typedef unsigned char byte;
|
||||
// Wraps Windows Sockets and BSD Sockets
|
||||
class Socket {
|
||||
socket_t socket_; // underlying socket descriptor
|
||||
bool wouldBlock_; // for non-blocking data
|
||||
bool blocking_; // is option set
|
||||
bool wouldBlock_; // if non-blocking data, for last read
|
||||
bool nonBlocking_; // is option set
|
||||
public:
|
||||
explicit Socket(socket_t s = INVALID_SOCKET);
|
||||
~Socket();
|
||||
@ -85,7 +85,7 @@ public:
|
||||
|
||||
bool wait();
|
||||
bool WouldBlock() const;
|
||||
bool IsBlocking() const;
|
||||
bool IsNonBlocking() const;
|
||||
|
||||
void closeSocket();
|
||||
void shutDown(int how = SD_SEND);
|
||||
|
@ -56,7 +56,10 @@ enum YasslError {
|
||||
receive_error = 114,
|
||||
certificate_error = 115,
|
||||
privateKey_error = 116,
|
||||
badVersion_error = 117
|
||||
badVersion_error = 117,
|
||||
compress_error = 118,
|
||||
decompress_error = 119,
|
||||
pms_version_error = 120
|
||||
|
||||
// !!!! add error message to .cpp !!!!
|
||||
|
||||
|
@ -132,7 +132,6 @@ class Data : public Message {
|
||||
public:
|
||||
Data();
|
||||
Data(uint16 len, opaque* b);
|
||||
Data(uint16 len, const opaque* w);
|
||||
|
||||
friend output_buffer& operator<<(output_buffer&, const Data&);
|
||||
|
||||
@ -141,9 +140,9 @@ public:
|
||||
|
||||
ContentType get_type() const;
|
||||
uint16 get_length() const;
|
||||
const opaque* get_buffer() 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
|
||||
@ -232,11 +231,11 @@ public:
|
||||
void Process(input_buffer&, SSL&);
|
||||
|
||||
const opaque* get_random() const;
|
||||
friend void buildClientHello(SSL&, ClientHello&, CompressionMethod);
|
||||
friend void buildClientHello(SSL&, ClientHello&);
|
||||
friend void ProcessOldClientHello(input_buffer& input, SSL& ssl);
|
||||
|
||||
ClientHello();
|
||||
explicit ClientHello(ProtocolVersion pv);
|
||||
ClientHello(ProtocolVersion pv, bool useCompression);
|
||||
private:
|
||||
ClientHello(const ClientHello&); // hide copy
|
||||
ClientHello& operator=(const ClientHello&); // and assign
|
||||
@ -253,7 +252,7 @@ class ServerHello : public HandShakeBase {
|
||||
opaque cipher_suite_[SUITE_LEN];
|
||||
CompressionMethod compression_method_;
|
||||
public:
|
||||
explicit ServerHello(ProtocolVersion pv);
|
||||
ServerHello(ProtocolVersion pv, bool useCompression);
|
||||
ServerHello();
|
||||
|
||||
friend input_buffer& operator>>(input_buffer&, ServerHello&);
|
||||
@ -629,8 +628,11 @@ struct Connection {
|
||||
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
|
||||
ProtocolVersion version_;
|
||||
bool compression_; // zlib compression?
|
||||
ProtocolVersion version_; // negotiated version
|
||||
ProtocolVersion chVersion_; // client hello version
|
||||
RandomPool& random_;
|
||||
|
||||
Connection(ProtocolVersion v, RandomPool& ran);
|
||||
@ -640,6 +642,7 @@ struct Connection {
|
||||
void CleanPreMaster();
|
||||
void CleanMaster();
|
||||
void TurnOffTLS();
|
||||
void TurnOffTLS1_1();
|
||||
private:
|
||||
Connection(const Connection&); // hide copy
|
||||
Connection& operator=(const Connection&); // and assign
|
||||
|
@ -431,6 +431,7 @@ private:
|
||||
DH_Parms dhParms_;
|
||||
pem_password_cb passwordCb_;
|
||||
void* userData_;
|
||||
bool sessionCacheOff_;
|
||||
Stats stats_;
|
||||
Mutex mutex_; // for Stats
|
||||
public:
|
||||
@ -445,6 +446,7 @@ public:
|
||||
const Stats& GetStats() const;
|
||||
pem_password_cb GetPasswordCb() const;
|
||||
void* GetUserData() const;
|
||||
bool GetSessionCacheOff() const;
|
||||
|
||||
void setVerifyPeer();
|
||||
void setVerifyNone();
|
||||
@ -453,6 +455,7 @@ public:
|
||||
bool SetDH(const DH&);
|
||||
void SetPasswordCb(pem_password_cb cb);
|
||||
void SetUserData(void*);
|
||||
void SetSessionCacheOff();
|
||||
|
||||
void IncrementStats(StatsField);
|
||||
void AddCA(x509* ca);
|
||||
@ -600,6 +603,7 @@ public:
|
||||
const Socket& getSocket() const;
|
||||
YasslError GetError() const;
|
||||
bool GetMultiProtocol() const;
|
||||
bool CompressionOn() const;
|
||||
|
||||
Crypto& useCrypto();
|
||||
Security& useSecurity();
|
||||
@ -617,9 +621,12 @@ public:
|
||||
void set_preMaster(const opaque*, uint);
|
||||
void set_masterSecret(const opaque*);
|
||||
void SetError(YasslError);
|
||||
int SetCompression();
|
||||
void UnSetCompression();
|
||||
|
||||
// helpers
|
||||
bool isTLS() const;
|
||||
bool isTLSv1_1() const;
|
||||
void order_error();
|
||||
void makeMasterSecret();
|
||||
void makeTLSMasterSecret();
|
||||
@ -653,6 +660,10 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// compression
|
||||
int Compress(const byte*, int, input_buffer&);
|
||||
int DeCompress(input_buffer&, int, input_buffer&);
|
||||
|
||||
|
||||
// conversion functions
|
||||
void c32to24(uint32, uint24&);
|
||||
|
@ -211,6 +211,7 @@ 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
|
||||
|
||||
|
||||
typedef uint8 Cipher; // first byte is always 0x00 for SSLv3 & TLS
|
||||
@ -222,7 +223,7 @@ typedef opaque* DistinguishedName;
|
||||
typedef bool IsExportable;
|
||||
|
||||
|
||||
enum CompressionMethod { no_compression = 0 };
|
||||
enum CompressionMethod { no_compression = 0, zlib = 221 };
|
||||
|
||||
enum CipherType { stream, block };
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
INCLUDES = -I../include -I../taocrypt/include -I../taocrypt/mySTL
|
||||
INCLUDES = -I$(srcdir)/../include -I$(srcdir)/../taocrypt/include -I$(srcdir)/../taocrypt/mySTL
|
||||
|
||||
noinst_LTLIBRARIES = libyassl.la
|
||||
libyassl_la_SOURCES = buffer.cpp cert_wrapper.cpp crypto_wrapper.cpp \
|
||||
|
@ -40,9 +40,11 @@ namespace yaSSL {
|
||||
|
||||
|
||||
// Build a client hello message from cipher suites and compression method
|
||||
void buildClientHello(SSL& ssl, ClientHello& hello,
|
||||
CompressionMethod compression = no_compression)
|
||||
void buildClientHello(SSL& ssl, ClientHello& hello)
|
||||
{
|
||||
// store for pre master secret
|
||||
ssl.useSecurity().use_connection().chVersion_ = hello.client_version_;
|
||||
|
||||
ssl.getCrypto().get_random().Fill(hello.random_, RAN_LEN);
|
||||
if (ssl.getSecurity().get_resuming()) {
|
||||
hello.id_len_ = ID_LEN;
|
||||
@ -55,7 +57,6 @@ void buildClientHello(SSL& ssl, ClientHello& hello,
|
||||
memcpy(hello.cipher_suites_, ssl.getSecurity().get_parms().suites_,
|
||||
hello.suite_len_);
|
||||
hello.comp_len_ = 1;
|
||||
hello.compression_methods_ = compression;
|
||||
|
||||
hello.set_length(sizeof(ProtocolVersion) +
|
||||
RAN_LEN +
|
||||
@ -83,7 +84,7 @@ void buildServerHello(SSL& ssl, ServerHello& hello)
|
||||
|
||||
hello.cipher_suite_[0] = ssl.getSecurity().get_parms().suite_[0];
|
||||
hello.cipher_suite_[1] = ssl.getSecurity().get_parms().suite_[1];
|
||||
hello.compression_method_ = no_compression;
|
||||
hello.compression_method_ = hello.compression_method_;
|
||||
|
||||
hello.set_length(sizeof(ProtocolVersion) + RAN_LEN + ID_LEN +
|
||||
sizeof(hello.id_len_) + SUITE_LEN + SIZEOF_ENUM);
|
||||
@ -151,12 +152,18 @@ void buildHeaders(SSL& ssl, HandShakeHeader& hsHeader,
|
||||
|
||||
|
||||
// add handshake from buffer into md5 and sha hashes, exclude record header
|
||||
void hashHandShake(SSL& ssl, const output_buffer& output)
|
||||
void hashHandShake(SSL& ssl, const output_buffer& output, bool removeIV = false)
|
||||
{
|
||||
uint sz = output.get_size() - RECORD_HEADER;
|
||||
|
||||
const opaque* buffer = output.get_buffer() + RECORD_HEADER;
|
||||
|
||||
if (removeIV) { // TLSv1_1 IV
|
||||
uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();
|
||||
sz -= blockSz;
|
||||
buffer += blockSz;
|
||||
}
|
||||
|
||||
ssl.useHashes().use_MD5().update(buffer, sz);
|
||||
ssl.useHashes().use_SHA().update(buffer, sz);
|
||||
}
|
||||
@ -229,6 +236,18 @@ void decrypt_message(SSL& ssl, input_buffer& input, uint sz)
|
||||
ssl.useCrypto().use_cipher().decrypt(plain.get_buffer(), cipher, sz);
|
||||
memcpy(cipher, plain.get_buffer(), sz);
|
||||
ssl.useSecurity().use_parms().encrypt_size_ = sz;
|
||||
|
||||
if (ssl.isTLSv1_1()) // IV
|
||||
input.set_current(input.get_current() +
|
||||
ssl.getCrypto().get_cipher().get_blockSize());
|
||||
}
|
||||
|
||||
|
||||
// output operator for input_buffer
|
||||
output_buffer& operator<<(output_buffer& output, const input_buffer& input)
|
||||
{
|
||||
output.write(input.get_buffer(), input.get_size());
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@ -239,9 +258,12 @@ void cipherFinished(SSL& ssl, Finished& fin, output_buffer& output)
|
||||
uint finishedSz = ssl.isTLS() ? TLS_FINISHED_SZ : FINISHED_SZ;
|
||||
uint sz = RECORD_HEADER + HANDSHAKE_HEADER + finishedSz + digestSz;
|
||||
uint pad = 0;
|
||||
uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();
|
||||
|
||||
if (ssl.getSecurity().get_parms().cipher_type_ == block) {
|
||||
if (ssl.isTLSv1_1())
|
||||
sz += blockSz; // IV
|
||||
sz += 1; // pad byte
|
||||
uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();
|
||||
pad = (sz - RECORD_HEADER) % blockSz;
|
||||
pad = blockSz - pad;
|
||||
sz += pad;
|
||||
@ -252,14 +274,21 @@ void cipherFinished(SSL& ssl, Finished& fin, output_buffer& output)
|
||||
buildHeaders(ssl, hsHeader, rlHeader, fin);
|
||||
rlHeader.length_ = sz - RECORD_HEADER; // record header includes mac
|
||||
// and pad, hanshake doesn't
|
||||
input_buffer iv;
|
||||
if (ssl.isTLSv1_1() && ssl.getSecurity().get_parms().cipher_type_== block){
|
||||
iv.allocate(blockSz);
|
||||
ssl.getCrypto().get_random().Fill(iv.get_buffer(), blockSz);
|
||||
iv.add_size(blockSz);
|
||||
}
|
||||
uint ivSz = iv.get_size();
|
||||
output.allocate(sz);
|
||||
output << rlHeader << hsHeader << fin;
|
||||
output << rlHeader << iv << hsHeader << fin;
|
||||
|
||||
hashHandShake(ssl, output);
|
||||
hashHandShake(ssl, output, ssl.isTLSv1_1() ? true : false);
|
||||
opaque digest[SHA_LEN]; // max size
|
||||
if (ssl.isTLS())
|
||||
TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER,
|
||||
output.get_size() - RECORD_HEADER, handshake);
|
||||
TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER + ivSz,
|
||||
output.get_size() - RECORD_HEADER - ivSz, handshake);
|
||||
else
|
||||
hmac(ssl, digest, output.get_buffer() + RECORD_HEADER,
|
||||
output.get_size() - RECORD_HEADER, handshake);
|
||||
@ -282,9 +311,12 @@ void buildMessage(SSL& ssl, output_buffer& output, const Message& msg)
|
||||
uint digestSz = ssl.getCrypto().get_digest().get_digestSize();
|
||||
uint sz = RECORD_HEADER + msg.get_length() + digestSz;
|
||||
uint pad = 0;
|
||||
uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();
|
||||
|
||||
if (ssl.getSecurity().get_parms().cipher_type_ == block) {
|
||||
if (ssl.isTLSv1_1()) // IV
|
||||
sz += blockSz;
|
||||
sz += 1; // pad byte
|
||||
uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();
|
||||
pad = (sz - RECORD_HEADER) % blockSz;
|
||||
pad = blockSz - pad;
|
||||
sz += pad;
|
||||
@ -294,13 +326,21 @@ void buildMessage(SSL& ssl, output_buffer& output, const Message& msg)
|
||||
buildHeader(ssl, rlHeader, msg);
|
||||
rlHeader.length_ = sz - RECORD_HEADER; // record header includes mac
|
||||
// and pad, hanshake doesn't
|
||||
input_buffer iv;
|
||||
if (ssl.isTLSv1_1() && ssl.getSecurity().get_parms().cipher_type_== block){
|
||||
iv.allocate(blockSz);
|
||||
ssl.getCrypto().get_random().Fill(iv.get_buffer(), blockSz);
|
||||
iv.add_size(blockSz);
|
||||
}
|
||||
|
||||
uint ivSz = iv.get_size();
|
||||
output.allocate(sz);
|
||||
output << rlHeader << msg;
|
||||
output << rlHeader << iv << msg;
|
||||
|
||||
opaque digest[SHA_LEN]; // max size
|
||||
if (ssl.isTLS())
|
||||
TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER,
|
||||
output.get_size() - RECORD_HEADER, msg.get_type());
|
||||
TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER + ivSz,
|
||||
output.get_size() - RECORD_HEADER - ivSz, msg.get_type());
|
||||
else
|
||||
hmac(ssl, digest, output.get_buffer() + RECORD_HEADER,
|
||||
output.get_size() - RECORD_HEADER, msg.get_type());
|
||||
@ -456,6 +496,10 @@ void buildSHA_CertVerify(SSL& ssl, byte* digest)
|
||||
// some clients still send sslv2 client hello
|
||||
void ProcessOldClientHello(input_buffer& input, SSL& ssl)
|
||||
{
|
||||
if (input.get_remaining() < 2) {
|
||||
ssl.SetError(bad_input);
|
||||
return;
|
||||
}
|
||||
byte b0 = input[AUTO];
|
||||
byte b1 = input[AUTO];
|
||||
|
||||
@ -721,6 +765,7 @@ int DoProcessReply(SSL& ssl)
|
||||
// each message in record, can be more than 1 if not encrypted
|
||||
if (ssl.getSecurity().get_parms().pending_ == false) // cipher on
|
||||
decrypt_message(ssl, buffer, hdr.length_);
|
||||
|
||||
mySTL::auto_ptr<Message> msg(mf.CreateObject(hdr.type_));
|
||||
if (!msg.get()) {
|
||||
ssl.SetError(factory_error);
|
||||
@ -744,13 +789,13 @@ void processReply(SSL& ssl)
|
||||
|
||||
if (DoProcessReply(ssl))
|
||||
// didn't complete process
|
||||
if (!ssl.getSocket().IsBlocking()) {
|
||||
// keep trying now
|
||||
if (!ssl.getSocket().IsNonBlocking()) {
|
||||
// keep trying now, blocking ok
|
||||
while (!ssl.GetError())
|
||||
if (DoProcessReply(ssl) == 0) break;
|
||||
}
|
||||
else
|
||||
// user will have try again later
|
||||
// user will have try again later, non blocking
|
||||
ssl.SetError(YasslError(SSL_ERROR_WANT_READ));
|
||||
}
|
||||
|
||||
@ -761,7 +806,8 @@ void sendClientHello(SSL& ssl)
|
||||
ssl.verifyState(serverNull);
|
||||
if (ssl.GetError()) return;
|
||||
|
||||
ClientHello ch(ssl.getSecurity().get_connection().version_);
|
||||
ClientHello ch(ssl.getSecurity().get_connection().version_,
|
||||
ssl.getSecurity().get_connection().compression_);
|
||||
RecordLayerHeader rlHeader;
|
||||
HandShakeHeader hsHeader;
|
||||
output_buffer out;
|
||||
@ -859,6 +905,7 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer)
|
||||
buildFinished(ssl, ssl.useHashes().use_verify(), client); // client
|
||||
}
|
||||
else {
|
||||
if (!ssl.getSecurity().GetContext()->GetSessionCacheOff())
|
||||
GetSessions().add(ssl); // store session
|
||||
if (side == client_end)
|
||||
buildFinished(ssl, ssl.useHashes().use_verify(), server); // server
|
||||
@ -885,7 +932,20 @@ int sendData(SSL& ssl, const void* buffer, int sz)
|
||||
for (;;) {
|
||||
int len = min(sz - sent, MAX_RECORD_SIZE);
|
||||
output_buffer out;
|
||||
const Data data(len, static_cast<const opaque*>(buffer) + sent);
|
||||
input_buffer tmp;
|
||||
|
||||
Data data;
|
||||
|
||||
if (ssl.CompressionOn()) {
|
||||
if (Compress(static_cast<const opaque*>(buffer) + sent, len,
|
||||
tmp) == -1) {
|
||||
ssl.SetError(compress_error);
|
||||
return -1;
|
||||
}
|
||||
data.SetData(tmp.get_size(), tmp.get_buffer());
|
||||
}
|
||||
else
|
||||
data.SetData(len, static_cast<const opaque*>(buffer) + sent);
|
||||
|
||||
buildMessage(ssl, out, data);
|
||||
ssl.Send(out.get_buffer(), out.get_size());
|
||||
@ -947,7 +1007,8 @@ void sendServerHello(SSL& ssl, BufferOutput buffer)
|
||||
ssl.verifyState(clientHelloComplete);
|
||||
if (ssl.GetError()) return;
|
||||
|
||||
ServerHello sh(ssl.getSecurity().get_connection().version_);
|
||||
ServerHello sh(ssl.getSecurity().get_connection().version_,
|
||||
ssl.getSecurity().get_connection().compression_);
|
||||
RecordLayerHeader rlHeader;
|
||||
HandShakeHeader hsHeader;
|
||||
mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);
|
||||
|
@ -1,7 +1,7 @@
|
||||
REM quick and dirty build file for testing different MSDEVs
|
||||
setlocal
|
||||
|
||||
set myFLAGS= /I../include /I../mySTL /I../taocrypt/include /W3 /c /ZI
|
||||
set myFLAGS= /I../include /I../taocrypt/mySTL /I../taocrypt/include /W3 /c /ZI
|
||||
|
||||
cl %myFLAGS% buffer.cpp
|
||||
cl %myFLAGS% cert_wrapper.cpp
|
||||
|
@ -63,7 +63,7 @@ namespace yaSSL {
|
||||
|
||||
|
||||
Socket::Socket(socket_t s)
|
||||
: socket_(s), wouldBlock_(false), blocking_(false)
|
||||
: socket_(s), wouldBlock_(false), nonBlocking_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -148,8 +148,8 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags)
|
||||
if (recvd == -1) {
|
||||
if (get_lastError() == SOCKET_EWOULDBLOCK ||
|
||||
get_lastError() == SOCKET_EAGAIN) {
|
||||
wouldBlock_ = true;
|
||||
blocking_ = true; // socket can block, only way to tell for win32
|
||||
wouldBlock_ = true; // would have blocked this time only
|
||||
nonBlocking_ = true; // socket nonblocking, win32 only way to tell
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -191,9 +191,9 @@ bool Socket::WouldBlock() const
|
||||
}
|
||||
|
||||
|
||||
bool Socket::IsBlocking() const
|
||||
bool Socket::IsNonBlocking() const
|
||||
{
|
||||
return blocking_;
|
||||
return nonBlocking_;
|
||||
}
|
||||
|
||||
|
||||
|
@ -184,10 +184,22 @@ SSL_METHOD* TLSv1_client_method()
|
||||
}
|
||||
|
||||
|
||||
SSL_METHOD* TLSv1_1_server_method()
|
||||
{
|
||||
return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2));
|
||||
}
|
||||
|
||||
|
||||
SSL_METHOD* TLSv1_1_client_method()
|
||||
{
|
||||
return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2));
|
||||
}
|
||||
|
||||
|
||||
SSL_METHOD* SSLv23_server_method()
|
||||
{
|
||||
// compatibility only, no version 2 support, but does SSL 3 and TLS 1
|
||||
return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,1), true);
|
||||
return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2), true);
|
||||
}
|
||||
|
||||
|
||||
@ -196,7 +208,7 @@ SSL_METHOD* SSLv23_client_method()
|
||||
// compatibility only, no version 2 support, but does SSL 3 and TLS 1
|
||||
// though it sends TLS1 hello not SSLv2 so SSLv3 only servers will decline
|
||||
// TODO: maybe add support to send SSLv2 hello ???
|
||||
return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,1), true);
|
||||
return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2), true);
|
||||
}
|
||||
|
||||
|
||||
@ -407,7 +419,6 @@ int SSL_shutdown(SSL* ssl)
|
||||
Alert alert(warning, close_notify);
|
||||
sendAlert(*ssl, alert);
|
||||
ssl->useLog().ShowTCP(ssl->getSocket().get_fd(), true);
|
||||
ssl->useSocket().closeSocket();
|
||||
|
||||
GetErrors().Remove();
|
||||
|
||||
@ -415,8 +426,21 @@ int SSL_shutdown(SSL* ssl)
|
||||
}
|
||||
|
||||
|
||||
/* on by default but allow user to turn off */
|
||||
long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode)
|
||||
{
|
||||
if (mode == SSL_SESS_CACHE_OFF)
|
||||
ctx->SetSessionCacheOff();
|
||||
|
||||
return SSL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
SSL_SESSION* SSL_get_session(SSL* ssl)
|
||||
{
|
||||
if (ssl->getSecurity().GetContext()->GetSessionCacheOff())
|
||||
return 0;
|
||||
|
||||
return GetSessions().lookup(
|
||||
ssl->getSecurity().get_connection().sessionID_);
|
||||
}
|
||||
@ -424,6 +448,9 @@ SSL_SESSION* SSL_get_session(SSL* ssl)
|
||||
|
||||
int SSL_set_session(SSL* ssl, SSL_SESSION* session)
|
||||
{
|
||||
if (ssl->getSecurity().GetContext()->GetSessionCacheOff())
|
||||
return SSL_FAILURE;
|
||||
|
||||
ssl->set_session(session);
|
||||
return SSL_SUCCESS;
|
||||
}
|
||||
@ -512,6 +539,19 @@ int SSL_get_error(SSL* ssl, int /*previous*/)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* turn on yaSSL zlib compression
|
||||
returns 0 for success, else error (not built in)
|
||||
only need to turn on for client, becuase server on by default if built in
|
||||
but calling for server will tell you whether it's available or not
|
||||
*/
|
||||
int SSL_set_compression(SSL* ssl)
|
||||
{
|
||||
return ssl->SetCompression();
|
||||
}
|
||||
|
||||
|
||||
|
||||
X509* SSL_get_peer_certificate(SSL* ssl)
|
||||
{
|
||||
return ssl->getCrypto().get_certManager().get_peerX509();
|
||||
@ -918,7 +958,7 @@ void ERR_print_errors_fp(FILE* /*fp*/)
|
||||
|
||||
char* ERR_error_string(unsigned long errNumber, char* buffer)
|
||||
{
|
||||
static char* msg = "Please supply a buffer for error string";
|
||||
static char* msg = (char*) "Please supply a buffer for error string";
|
||||
|
||||
if (buffer) {
|
||||
SetErrorString(YasslError(errNumber), buffer);
|
||||
@ -1359,6 +1399,56 @@ int SSL_pending(SSL* ssl)
|
||||
}
|
||||
|
||||
|
||||
void SSL_CTX_set_default_passwd_cb(SSL_CTX* ctx, pem_password_cb cb)
|
||||
{
|
||||
ctx->SetPasswordCb(cb);
|
||||
}
|
||||
|
||||
|
||||
int SSLeay_add_ssl_algorithms() // compatibility only
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void ERR_remove_state(unsigned long)
|
||||
{
|
||||
GetErrors().Remove();
|
||||
}
|
||||
|
||||
|
||||
int ERR_GET_REASON(int l)
|
||||
{
|
||||
return l & 0xfff;
|
||||
}
|
||||
|
||||
|
||||
unsigned long err_helper(bool peek = false)
|
||||
{
|
||||
int ysError = GetErrors().Lookup(peek);
|
||||
|
||||
// translate cert error for libcurl, it uses OpenSSL hex code
|
||||
switch (ysError) {
|
||||
case TaoCrypt::SIG_OTHER_E:
|
||||
return CERTFICATE_ERROR;
|
||||
break;
|
||||
default :
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned long ERR_peek_error()
|
||||
{
|
||||
return err_helper(true);
|
||||
}
|
||||
|
||||
|
||||
unsigned long ERR_get_error()
|
||||
{
|
||||
return err_helper();
|
||||
}
|
||||
|
||||
|
||||
// functions for stunnel
|
||||
|
||||
@ -1477,13 +1567,6 @@ int SSL_pending(SSL* ssl)
|
||||
}
|
||||
|
||||
|
||||
long SSL_CTX_set_session_cache_mode(SSL_CTX*, long)
|
||||
{
|
||||
// TDOD:
|
||||
return SSL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
long SSL_CTX_set_timeout(SSL_CTX*, long)
|
||||
{
|
||||
// TDOD:
|
||||
@ -1498,12 +1581,6 @@ int SSL_pending(SSL* ssl)
|
||||
}
|
||||
|
||||
|
||||
void SSL_CTX_set_default_passwd_cb(SSL_CTX* ctx, pem_password_cb cb)
|
||||
{
|
||||
ctx->SetPasswordCb(cb);
|
||||
}
|
||||
|
||||
|
||||
int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX*, const char*, int)
|
||||
{
|
||||
// TDOD:
|
||||
@ -1555,49 +1632,6 @@ int SSL_pending(SSL* ssl)
|
||||
}
|
||||
|
||||
|
||||
int SSLeay_add_ssl_algorithms() // compatibility only
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void ERR_remove_state(unsigned long)
|
||||
{
|
||||
GetErrors().Remove();
|
||||
}
|
||||
|
||||
|
||||
int ERR_GET_REASON(int l)
|
||||
{
|
||||
return l & 0xfff;
|
||||
}
|
||||
|
||||
unsigned long err_helper(bool peek = false)
|
||||
{
|
||||
int ysError = GetErrors().Lookup(peek);
|
||||
|
||||
// translate cert error for libcurl, it uses OpenSSL hex code
|
||||
switch (ysError) {
|
||||
case TaoCrypt::SIG_OTHER_E:
|
||||
return CERTFICATE_ERROR;
|
||||
break;
|
||||
default :
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned long ERR_peek_error()
|
||||
{
|
||||
return err_helper(true);
|
||||
}
|
||||
|
||||
|
||||
unsigned long ERR_get_error()
|
||||
{
|
||||
return err_helper();
|
||||
}
|
||||
|
||||
|
||||
// end stunnel needs
|
||||
|
||||
|
@ -133,6 +133,18 @@ void SetErrorString(YasslError error, char* buffer)
|
||||
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);
|
||||
|
@ -87,7 +87,7 @@ void EncryptedPreMasterSecret::build(SSL& ssl)
|
||||
opaque tmp[SECRET_LEN];
|
||||
memset(tmp, 0, sizeof(tmp));
|
||||
ssl.getCrypto().get_random().Fill(tmp, SECRET_LEN);
|
||||
ProtocolVersion pv = ssl.getSecurity().get_connection().version_;
|
||||
ProtocolVersion pv = ssl.getSecurity().get_connection().chVersion_;
|
||||
tmp[0] = pv.major_;
|
||||
tmp[1] = pv.minor_;
|
||||
ssl.set_preMaster(tmp, SECRET_LEN);
|
||||
@ -233,6 +233,10 @@ void EncryptedPreMasterSecret::read(SSL& ssl, input_buffer& input)
|
||||
rsa.decrypt(preMasterSecret, secret_, length_,
|
||||
ssl.getCrypto().get_random());
|
||||
|
||||
ProtocolVersion pv = ssl.getSecurity().get_connection().chVersion_;
|
||||
if (pv.major_ != preMasterSecret[0] || pv.minor_ != preMasterSecret[1])
|
||||
ssl.SetError(pms_version_error); // continue deriving for timing attack
|
||||
|
||||
ssl.set_preMaster(preMasterSecret, SECRET_LEN);
|
||||
ssl.makeMasterSecret();
|
||||
}
|
||||
@ -437,6 +441,7 @@ Parameters::Parameters(ConnectionEnd ce, const Ciphers& ciphers,
|
||||
ProtocolVersion pv, bool haveDH) : entity_(ce)
|
||||
{
|
||||
pending_ = true; // suite not set yet
|
||||
strncpy(cipher_name_, "NONE", 5);
|
||||
|
||||
if (ciphers.setSuites_) { // use user set list
|
||||
suites_size_ = ciphers.suiteSz_;
|
||||
@ -445,6 +450,7 @@ Parameters::Parameters(ConnectionEnd ce, const Ciphers& ciphers,
|
||||
}
|
||||
else
|
||||
SetSuites(pv, ce == server_end && !haveDH); // defaults
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -613,14 +619,18 @@ output_buffer& operator<<(output_buffer& output, const HandShakeHeader& hdr)
|
||||
void HandShakeHeader::Process(input_buffer& input, SSL& ssl)
|
||||
{
|
||||
ssl.verifyState(*this);
|
||||
if (ssl.GetError()) return;
|
||||
const HandShakeFactory& hsf = ssl.getFactory().getHandShake();
|
||||
mySTL::auto_ptr<HandShakeBase> hs(hsf.CreateObject(type_));
|
||||
if (!hs.get()) {
|
||||
ssl.SetError(factory_error);
|
||||
return;
|
||||
}
|
||||
hashHandShake(ssl, input, c24to32(length_));
|
||||
|
||||
uint len = c24to32(length_);
|
||||
hashHandShake(ssl, input, len);
|
||||
|
||||
hs->set_length(len);
|
||||
input >> *hs;
|
||||
hs->Process(input, ssl);
|
||||
}
|
||||
@ -849,11 +859,17 @@ void Alert::Process(input_buffer& input, SSL& ssl)
|
||||
opaque mac[SHA_LEN];
|
||||
input.read(mac, digestSz);
|
||||
|
||||
if (ssl.getSecurity().get_parms().cipher_type_ == block) {
|
||||
int ivExtra = 0;
|
||||
opaque fill;
|
||||
int padSz = ssl.getSecurity().get_parms().encrypt_size_ - aSz -
|
||||
digestSz;
|
||||
|
||||
if (ssl.isTLSv1_1())
|
||||
ivExtra = ssl.getCrypto().get_cipher().get_blockSize();
|
||||
int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra -
|
||||
aSz - digestSz;
|
||||
for (int i = 0; i < padSz; i++)
|
||||
fill = input[AUTO];
|
||||
}
|
||||
|
||||
// verify
|
||||
if (memcmp(mac, verify, digestSz)) {
|
||||
@ -879,9 +895,13 @@ Data::Data(uint16 len, opaque* b)
|
||||
{}
|
||||
|
||||
|
||||
Data::Data(uint16 len, const opaque* w)
|
||||
: length_(len), buffer_(0), write_buffer_(w)
|
||||
{}
|
||||
void Data::SetData(uint16 len, const opaque* buffer)
|
||||
{
|
||||
assert(write_buffer_ == 0);
|
||||
|
||||
length_ = len;
|
||||
write_buffer_ = buffer;
|
||||
}
|
||||
|
||||
input_buffer& Data::set(input_buffer& in)
|
||||
{
|
||||
@ -907,17 +927,12 @@ uint16 Data::get_length() const
|
||||
}
|
||||
|
||||
|
||||
const opaque* Data::get_buffer() const
|
||||
{
|
||||
return write_buffer_;
|
||||
}
|
||||
|
||||
|
||||
void Data::set_length(uint16 l)
|
||||
{
|
||||
length_ = l;
|
||||
}
|
||||
|
||||
|
||||
opaque* Data::set_buffer()
|
||||
{
|
||||
return buffer_;
|
||||
@ -937,27 +952,42 @@ void Data::Process(input_buffer& input, SSL& ssl)
|
||||
{
|
||||
int msgSz = ssl.getSecurity().get_parms().encrypt_size_;
|
||||
int pad = 0, padByte = 0;
|
||||
int ivExtra = 0;
|
||||
|
||||
if (ssl.getSecurity().get_parms().cipher_type_ == block) {
|
||||
pad = *(input.get_buffer() + input.get_current() + msgSz - 1);
|
||||
if (ssl.isTLSv1_1()) // IV
|
||||
ivExtra = ssl.getCrypto().get_cipher().get_blockSize();
|
||||
pad = *(input.get_buffer() + input.get_current() + msgSz -ivExtra - 1);
|
||||
padByte = 1;
|
||||
}
|
||||
int digestSz = ssl.getCrypto().get_digest().get_digestSize();
|
||||
int dataSz = msgSz - digestSz - pad - padByte;
|
||||
int dataSz = msgSz - ivExtra - digestSz - pad - padByte;
|
||||
opaque verify[SHA_LEN];
|
||||
|
||||
const byte* rawData = input.get_buffer() + input.get_current();
|
||||
|
||||
// read data
|
||||
if (dataSz) {
|
||||
if (dataSz) { // could be compressed
|
||||
if (ssl.CompressionOn()) {
|
||||
input_buffer tmp;
|
||||
if (DeCompress(input, dataSz, tmp) == -1) {
|
||||
ssl.SetError(decompress_error);
|
||||
return;
|
||||
}
|
||||
ssl.addData(NEW_YS input_buffer(tmp.get_size(),
|
||||
tmp.get_buffer(), tmp.get_size()));
|
||||
}
|
||||
else {
|
||||
input_buffer* data;
|
||||
ssl.addData(data = NEW_YS input_buffer(dataSz));
|
||||
input.read(data->get_buffer(), dataSz);
|
||||
data->add_size(dataSz);
|
||||
}
|
||||
|
||||
if (ssl.isTLS())
|
||||
TLS_hmac(ssl, verify, data->get_buffer(), dataSz, application_data,
|
||||
true);
|
||||
TLS_hmac(ssl, verify, rawData, dataSz, application_data, true);
|
||||
else
|
||||
hmac(ssl, verify, data->get_buffer(), dataSz, application_data,
|
||||
true);
|
||||
hmac(ssl, verify, rawData, dataSz, application_data, true);
|
||||
}
|
||||
|
||||
// read mac and fill
|
||||
@ -1220,6 +1250,13 @@ void ServerHello::Process(input_buffer&, SSL& ssl)
|
||||
if (ssl.isTLS() && server_version_.minor_ < 1)
|
||||
// downgrade to SSLv3
|
||||
ssl.useSecurity().use_connection().TurnOffTLS();
|
||||
else if (ssl.isTLSv1_1() && server_version_.minor_ == 1)
|
||||
// downdrage to TLSv1
|
||||
ssl.useSecurity().use_connection().TurnOffTLS1_1();
|
||||
}
|
||||
else if (ssl.isTLSv1_1() && server_version_.minor_ < 2) {
|
||||
ssl.SetError(badVersion_error);
|
||||
return;
|
||||
}
|
||||
else if (ssl.isTLS() && server_version_.minor_ < 1) {
|
||||
ssl.SetError(badVersion_error);
|
||||
@ -1252,6 +1289,10 @@ void ServerHello::Process(input_buffer&, SSL& ssl)
|
||||
ssl.useSecurity().set_resuming(false);
|
||||
ssl.useLog().Trace("server denied resumption");
|
||||
}
|
||||
|
||||
if (ssl.CompressionOn() && !compression_method_)
|
||||
ssl.UnSetCompression(); // server isn't supporting yaSSL zlib request
|
||||
|
||||
ssl.useStates().useClient() = serverHelloComplete;
|
||||
}
|
||||
|
||||
@ -1263,8 +1304,9 @@ ServerHello::ServerHello()
|
||||
}
|
||||
|
||||
|
||||
ServerHello::ServerHello(ProtocolVersion pv)
|
||||
: server_version_(pv)
|
||||
ServerHello::ServerHello(ProtocolVersion pv, bool useCompression)
|
||||
: server_version_(pv),
|
||||
compression_method_(useCompression ? zlib : no_compression)
|
||||
{
|
||||
memset(random_, 0, RAN_LEN);
|
||||
memset(session_id_, 0, ID_LEN);
|
||||
@ -1341,6 +1383,8 @@ opaque* ClientKeyBase::get_clientKey() const
|
||||
// input operator for Client Hello
|
||||
input_buffer& operator>>(input_buffer& input, ClientHello& hello)
|
||||
{
|
||||
uint begin = input.get_current(); // could have extensions at end
|
||||
|
||||
// Protocol
|
||||
hello.client_version_.major_ = input[AUTO];
|
||||
hello.client_version_.minor_ = input[AUTO];
|
||||
@ -1361,8 +1405,19 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello)
|
||||
|
||||
// Compression
|
||||
hello.comp_len_ = input[AUTO];
|
||||
while (hello.comp_len_--) // ignore for now
|
||||
hello.compression_methods_ = CompressionMethod(input[AUTO]);
|
||||
hello.compression_methods_ = no_compression;
|
||||
while (hello.comp_len_--) {
|
||||
CompressionMethod cm = CompressionMethod(input[AUTO]);
|
||||
if (cm == zlib)
|
||||
hello.compression_methods_ = zlib;
|
||||
}
|
||||
|
||||
uint read = input.get_current() - begin;
|
||||
uint expected = hello.get_length();
|
||||
|
||||
// ignore client hello extensions for now
|
||||
if (read < expected)
|
||||
input.set_current(input.get_current() + expected - read);
|
||||
|
||||
return input;
|
||||
}
|
||||
@ -1400,6 +1455,13 @@ output_buffer& operator<<(output_buffer& output, const ClientHello& hello)
|
||||
// Client Hello processing handler
|
||||
void ClientHello::Process(input_buffer&, SSL& ssl)
|
||||
{
|
||||
// store version for pre master secret
|
||||
ssl.useSecurity().use_connection().chVersion_ = client_version_;
|
||||
|
||||
if (client_version_.major_ != 3) {
|
||||
ssl.SetError(badVersion_error);
|
||||
return;
|
||||
}
|
||||
if (ssl.GetMultiProtocol()) { // SSLv23 support
|
||||
if (ssl.isTLS() && client_version_.minor_ < 1) {
|
||||
// downgrade to SSLv3
|
||||
@ -1407,20 +1469,29 @@ void ClientHello::Process(input_buffer&, SSL& ssl)
|
||||
ProtocolVersion pv = ssl.getSecurity().get_connection().version_;
|
||||
ssl.useSecurity().use_parms().SetSuites(pv); // reset w/ SSL suites
|
||||
}
|
||||
else if (ssl.isTLSv1_1() && client_version_.minor_ == 1)
|
||||
// downgrade to TLSv1, but use same suites
|
||||
ssl.useSecurity().use_connection().TurnOffTLS1_1();
|
||||
}
|
||||
else if (ssl.isTLSv1_1() && client_version_.minor_ < 2) {
|
||||
ssl.SetError(badVersion_error);
|
||||
return;
|
||||
}
|
||||
else if (ssl.isTLS() && client_version_.minor_ < 1) {
|
||||
ssl.SetError(badVersion_error);
|
||||
return;
|
||||
}
|
||||
else if (!ssl.isTLS() && (client_version_.major_ == 3 &&
|
||||
client_version_.minor_ >= 1)) {
|
||||
else if (!ssl.isTLS() && client_version_.minor_ >= 1) {
|
||||
ssl.SetError(badVersion_error);
|
||||
return;
|
||||
}
|
||||
|
||||
ssl.set_random(random_, client_end);
|
||||
|
||||
while (id_len_) { // trying to resume
|
||||
SSL_SESSION* session = GetSessions().lookup(session_id_);
|
||||
SSL_SESSION* session = 0;
|
||||
if (!ssl.getSecurity().GetContext()->GetSessionCacheOff())
|
||||
session = GetSessions().lookup(session_id_);
|
||||
if (!session) {
|
||||
ssl.useLog().Trace("session lookup failed");
|
||||
break;
|
||||
@ -1444,6 +1515,9 @@ void ClientHello::Process(input_buffer&, SSL& ssl)
|
||||
ssl.matchSuite(cipher_suites_, suite_len_);
|
||||
ssl.set_pending(ssl.getSecurity().get_parms().suite_[1]);
|
||||
|
||||
if (compression_methods_ == zlib)
|
||||
ssl.SetCompression();
|
||||
|
||||
ssl.useStates().useServer() = clientHelloComplete;
|
||||
}
|
||||
|
||||
@ -1478,8 +1552,9 @@ ClientHello::ClientHello()
|
||||
}
|
||||
|
||||
|
||||
ClientHello::ClientHello(ProtocolVersion pv)
|
||||
: client_version_(pv)
|
||||
ClientHello::ClientHello(ProtocolVersion pv, bool useCompression)
|
||||
: client_version_(pv),
|
||||
compression_methods_(useCompression ? zlib : no_compression)
|
||||
{
|
||||
memset(random_, 0, RAN_LEN);
|
||||
}
|
||||
@ -1943,8 +2018,13 @@ void Finished::Process(input_buffer& input, SSL& ssl)
|
||||
int digestSz = ssl.getCrypto().get_digest().get_digestSize();
|
||||
input.read(mac, digestSz);
|
||||
|
||||
uint ivExtra = 0;
|
||||
if (ssl.getSecurity().get_parms().cipher_type_ == block)
|
||||
if (ssl.isTLSv1_1())
|
||||
ivExtra = ssl.getCrypto().get_cipher().get_blockSize();
|
||||
|
||||
opaque fill;
|
||||
int padSz = ssl.getSecurity().get_parms().encrypt_size_ -
|
||||
int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra -
|
||||
HANDSHAKE_HEADER - finishedSz - digestSz;
|
||||
for (int i = 0; i < padSz; i++)
|
||||
fill = input[AUTO];
|
||||
@ -2018,7 +2098,9 @@ void clean(volatile opaque* p, uint sz, RandomPool& ran)
|
||||
Connection::Connection(ProtocolVersion v, RandomPool& ran)
|
||||
: pre_master_secret_(0), sequence_number_(0), peer_sequence_number_(0),
|
||||
pre_secret_len_(0), send_server_key_(false), master_clean_(false),
|
||||
TLS_(v.major_ >= 3 && v.minor_ >= 1), version_(v), random_(ran)
|
||||
TLS_(v.major_ >= 3 && v.minor_ >= 1),
|
||||
TLSv1_1_(v.major_ >= 3 && v.minor_ >= 2), compression_(false),
|
||||
version_(v), random_(ran)
|
||||
{
|
||||
memset(sessionID_, 0, sizeof(sessionID_));
|
||||
}
|
||||
@ -2043,6 +2125,13 @@ void Connection::TurnOffTLS()
|
||||
}
|
||||
|
||||
|
||||
void Connection::TurnOffTLS1_1()
|
||||
{
|
||||
TLSv1_1_ = false;
|
||||
version_.minor_ = 1;
|
||||
}
|
||||
|
||||
|
||||
// wipeout master secret
|
||||
void Connection::CleanMaster()
|
||||
{
|
||||
|
@ -38,6 +38,11 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef YASSL_PURE_C
|
||||
|
||||
void* operator new(size_t sz, yaSSL::new_t)
|
||||
@ -727,6 +732,32 @@ void SSL::set_preMaster(const opaque* pre, uint sz)
|
||||
}
|
||||
|
||||
|
||||
// set yaSSL zlib type compression
|
||||
int SSL::SetCompression()
|
||||
{
|
||||
#ifdef HAVE_LIBZ
|
||||
secure_.use_connection().compression_ = true;
|
||||
return 0;
|
||||
#else
|
||||
return -1; // not built in
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// unset yaSSL zlib type compression
|
||||
void SSL::UnSetCompression()
|
||||
{
|
||||
secure_.use_connection().compression_ = false;
|
||||
}
|
||||
|
||||
|
||||
// is yaSSL zlib compression on
|
||||
bool SSL::CompressionOn() const
|
||||
{
|
||||
return secure_.get_connection().compression_;
|
||||
}
|
||||
|
||||
|
||||
// store master secret
|
||||
void SSL::set_masterSecret(const opaque* sec)
|
||||
{
|
||||
@ -1109,6 +1140,11 @@ void SSL::verifyState(const RecordLayerHeader& rlHeader)
|
||||
{
|
||||
if (GetError()) return;
|
||||
|
||||
if (rlHeader.version_.major_ != 3 || rlHeader.version_.minor_ > 2) {
|
||||
SetError(badVersion_error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (states_.getRecord() == recordNotReady ||
|
||||
(rlHeader.type_ == application_data && // data and handshake
|
||||
states_.getHandShake() != handShakeReady) ) // isn't complete yet
|
||||
@ -1247,6 +1283,9 @@ void SSL::matchSuite(const opaque* peer, uint length)
|
||||
|
||||
void SSL::set_session(SSL_SESSION* s)
|
||||
{
|
||||
if (getSecurity().GetContext()->GetSessionCacheOff())
|
||||
return;
|
||||
|
||||
if (s && GetSessions().lookup(s->GetID(), &secure_.use_resume())) {
|
||||
secure_.set_resuming(true);
|
||||
crypto_.use_certManager().setPeerX509(s->GetPeerX509());
|
||||
@ -1344,6 +1383,12 @@ bool SSL::isTLS() const
|
||||
}
|
||||
|
||||
|
||||
bool SSL::isTLSv1_1() const
|
||||
{
|
||||
return secure_.get_connection().TLSv1_1_;
|
||||
}
|
||||
|
||||
|
||||
void SSL::addData(input_buffer* data)
|
||||
{
|
||||
buffers_.useData().push_back(data);
|
||||
@ -1703,7 +1748,7 @@ bool SSL_METHOD::multipleProtocol() const
|
||||
|
||||
SSL_CTX::SSL_CTX(SSL_METHOD* meth)
|
||||
: method_(meth), certificate_(0), privateKey_(0), passwordCb_(0),
|
||||
userData_(0)
|
||||
userData_(0), sessionCacheOff_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -1784,12 +1829,24 @@ void* SSL_CTX::GetUserData() const
|
||||
}
|
||||
|
||||
|
||||
bool SSL_CTX::GetSessionCacheOff() const
|
||||
{
|
||||
return sessionCacheOff_;
|
||||
}
|
||||
|
||||
|
||||
void SSL_CTX::SetUserData(void* data)
|
||||
{
|
||||
userData_ = data;
|
||||
}
|
||||
|
||||
|
||||
void SSL_CTX::SetSessionCacheOff()
|
||||
{
|
||||
sessionCacheOff_ = true;
|
||||
}
|
||||
|
||||
|
||||
void SSL_CTX::setVerifyPeer()
|
||||
{
|
||||
method_->setVerifyPeer();
|
||||
@ -2312,9 +2369,110 @@ ASN1_STRING* StringHolder::GetString()
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
|
||||
void* myAlloc(void* /* opaque */, unsigned int item, unsigned int size)
|
||||
{
|
||||
return NEW_YS unsigned char[item * size];
|
||||
}
|
||||
|
||||
|
||||
void myFree(void* /* opaque */, void* memory)
|
||||
{
|
||||
unsigned char* ptr = static_cast<unsigned char*>(memory);
|
||||
yaSSL::ysArrayDelete(ptr);
|
||||
}
|
||||
|
||||
|
||||
// put size in front of compressed data
|
||||
int Compress(const byte* in, int sz, input_buffer& buffer)
|
||||
{
|
||||
byte tmp[LENGTH_SZ];
|
||||
z_stream c_stream; /* compression stream */
|
||||
|
||||
buffer.allocate(sz + sizeof(uint16) + COMPRESS_EXTRA);
|
||||
|
||||
c_stream.zalloc = myAlloc;
|
||||
c_stream.zfree = myFree;
|
||||
c_stream.opaque = (voidpf)0;
|
||||
|
||||
c_stream.next_in = const_cast<byte*>(in);
|
||||
c_stream.avail_in = sz;
|
||||
c_stream.next_out = buffer.get_buffer() + sizeof(tmp);
|
||||
c_stream.avail_out = buffer.get_capacity() - sizeof(tmp);
|
||||
|
||||
if (deflateInit(&c_stream, 8) != Z_OK) return -1;
|
||||
int err = deflate(&c_stream, Z_FINISH);
|
||||
deflateEnd(&c_stream);
|
||||
if (err != Z_OK && err != Z_STREAM_END) return -1;
|
||||
|
||||
c16toa(sz, tmp);
|
||||
memcpy(buffer.get_buffer(), tmp, sizeof(tmp));
|
||||
buffer.add_size(c_stream.total_out + sizeof(tmp));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// get uncompressed size in front
|
||||
int DeCompress(input_buffer& in, int sz, input_buffer& out)
|
||||
{
|
||||
byte tmp[LENGTH_SZ];
|
||||
|
||||
in.read(tmp, sizeof(tmp));
|
||||
|
||||
uint16 len;
|
||||
ato16(tmp, len);
|
||||
|
||||
out.allocate(len);
|
||||
|
||||
z_stream d_stream; /* decompression stream */
|
||||
|
||||
d_stream.zalloc = myAlloc;
|
||||
d_stream.zfree = myFree;
|
||||
d_stream.opaque = (voidpf)0;
|
||||
|
||||
d_stream.next_in = in.get_buffer() + in.get_current();
|
||||
d_stream.avail_in = sz - sizeof(tmp);
|
||||
d_stream.next_out = out.get_buffer();
|
||||
d_stream.avail_out = out.get_capacity();
|
||||
|
||||
if (inflateInit(&d_stream) != Z_OK) return -1;
|
||||
int err = inflate(&d_stream, Z_FINISH);
|
||||
inflateEnd(&d_stream);
|
||||
if (err != Z_OK && err != Z_STREAM_END) return -1;
|
||||
|
||||
out.add_size(d_stream.total_out);
|
||||
in.set_current(in.get_current() + sz - sizeof(tmp));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#else // LIBZ
|
||||
|
||||
// these versions should never get called
|
||||
int Compress(const byte* in, int sz, input_buffer& buffer)
|
||||
{
|
||||
assert(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int DeCompress(input_buffer& in, int sz, input_buffer& out)
|
||||
{
|
||||
assert(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#endif // LIBZ
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
extern "C" void yaSSL_CleanUp()
|
||||
{
|
||||
TaoCrypt::CleanUp();
|
||||
|
@ -1,4 +1,4 @@
|
||||
INCLUDES = -I../include -I../mySTL
|
||||
INCLUDES = -I$(srcdir)/../include -I$(srcdir)/../mySTL
|
||||
bin_PROGRAMS = benchmark
|
||||
benchmark_SOURCES = benchmark.cpp
|
||||
benchmark_LDADD = $(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la
|
||||
|
@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\include" /I "..\..\mySTL" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\include" /I "..\mySTL" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@ -65,7 +65,7 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
@ -1,7 +1,7 @@
|
||||
REM quick and dirty build file for testing different MSDEVs
|
||||
setlocal
|
||||
|
||||
set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2
|
||||
set myFLAGS= /I../include /I../mySTL /c /W3 /G6 /O2
|
||||
|
||||
cl %myFLAGS% benchmark.cpp
|
||||
|
||||
|
@ -34,6 +34,12 @@
|
||||
#include "modes.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_AES_ASM
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
@ -46,15 +52,14 @@ public:
|
||||
enum { BLOCK_SIZE = AES_BLOCK_SIZE };
|
||||
|
||||
AES(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(BLOCK_SIZE), dir_(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:
|
||||
CipherDir dir_;
|
||||
Mode mode_;
|
||||
|
||||
static const word32 rcon_[];
|
||||
|
||||
word32 rounds_;
|
||||
|
@ -75,7 +75,8 @@ public:
|
||||
typedef Integer Element;
|
||||
|
||||
AbstractRing() : AbstractGroup() {m_mg.m_pRing = this;}
|
||||
AbstractRing(const AbstractRing &source) {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;
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
ARC4() {}
|
||||
|
||||
void Process(byte*, const byte*, word32);
|
||||
void AsmProcess(byte*, const byte*, word32);
|
||||
void SetKey(const byte*, word32);
|
||||
private:
|
||||
byte x_;
|
||||
@ -55,6 +54,8 @@ private:
|
||||
|
||||
ARC4(const ARC4&); // hide copy
|
||||
const ARC4 operator=(const ARC4&); // and assign
|
||||
|
||||
void AsmProcess(byte*, const byte*, word32);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@ -34,7 +34,11 @@
|
||||
#include "misc.hpp"
|
||||
#include "block.hpp"
|
||||
#include "error.hpp"
|
||||
#include STL_LIST_FILE
|
||||
#ifdef USE_SYS_STL
|
||||
#include <list>
|
||||
#else
|
||||
#include "list.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
@ -34,7 +34,12 @@
|
||||
#include "misc.hpp"
|
||||
#include <string.h> // memcpy
|
||||
#include <stddef.h> // ptrdiff_t
|
||||
#include STL_ALGORITHM_FILE
|
||||
|
||||
#ifdef USE_SYS_STL
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include "algorithm.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
@ -32,12 +32,21 @@
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "modes.hpp"
|
||||
#include STL_ALGORITHM_FILE
|
||||
#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 };
|
||||
@ -49,15 +58,14 @@ public:
|
||||
enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 };
|
||||
|
||||
Blowfish(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
|
||||
: Mode_BASE(BLOCK_SIZE, DIR, MODE) {}
|
||||
|
||||
#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:
|
||||
CipherDir dir_;
|
||||
Mode mode_;
|
||||
|
||||
static const word32 p_init_[ROUNDS + 2];
|
||||
static const word32 s_init_[4 * 256];
|
||||
|
||||
|
@ -34,6 +34,12 @@
|
||||
#include "misc.hpp"
|
||||
#include "modes.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_DES_ASM
|
||||
#endif
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
@ -53,13 +59,9 @@ protected:
|
||||
class DES : public Mode_BASE, public BasicDES {
|
||||
public:
|
||||
DES(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(DES_BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
|
||||
: Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}
|
||||
|
||||
void Process(byte*, const byte*, word32);
|
||||
private:
|
||||
CipherDir dir_;
|
||||
Mode mode_;
|
||||
|
||||
void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
|
||||
|
||||
DES(const DES&); // hide copy
|
||||
@ -71,14 +73,10 @@ private:
|
||||
class DES_EDE2 : public Mode_BASE {
|
||||
public:
|
||||
DES_EDE2(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(DES_BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
|
||||
: Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}
|
||||
|
||||
void SetKey(const byte*, word32, CipherDir dir);
|
||||
void Process(byte*, const byte*, word32);
|
||||
private:
|
||||
CipherDir dir_;
|
||||
Mode mode_;
|
||||
|
||||
BasicDES des1_;
|
||||
BasicDES des2_;
|
||||
|
||||
@ -94,15 +92,14 @@ private:
|
||||
class DES_EDE3 : public Mode_BASE {
|
||||
public:
|
||||
DES_EDE3(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(DES_BLOCK_SIZE), dir_(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:
|
||||
CipherDir dir_;
|
||||
Mode mode_;
|
||||
|
||||
BasicDES des1_;
|
||||
BasicDES des2_;
|
||||
BasicDES des3_;
|
||||
|
@ -45,7 +45,11 @@
|
||||
#include "random.hpp"
|
||||
#include "file.hpp"
|
||||
#include <string.h>
|
||||
#include STL_ALGORITHM_FILE
|
||||
#ifdef USE_SYS_STL
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include "algorithm.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TAOCRYPT_X86ASM_AVAILABLE
|
||||
@ -67,7 +71,8 @@
|
||||
#endif
|
||||
|
||||
// SSE2 intrinsics work in GCC 3.3 or later
|
||||
#if defined(__SSE2__) && (__GNUC_MAJOR__ > 3 || __GNUC_MINOR__ > 2)
|
||||
#if defined(__SSE2__) && (__GNUC__ == 4 || __GNUC_MAJOR__ > 3 || \
|
||||
__GNUC_MINOR__ > 2)
|
||||
#define SSE2_INTRINSICS_AVAILABLE
|
||||
#endif
|
||||
|
||||
@ -106,7 +111,6 @@ namespace TaoCrypt {
|
||||
#endif
|
||||
};
|
||||
|
||||
template class TAOCRYPT_DLL AlignedAllocator<word>;
|
||||
typedef Block<word, AlignedAllocator<word> > AlignedWordBlock;
|
||||
#else
|
||||
typedef WordBlock AlignedWordBlock;
|
||||
|
@ -31,6 +31,11 @@
|
||||
|
||||
#include "hash.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_MD5_ASM
|
||||
#endif
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
@ -49,7 +54,9 @@ public:
|
||||
MD5(const MD5&);
|
||||
MD5& operator= (const MD5&);
|
||||
|
||||
#ifdef DO_MD5_ASM
|
||||
void Update(const byte*, word32);
|
||||
#endif
|
||||
|
||||
void Init();
|
||||
void Swap(MD5&);
|
||||
|
@ -151,6 +151,17 @@ void CleanUp();
|
||||
#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
|
||||
@ -200,17 +211,9 @@ void CleanUp();
|
||||
|
||||
#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_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_NAMESPACE mySTL
|
||||
#endif
|
||||
|
||||
|
@ -38,6 +38,7 @@ namespace TaoCrypt {
|
||||
enum Mode { ECB, CBC };
|
||||
|
||||
|
||||
|
||||
// BlockCipher abstraction
|
||||
template<CipherDir DIR, class T, Mode MODE>
|
||||
class BlockCipher {
|
||||
@ -63,14 +64,16 @@ class Mode_BASE : public virtual_base {
|
||||
public:
|
||||
enum { MaxBlockSz = 16 };
|
||||
|
||||
explicit Mode_BASE(int sz)
|
||||
explicit Mode_BASE(int sz, CipherDir dir, Mode mode)
|
||||
: blockSz_(sz), reg_(reinterpret_cast<byte*>(r_)),
|
||||
tmp_(reinterpret_cast<byte*>(t_))
|
||||
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_;
|
||||
@ -80,6 +83,9 @@ protected:
|
||||
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);
|
||||
@ -92,6 +98,18 @@ private:
|
||||
};
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -31,6 +31,11 @@
|
||||
|
||||
#include "hash.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_RIPEMD_ASM
|
||||
#endif
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
@ -49,7 +54,9 @@ public:
|
||||
RIPEMD160(const RIPEMD160&);
|
||||
RIPEMD160& operator= (const RIPEMD160&);
|
||||
|
||||
#ifdef DO_RIPEMD_ASM
|
||||
void Update(const byte*, word32);
|
||||
#endif
|
||||
void Init();
|
||||
void Swap(RIPEMD160&);
|
||||
private:
|
||||
|
@ -239,7 +239,8 @@ bool RSA_Encryptor<Pad>::SSL_Verify(const byte* message, word32 sz,
|
||||
const byte* sig)
|
||||
{
|
||||
ByteBlock plain(PK_Lengths(key_.GetModulus()).FixedMaxPlaintextLength());
|
||||
SSL_Decrypt(key_, sig, plain.get_buffer());
|
||||
if (SSL_Decrypt(key_, sig, plain.get_buffer()) != sz)
|
||||
return false; // not right justified or bad padding
|
||||
|
||||
if ( (memcmp(plain.get_buffer(), message, sz)) == 0)
|
||||
return true;
|
||||
|
@ -31,6 +31,11 @@
|
||||
|
||||
#include "hash.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_SHA_ASM
|
||||
#endif
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
@ -46,7 +51,9 @@ public:
|
||||
word32 getDigestSize() const { return DIGEST_SIZE; }
|
||||
word32 getPadSize() const { return PAD_SIZE; }
|
||||
|
||||
#ifdef DO_SHA_ASM
|
||||
void Update(const byte* data, word32 len);
|
||||
#endif
|
||||
void Init();
|
||||
|
||||
SHA(const SHA&);
|
||||
|
@ -32,12 +32,20 @@
|
||||
|
||||
#include "misc.hpp"
|
||||
#include "modes.hpp"
|
||||
#include STL_ALGORITHM_FILE
|
||||
#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_TWOFISH_ASM
|
||||
#endif
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
enum { TWOFISH_BLOCK_SIZE = 16 };
|
||||
@ -49,15 +57,14 @@ public:
|
||||
enum { BLOCK_SIZE = TWOFISH_BLOCK_SIZE };
|
||||
|
||||
Twofish(CipherDir DIR, Mode MODE)
|
||||
: Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {}
|
||||
: Mode_BASE(BLOCK_SIZE, DIR, MODE) {}
|
||||
|
||||
#ifdef DO_TWOFISH_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:
|
||||
CipherDir dir_;
|
||||
Mode mode_;
|
||||
|
||||
static const byte q_[2][256];
|
||||
static const word32 mds_[4][256];
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
INCLUDES = -I../include -I../mySTL
|
||||
INCLUDES = -I$(srcdir)/../include -I$(srcdir)/../mySTL
|
||||
|
||||
noinst_LTLIBRARIES = libtaocrypt.la
|
||||
|
||||
|
@ -34,33 +34,19 @@
|
||||
#include "aes.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_AES_ASM
|
||||
#endif
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
#if !defined(DO_AES_ASM)
|
||||
|
||||
// Generic Version
|
||||
void AES::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);
|
||||
}
|
||||
|
||||
#else
|
||||
#if defined(DO_AES_ASM)
|
||||
|
||||
// ia32 optimized version
|
||||
void AES::Process(byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
if (!isMMX) {
|
||||
Mode_BASE::Process(out, in, sz);
|
||||
return;
|
||||
}
|
||||
|
||||
word32 blocks = sz / BLOCK_SIZE;
|
||||
|
||||
if (mode_ == ECB)
|
||||
|
@ -29,7 +29,11 @@
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "algebra.hpp"
|
||||
#include STL_VECTOR_FILE
|
||||
#ifdef USE_SYS_STL
|
||||
#include <vector>
|
||||
#else
|
||||
#include "vector.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
@ -80,12 +80,18 @@ inline unsigned int MakeByte(word32& x, word32& y, byte* s)
|
||||
} // namespace
|
||||
|
||||
|
||||
#ifndef DO_ARC4_ASM
|
||||
|
||||
void ARC4::Process(byte* out, const byte* in, word32 length)
|
||||
{
|
||||
if (length == 0) return;
|
||||
|
||||
#ifdef DO_ARC4_ASM
|
||||
if (isMMX) {
|
||||
AsmProcess(out, in, length);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
byte *const s = state_;
|
||||
word32 x = x_;
|
||||
word32 y = y_;
|
||||
@ -100,13 +106,16 @@ void ARC4::Process(byte* out, const byte* in, word32 length)
|
||||
y_ = y;
|
||||
}
|
||||
|
||||
#else // DO_ARC4_ASM
|
||||
|
||||
|
||||
#ifdef DO_ARC4_ASM
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__declspec(naked)
|
||||
#else
|
||||
__attribute__ ((noinline))
|
||||
#endif
|
||||
void ARC4::Process(byte* out, const byte* in, word32 length)
|
||||
void ARC4::AsmProcess(byte* out, const byte* in, word32 length)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#define AS1(x) asm(#x);
|
||||
|
@ -37,34 +37,21 @@
|
||||
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_BLOWFISH_ASM
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
#if !defined(DO_BLOWFISH_ASM)
|
||||
|
||||
// Generic Version
|
||||
void Blowfish::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);
|
||||
}
|
||||
|
||||
#else
|
||||
#if defined(DO_BLOWFISH_ASM)
|
||||
|
||||
// ia32 optimized version
|
||||
void Blowfish::Process(byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
if (!isMMX) {
|
||||
Mode_BASE::Process(out, in, sz);
|
||||
return;
|
||||
}
|
||||
|
||||
word32 blocks = sz / BLOCK_SIZE;
|
||||
|
||||
if (mode_ == ECB)
|
||||
|
@ -34,16 +34,16 @@
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "des.hpp"
|
||||
#include STL_ALGORITHM_FILE
|
||||
#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_DES_ASM
|
||||
#endif
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
@ -357,18 +357,6 @@ void BasicDES::RawProcessBlock(word32& lIn, word32& rIn) const
|
||||
}
|
||||
|
||||
|
||||
void DES::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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef BlockGetAndPut<word32, BigEndian> Block;
|
||||
|
||||
@ -386,17 +374,6 @@ void DES::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out) const
|
||||
}
|
||||
|
||||
|
||||
void DES_EDE2::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);
|
||||
}
|
||||
|
||||
void DES_EDE2::SetKey(const byte* key, word32 sz, CipherDir dir)
|
||||
{
|
||||
des1_.SetKey(key, sz, dir);
|
||||
@ -429,25 +406,16 @@ void DES_EDE3::SetKey(const byte* key, word32 sz, CipherDir dir)
|
||||
|
||||
|
||||
|
||||
#if !defined(DO_DES_ASM)
|
||||
|
||||
// Generic Version
|
||||
void DES_EDE3::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);
|
||||
}
|
||||
|
||||
#else
|
||||
#if defined(DO_DES_ASM)
|
||||
|
||||
// ia32 optimized version
|
||||
void DES_EDE3::Process(byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
if (!isMMX) {
|
||||
Mode_BASE::Process(out, in, sz);
|
||||
return;
|
||||
}
|
||||
|
||||
word32 blocks = sz / DES_BLOCK_SIZE;
|
||||
|
||||
if (mode_ == CBC)
|
||||
|
@ -55,12 +55,15 @@ extern "C" word myUMULH(word, word);
|
||||
#pragma intrinsic (myUMULH)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SSE2_INTRINSICS_AVAILABLE
|
||||
#ifdef __GNUC__
|
||||
#include <xmmintrin.h>
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#ifdef TAOCRYPT_MEMALIGN_AVAILABLE
|
||||
#include <malloc.h>
|
||||
#else
|
||||
@ -1015,44 +1018,20 @@ void Portable::Multiply8Bottom(word *R, const word *A, const word *B)
|
||||
|
||||
// ************** x86 feature detection ***************
|
||||
|
||||
static bool s_sse2Enabled = true;
|
||||
|
||||
static void CpuId(word32 input, word32 *output)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
__asm__
|
||||
(
|
||||
// save ebx in case -fPIC is being used
|
||||
"push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx"
|
||||
: "=a" (output[0]), "=D" (output[1]), "=c" (output[2]), "=d"(output[3])
|
||||
: "a" (input)
|
||||
);
|
||||
#else
|
||||
__asm
|
||||
{
|
||||
mov eax, input
|
||||
cpuid
|
||||
mov edi, output
|
||||
mov [edi], eax
|
||||
mov [edi+4], ebx
|
||||
mov [edi+8], ecx
|
||||
mov [edi+12], edx
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SSE2_INTRINSICS_AVAILABLE
|
||||
|
||||
#ifndef _MSC_VER
|
||||
static jmp_buf s_env;
|
||||
static void SigIllHandler(int)
|
||||
{
|
||||
static jmp_buf s_env;
|
||||
static void SigIllHandler(int)
|
||||
{
|
||||
longjmp(s_env, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool HasSSE2()
|
||||
{
|
||||
if (!s_sse2Enabled)
|
||||
if (!IsPentium())
|
||||
return false;
|
||||
|
||||
word32 cpuid[4];
|
||||
@ -1081,23 +1060,22 @@ static bool HasSSE2()
|
||||
if (setjmp(s_env))
|
||||
result = false;
|
||||
else
|
||||
__asm __volatile ("xorps %xmm0, %xmm0");
|
||||
__asm __volatile ("xorpd %xmm0, %xmm0");
|
||||
|
||||
signal(SIGILL, oldHandler);
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif // SSE2_INTRINSICS_AVAILABLE
|
||||
|
||||
|
||||
static bool IsP4()
|
||||
{
|
||||
word32 cpuid[4];
|
||||
|
||||
CpuId(0, cpuid);
|
||||
STL::swap(cpuid[2], cpuid[3]);
|
||||
if (memcmp(cpuid+1, "GenuineIntel", 12) != 0)
|
||||
if (!IsPentium())
|
||||
return false;
|
||||
|
||||
word32 cpuid[4];
|
||||
|
||||
CpuId(1, cpuid);
|
||||
return ((cpuid[0] >> 8) & 0xf) == 0xf;
|
||||
}
|
||||
@ -1147,7 +1125,12 @@ static PMul s_pMul4, s_pMul8, s_pMul8B;
|
||||
|
||||
static void SetPentiumFunctionPointers()
|
||||
{
|
||||
if (IsP4())
|
||||
if (!IsPentium())
|
||||
{
|
||||
s_pAdd = &Portable::Add;
|
||||
s_pSub = &Portable::Subtract;
|
||||
}
|
||||
else if (IsP4())
|
||||
{
|
||||
s_pAdd = &P4Optimized::Add;
|
||||
s_pSub = &P4Optimized::Subtract;
|
||||
@ -1159,7 +1142,13 @@ static void SetPentiumFunctionPointers()
|
||||
}
|
||||
|
||||
#ifdef SSE2_INTRINSICS_AVAILABLE
|
||||
if (HasSSE2())
|
||||
if (!IsPentium())
|
||||
{
|
||||
s_pMul4 = &Portable::Multiply4;
|
||||
s_pMul8 = &Portable::Multiply8;
|
||||
s_pMul8B = &Portable::Multiply8Bottom;
|
||||
}
|
||||
else if (HasSSE2())
|
||||
{
|
||||
s_pMul4 = &P4Optimized::Multiply4;
|
||||
s_pMul8 = &P4Optimized::Multiply8;
|
||||
@ -1177,11 +1166,6 @@ static void SetPentiumFunctionPointers()
|
||||
static const char s_RunAtStartupSetPentiumFunctionPointers =
|
||||
(SetPentiumFunctionPointers(), 0);
|
||||
|
||||
void DisableSSE2()
|
||||
{
|
||||
s_sse2Enabled = false;
|
||||
SetPentiumFunctionPointers();
|
||||
}
|
||||
|
||||
class LowLevel : public PentiumOptimized
|
||||
{
|
||||
@ -3984,6 +3968,9 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq,
|
||||
template hword DivideThreeWordsByTwo<hword, Word>(hword*, hword, hword, Word*);
|
||||
#endif
|
||||
template word DivideThreeWordsByTwo<word, DWord>(word*, word, word, DWord*);
|
||||
#ifdef SSE2_INTRINSICS_AVAILABLE
|
||||
template class AlignedAllocator<word>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
REM quick and dirty build file for testing different MSDEVs
|
||||
setlocal
|
||||
|
||||
set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2
|
||||
set myFLAGS= /I../include /I../mySTL /c /W3 /G6 /O2
|
||||
|
||||
cl %myFLAGS% aes.cpp
|
||||
cl %myFLAGS% aestables.cpp
|
||||
@ -21,6 +21,7 @@ cl %myFLAGS% file.cpp
|
||||
cl %myFLAGS% hash.cpp
|
||||
cl %myFLAGS% integer.cpp
|
||||
cl %myFLAGS% md2.cpp
|
||||
cl %myFLAGS% md4.cpp
|
||||
cl %myFLAGS% md5.cpp
|
||||
|
||||
cl %myFLAGS% misc.cpp
|
||||
@ -33,5 +34,5 @@ cl %myFLAGS% template_instnt.cpp
|
||||
cl %myFLAGS% tftables.cpp
|
||||
cl %myFLAGS% twofish.cpp
|
||||
|
||||
link.exe -lib /out:taocrypt.lib aes.obj aestables.obj algebra.obj arc4.obj asn.obj bftables.obj blowfish.obj coding.obj des.obj dh.obj dsa.obj file.obj hash.obj integer.obj md2.obj md5.obj misc.obj random.obj ripemd.obj rsa.obj sha.obj template_instnt.obj tftables.obj twofish.obj
|
||||
link.exe -lib /out:taocrypt.lib aes.obj aestables.obj algebra.obj arc4.obj asn.obj bftables.obj blowfish.obj coding.obj des.obj dh.obj dsa.obj file.obj hash.obj integer.obj md2.obj md4.obj md5.obj misc.obj random.obj ripemd.obj rsa.obj sha.obj template_instnt.obj tftables.obj twofish.obj
|
||||
|
||||
|
@ -28,7 +28,11 @@
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "md4.hpp"
|
||||
#include STL_ALGORITHM_FILE
|
||||
#ifdef USE_SYS_STL
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include "algorithm.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
@ -28,15 +28,16 @@
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "md5.hpp"
|
||||
#include STL_ALGORITHM_FILE
|
||||
#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_MD5_ASM
|
||||
#endif
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
@ -84,10 +85,17 @@ void MD5::Swap(MD5& other)
|
||||
}
|
||||
|
||||
|
||||
// Update digest with data of size len, do in blocks
|
||||
#ifdef DO_MD5_ASM
|
||||
|
||||
// Update digest with data of size len
|
||||
void MD5::Update(const byte* data, word32 len)
|
||||
{
|
||||
byte* local = (byte*)buffer_;
|
||||
if (!isMMX) {
|
||||
HASHwithTransform::Update(data, len);
|
||||
return;
|
||||
}
|
||||
|
||||
byte* local = reinterpret_cast<byte*>(buffer_);
|
||||
|
||||
// remove buffered data if possible
|
||||
if (buffLen_) {
|
||||
@ -99,27 +107,14 @@ void MD5::Update(const byte* data, word32 len)
|
||||
len -= add;
|
||||
|
||||
if (buffLen_ == BLOCK_SIZE) {
|
||||
ByteReverseIf(local, local, BLOCK_SIZE, LittleEndianOrder);
|
||||
Transform();
|
||||
AddLength(BLOCK_SIZE);
|
||||
buffLen_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// do block size transforms or all at once for asm
|
||||
// at once for asm
|
||||
if (buffLen_ == 0) {
|
||||
#ifndef DO_MD5_ASM
|
||||
while (len >= BLOCK_SIZE) {
|
||||
memcpy(&local[0], data, BLOCK_SIZE);
|
||||
|
||||
data += BLOCK_SIZE;
|
||||
len -= BLOCK_SIZE;
|
||||
|
||||
ByteReverseIf(local, local, BLOCK_SIZE, LittleEndianOrder);
|
||||
Transform();
|
||||
AddLength(BLOCK_SIZE);
|
||||
}
|
||||
#else
|
||||
word32 times = len / BLOCK_SIZE;
|
||||
if (times) {
|
||||
AsmTransform(data, times);
|
||||
@ -128,7 +123,6 @@ void MD5::Update(const byte* data, word32 len)
|
||||
len -= add;
|
||||
data += add;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// cache any data left
|
||||
@ -139,7 +133,6 @@ void MD5::Update(const byte* data, word32 len)
|
||||
}
|
||||
|
||||
|
||||
#ifdef DO_MD5_ASM
|
||||
|
||||
|
||||
/*
|
||||
|
@ -30,6 +30,20 @@
|
||||
#include "misc.hpp"
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_SYS_STL
|
||||
#include <algorithm>
|
||||
#else
|
||||
#include "algorithm.hpp"
|
||||
#endif
|
||||
|
||||
namespace STL = STL_NAMESPACE;
|
||||
|
||||
|
||||
#ifdef YASSL_PURE_C
|
||||
|
||||
void* operator new(size_t sz, TaoCrypt::new_t)
|
||||
@ -156,5 +170,129 @@ unsigned long Crop(unsigned long value, unsigned int size)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef TAOCRYPT_X86ASM_AVAILABLE
|
||||
|
||||
#ifndef _MSC_VER
|
||||
static jmp_buf s_env;
|
||||
static void SigIllHandler(int)
|
||||
{
|
||||
longjmp(s_env, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool HaveCpuId()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
__try
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, 0
|
||||
cpuid
|
||||
}
|
||||
}
|
||||
__except (1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
typedef void (*SigHandler)(int);
|
||||
|
||||
SigHandler oldHandler = signal(SIGILL, SigIllHandler);
|
||||
if (oldHandler == SIG_ERR)
|
||||
return false;
|
||||
|
||||
bool result = true;
|
||||
if (setjmp(s_env))
|
||||
result = false;
|
||||
else
|
||||
__asm__ __volatile
|
||||
(
|
||||
// save ebx in case -fPIC is being used
|
||||
"push %%ebx; mov $0, %%eax; cpuid; pop %%ebx"
|
||||
:
|
||||
:
|
||||
: "%eax", "%ecx", "%edx"
|
||||
);
|
||||
|
||||
signal(SIGILL, oldHandler);
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void CpuId(word32 input, word32 *output)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
__asm__
|
||||
(
|
||||
// save ebx in case -fPIC is being used
|
||||
"push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx"
|
||||
: "=a" (output[0]), "=D" (output[1]), "=c" (output[2]), "=d"(output[3])
|
||||
: "a" (input)
|
||||
);
|
||||
#else
|
||||
__asm
|
||||
{
|
||||
mov eax, input
|
||||
cpuid
|
||||
mov edi, output
|
||||
mov [edi], eax
|
||||
mov [edi+4], ebx
|
||||
mov [edi+8], ecx
|
||||
mov [edi+12], edx
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool IsPentium()
|
||||
{
|
||||
if (!HaveCpuId())
|
||||
return false;
|
||||
|
||||
word32 cpuid[4];
|
||||
|
||||
CpuId(0, cpuid);
|
||||
STL::swap(cpuid[2], cpuid[3]);
|
||||
if (memcmp(cpuid+1, "GenuineIntel", 12) != 0)
|
||||
return false;
|
||||
|
||||
CpuId(1, cpuid);
|
||||
byte family = ((cpuid[0] >> 8) & 0xf);
|
||||
if (family < 5)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool IsMmx()
|
||||
{
|
||||
if (!IsPentium())
|
||||
return false;
|
||||
|
||||
word32 cpuid[4];
|
||||
|
||||
CpuId(1, cpuid);
|
||||
if ((cpuid[3] & (1 << 23)) == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool isMMX = IsMmx();
|
||||
|
||||
|
||||
#endif // TAOCRYPT_X86ASM_AVAILABLE
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -50,8 +50,11 @@ namespace TaoCrypt {
|
||||
RandomNumberGenerator::RandomNumberGenerator()
|
||||
{
|
||||
byte key[32];
|
||||
byte junk[256];
|
||||
|
||||
seed_.GenerateSeed(key, sizeof(key));
|
||||
cipher_.SetKey(key, sizeof(key));
|
||||
GenerateBlock(junk, sizeof(junk)); // rid initial state
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,15 +28,16 @@
|
||||
|
||||
#include "runtime.hpp"
|
||||
#include "ripemd.hpp"
|
||||
#include STL_ALGORITHM_FILE
|
||||
#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_RIPEMD_ASM
|
||||
#endif
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
@ -86,10 +87,17 @@ void RIPEMD160::Swap(RIPEMD160& other)
|
||||
}
|
||||
|
||||
|
||||
// Update digest with data of size len, do in blocks
|
||||
#ifdef DO_RIPEMD_ASM
|
||||
|
||||
// Update digest with data of size len
|
||||
void RIPEMD160::Update(const byte* data, word32 len)
|
||||
{
|
||||
byte* local = (byte*)buffer_;
|
||||
if (!isMMX) {
|
||||
HASHwithTransform::Update(data, len);
|
||||
return;
|
||||
}
|
||||
|
||||
byte* local = reinterpret_cast<byte*>(buffer_);
|
||||
|
||||
// remove buffered data if possible
|
||||
if (buffLen_) {
|
||||
@ -101,27 +109,14 @@ void RIPEMD160::Update(const byte* data, word32 len)
|
||||
len -= add;
|
||||
|
||||
if (buffLen_ == BLOCK_SIZE) {
|
||||
ByteReverseIf(local, local, BLOCK_SIZE, LittleEndianOrder);
|
||||
Transform();
|
||||
AddLength(BLOCK_SIZE);
|
||||
buffLen_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// do block size transforms or all at once for asm
|
||||
// all at once for asm
|
||||
if (buffLen_ == 0) {
|
||||
#ifndef DO_RIPEMD_ASM
|
||||
while (len >= BLOCK_SIZE) {
|
||||
memcpy(&local[0], data, BLOCK_SIZE);
|
||||
|
||||
data += BLOCK_SIZE;
|
||||
len -= BLOCK_SIZE;
|
||||
|
||||
ByteReverseIf(local, local, BLOCK_SIZE, LittleEndianOrder);
|
||||
Transform();
|
||||
AddLength(BLOCK_SIZE);
|
||||
}
|
||||
#else
|
||||
word32 times = len / BLOCK_SIZE;
|
||||
if (times) {
|
||||
AsmTransform(data, times);
|
||||
@ -130,7 +125,6 @@ void RIPEMD160::Update(const byte* data, word32 len)
|
||||
len -= add;
|
||||
data += add;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// cache any data left
|
||||
@ -140,6 +134,8 @@ void RIPEMD160::Update(const byte* data, word32 len)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DO_RIPEMD_ASM
|
||||
|
||||
|
||||
// for all
|
||||
#define F(x, y, z) (x ^ y ^ z)
|
||||
|
@ -28,16 +28,16 @@
|
||||
#include "runtime.hpp"
|
||||
#include <string.h>
|
||||
#include "sha.hpp"
|
||||
#include STL_ALGORITHM_FILE
|
||||
#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_SHA_ASM
|
||||
#endif
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
@ -108,10 +108,18 @@ void SHA::Swap(SHA& other)
|
||||
}
|
||||
|
||||
|
||||
// Update digest with data of size len, do in blocks
|
||||
|
||||
#ifdef DO_SHA_ASM
|
||||
|
||||
// Update digest with data of size len
|
||||
void SHA::Update(const byte* data, word32 len)
|
||||
{
|
||||
byte* local = (byte*)buffer_;
|
||||
if (!isMMX) {
|
||||
HASHwithTransform::Update(data, len);
|
||||
return;
|
||||
}
|
||||
|
||||
byte* local = reinterpret_cast<byte*>(buffer_);
|
||||
|
||||
// remove buffered data if possible
|
||||
if (buffLen_) {
|
||||
@ -123,27 +131,15 @@ void SHA::Update(const byte* data, word32 len)
|
||||
len -= add;
|
||||
|
||||
if (buffLen_ == BLOCK_SIZE) {
|
||||
ByteReverseIf(local, local, BLOCK_SIZE, BigEndianOrder);
|
||||
ByteReverse(local, local, BLOCK_SIZE);
|
||||
Transform();
|
||||
AddLength(BLOCK_SIZE);
|
||||
buffLen_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// do block size transforms or all at once for asm
|
||||
// all at once for asm
|
||||
if (buffLen_ == 0) {
|
||||
#ifndef DO_SHA_ASM
|
||||
while (len >= BLOCK_SIZE) {
|
||||
memcpy(&local[0], data, BLOCK_SIZE);
|
||||
|
||||
data += BLOCK_SIZE;
|
||||
len -= BLOCK_SIZE;
|
||||
|
||||
ByteReverseIf(local, local, BLOCK_SIZE, BigEndianOrder);
|
||||
Transform();
|
||||
AddLength(BLOCK_SIZE);
|
||||
}
|
||||
#else
|
||||
word32 times = len / BLOCK_SIZE;
|
||||
if (times) {
|
||||
AsmTransform(data, times);
|
||||
@ -152,7 +148,6 @@ void SHA::Update(const byte* data, word32 len)
|
||||
len -= add;
|
||||
data += add;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// cache any data left
|
||||
@ -162,6 +157,8 @@ void SHA::Update(const byte* data, word32 len)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DO_SHA_ASM
|
||||
|
||||
|
||||
void SHA::Transform()
|
||||
{
|
||||
|
@ -35,33 +35,20 @@
|
||||
#include "twofish.hpp"
|
||||
|
||||
|
||||
#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
|
||||
#define DO_TWOFISH_ASM
|
||||
#endif
|
||||
|
||||
|
||||
namespace TaoCrypt {
|
||||
|
||||
|
||||
#if !defined(DO_TWOFISH_ASM)
|
||||
|
||||
// Generic Version
|
||||
void Twofish::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);
|
||||
}
|
||||
|
||||
#else
|
||||
#if defined(DO_TWOFISH_ASM)
|
||||
|
||||
// ia32 optimized version
|
||||
void Twofish::Process(byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
if (!isMMX) {
|
||||
Mode_BASE::Process(out, in, sz);
|
||||
return;
|
||||
}
|
||||
|
||||
word32 blocks = sz / BLOCK_SIZE;
|
||||
|
||||
if (mode_ == ECB)
|
||||
|
@ -41,7 +41,7 @@ RSC=rc.exe
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /G6 /MT /W3 /O2 /I "include" /I "..\mySTL" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /G6 /MT /W3 /O2 /I "include" /I "mySTL" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@ -64,7 +64,7 @@ LIB32=link.exe -lib
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "include" /I "..\mySTL" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "include" /I "mySTL" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# SUBTRACT CPP /Fr
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
|
@ -21,7 +21,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="include,..\mySTL"
|
||||
AdditionalIncludeDirectories="include,mySTL"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
ExceptionHandling="FALSE"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -75,7 +75,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="include,..\mySTL"
|
||||
AdditionalIncludeDirectories="include,mySTL"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
ExceptionHandling="FALSE"
|
||||
|
@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /O2 /I "include" /I "../mySTL" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /O2 /I "include" /I "mySTL" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@ -66,7 +66,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "include" /I "../mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "include" /I "mySTL" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
@ -1,4 +1,4 @@
|
||||
INCLUDES = -I../include -I../mySTL
|
||||
INCLUDES = -I$(srcdir)/../include -I$(srcdir)/../mySTL
|
||||
bin_PROGRAMS = test
|
||||
test_SOURCES = test.cpp
|
||||
test_LDADD = $(top_builddir)/extra/yassl/taocrypt/src/libtaocrypt.la
|
||||
|
@ -1,7 +1,7 @@
|
||||
REM quick and dirty build file for testing different MSDEVs
|
||||
setlocal
|
||||
|
||||
set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2
|
||||
set myFLAGS= /I../include /I../mySTL /c /W3 /G6 /O2
|
||||
|
||||
cl %myFLAGS% test.cpp
|
||||
|
||||
|
@ -247,6 +247,8 @@ void taocrypt_test(void* args)
|
||||
args.argv = argv;
|
||||
|
||||
taocrypt_test(&args);
|
||||
TaoCrypt::CleanUp();
|
||||
|
||||
return args.return_code;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user