Commit 97817fb5 authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Merge tag 'upstream/5.5.53' into ubuntu-14.04

Upstream version 5.5.53
parents fa322efd ad9e6670
commit: 0da39caceea7733a94d898427d63ba2670160af4 commit: eac8d95ffcdea7cd31d60d273e30cb3dfec66add
date: 2016-09-12 16:42:05 +0200 date: 2016-10-14 12:51:53 +0200
build-date: 2016-09-12 16:54:58 +0200 build-date: 2016-10-14 12:55:57 +0200
short: 0da39ca short: eac8d95
branch: HEAD branch: HEAD
MySQL source 5.5.52 MySQL source 5.5.53
MYSQL_VERSION_MAJOR=5 MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5 MYSQL_VERSION_MINOR=5
MYSQL_VERSION_PATCH=52 MYSQL_VERSION_PATCH=53
MYSQL_VERSION_EXTRA= MYSQL_VERSION_EXTRA=
...@@ -245,7 +245,8 @@ static void end_pager(); ...@@ -245,7 +245,8 @@ static void end_pager();
static void init_tee(const char *); static void init_tee(const char *);
static void end_tee(); static void end_tee();
static const char* construct_prompt(); static const char* construct_prompt();
static char *get_arg(char *line, my_bool get_next_arg); enum get_arg_mode { CHECK, GET, GET_NEXT};
static char *get_arg(char *line, get_arg_mode mode);
static void init_username(); static void init_username();
static void add_int_to_prompt(int toadd); static void add_int_to_prompt(int toadd);
static int get_result_width(MYSQL_RES *res); static int get_result_width(MYSQL_RES *res);
...@@ -2223,7 +2224,7 @@ static COMMANDS *find_command(char *name) ...@@ -2223,7 +2224,7 @@ static COMMANDS *find_command(char *name)
if (!my_strnncoll(&my_charset_latin1, (uchar*) name, len, if (!my_strnncoll(&my_charset_latin1, (uchar*) name, len,
(uchar*) commands[i].name, len) && (uchar*) commands[i].name, len) &&
(commands[i].name[len] == '\0') && (commands[i].name[len] == '\0') &&
(!end || commands[i].takes_params)) (!end || (commands[i].takes_params && get_arg(name, CHECK))))
{ {
index= i; index= i;
break; break;
...@@ -3143,7 +3144,7 @@ com_charset(String *buffer __attribute__((unused)), char *line) ...@@ -3143,7 +3144,7 @@ com_charset(String *buffer __attribute__((unused)), char *line)
char buff[256], *param; char buff[256], *param;
CHARSET_INFO * new_cs; CHARSET_INFO * new_cs;
strmake_buf(buff, line); strmake_buf(buff, line);
param= get_arg(buff, 0); param= get_arg(buff, GET);
if (!param || !*param) if (!param || !*param)
{ {
return put_info("Usage: \\C charset_name | charset charset_name", return put_info("Usage: \\C charset_name | charset charset_name",
...@@ -4228,12 +4229,12 @@ com_connect(String *buffer, char *line) ...@@ -4228,12 +4229,12 @@ com_connect(String *buffer, char *line)
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
tmp[1]= 0; tmp[1]= 0;
#endif #endif
tmp= get_arg(buff, 0); tmp= get_arg(buff, GET);
if (tmp && *tmp) if (tmp && *tmp)
{ {
my_free(current_db); my_free(current_db);
current_db= my_strdup(tmp, MYF(MY_WME)); current_db= my_strdup(tmp, MYF(MY_WME));
tmp= get_arg(buff, 1); tmp= get_arg(buff, GET_NEXT);
if (tmp) if (tmp)
{ {
my_free(current_host); my_free(current_host);
...@@ -4336,7 +4337,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line) ...@@ -4336,7 +4337,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line)
char buff[256], *tmp; char buff[256], *tmp;
strmake_buf(buff, line); strmake_buf(buff, line);
tmp= get_arg(buff, 0); tmp= get_arg(buff, GET);
if (!tmp || !*tmp) if (!tmp || !*tmp)
{ {
...@@ -4367,7 +4368,7 @@ com_use(String *buffer __attribute__((unused)), char *line) ...@@ -4367,7 +4368,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
bzero(buff, sizeof(buff)); bzero(buff, sizeof(buff));
strmake_buf(buff, line); strmake_buf(buff, line);
tmp= get_arg(buff, 0); tmp= get_arg(buff, GET);
if (!tmp || !*tmp) if (!tmp || !*tmp)
{ {
put_info("USE must be followed by a database name", INFO_ERROR); put_info("USE must be followed by a database name", INFO_ERROR);
...@@ -4452,23 +4453,22 @@ com_nowarnings(String *buffer __attribute__((unused)), ...@@ -4452,23 +4453,22 @@ com_nowarnings(String *buffer __attribute__((unused)),
} }
/* /*
Gets argument from a command on the command line. If get_next_arg is Gets argument from a command on the command line. If mode is not GET_NEXT,
not defined, skips the command and returns the first argument. The skips the command and returns the first argument. The line is modified by
line is modified by adding zero to the end of the argument. If adding zero to the end of the argument. If mode is GET_NEXT, then the
get_next_arg is defined, then the function searches for end of string function searches for end of string first, after found, returns the next
first, after found, returns the next argument and adds zero to the argument and adds zero to the end. If you ever wish to use this feature,
end. If you ever wish to use this feature, remember to initialize all remember to initialize all items in the array to zero first.
items in the array to zero first.
*/ */
char *get_arg(char *line, my_bool get_next_arg) static char *get_arg(char *line, get_arg_mode mode)
{ {
char *ptr, *start; char *ptr, *start;
my_bool quoted= 0, valid_arg= 0; bool short_cmd= false;
char qtype= 0; char qtype= 0;
ptr= line; ptr= line;
if (get_next_arg) if (mode == GET_NEXT)
{ {
for (; *ptr; ptr++) ; for (; *ptr; ptr++) ;
if (*(ptr + 1)) if (*(ptr + 1))
...@@ -4479,7 +4479,7 @@ char *get_arg(char *line, my_bool get_next_arg) ...@@ -4479,7 +4479,7 @@ char *get_arg(char *line, my_bool get_next_arg)
/* skip leading white spaces */ /* skip leading white spaces */
while (my_isspace(charset_info, *ptr)) while (my_isspace(charset_info, *ptr))
ptr++; ptr++;
if (*ptr == '\\') // short command was used if ((short_cmd= *ptr == '\\')) // short command was used
ptr+= 2; ptr+= 2;
else else
while (*ptr &&!my_isspace(charset_info, *ptr)) // skip command while (*ptr &&!my_isspace(charset_info, *ptr)) // skip command
...@@ -4492,24 +4492,28 @@ char *get_arg(char *line, my_bool get_next_arg) ...@@ -4492,24 +4492,28 @@ char *get_arg(char *line, my_bool get_next_arg)
if (*ptr == '\'' || *ptr == '\"' || *ptr == '`') if (*ptr == '\'' || *ptr == '\"' || *ptr == '`')
{ {
qtype= *ptr; qtype= *ptr;
quoted= 1;
ptr++; ptr++;
} }
for (start=ptr ; *ptr; ptr++) for (start=ptr ; *ptr; ptr++)
{ {
if (*ptr == '\\' && ptr[1]) // escaped character if ((*ptr == '\\' && ptr[1]) || // escaped character
(!short_cmd && qtype && *ptr == qtype && ptr[1] == qtype)) // quote
{ {
// Remove the backslash // Remove (or skip) the backslash (or a second quote)
if (mode != CHECK)
strmov_overlapp(ptr, ptr+1); strmov_overlapp(ptr, ptr+1);
else
ptr++;
} }
else if ((!quoted && *ptr == ' ') || (quoted && *ptr == qtype)) else if (*ptr == (qtype ? qtype : ' '))
{ {
qtype= 0;
if (mode != CHECK)
*ptr= 0; *ptr= 0;
break; break;
} }
} }
valid_arg= ptr != start; return ptr != start && !qtype ? start : NullS;
return valid_arg ? start : NullS;
} }
......
...@@ -547,9 +547,7 @@ static int dump_all_tablespaces(); ...@@ -547,9 +547,7 @@ static int dump_all_tablespaces();
static int dump_tablespaces_for_tables(char *db, char **table_names, int tables); static int dump_tablespaces_for_tables(char *db, char **table_names, int tables);
static int dump_tablespaces_for_databases(char** databases); static int dump_tablespaces_for_databases(char** databases);
static int dump_tablespaces(char* ts_where); static int dump_tablespaces(char* ts_where);
static void print_comment(FILE *sql_file, my_bool is_error, const char *format, static void print_comment(FILE *, my_bool, const char *, ...);
...);
/* /*
Print the supplied message if in verbose mode Print the supplied message if in verbose mode
...@@ -627,6 +625,30 @@ static void short_usage(FILE *f) ...@@ -627,6 +625,30 @@ static void short_usage(FILE *f)
} }
/** returns a string fixed to be safely printed inside a -- comment
that is, any new line in it gets prefixed with --
*/
static const char *fix_for_comment(const char *ident)
{
static char buf[1024];
char c, *s= buf;
while ((c= *s++= *ident++))
{
if (s >= buf + sizeof(buf) - 10)
{
strmov(s, "...");
break;
}
if (c == '\n')
s= strmov(s, "-- ");
}
return buf;
}
static void write_header(FILE *sql_file, char *db_name) static void write_header(FILE *sql_file, char *db_name)
{ {
if (opt_xml) if (opt_xml)
...@@ -649,8 +671,8 @@ static void write_header(FILE *sql_file, char *db_name) ...@@ -649,8 +671,8 @@ static void write_header(FILE *sql_file, char *db_name)
DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE, DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE,
MACHINE_TYPE); MACHINE_TYPE);
print_comment(sql_file, 0, "-- Host: %s Database: %s\n", print_comment(sql_file, 0, "-- Host: %s Database: %s\n",
current_host ? current_host : "localhost", fix_for_comment(current_host ? current_host : "localhost"),
db_name ? db_name : ""); fix_for_comment(db_name ? db_name : ""));
print_comment(sql_file, 0, print_comment(sql_file, 0,
"-- ------------------------------------------------------\n" "-- ------------------------------------------------------\n"
); );
...@@ -2094,7 +2116,8 @@ static uint dump_events_for_db(char *db) ...@@ -2094,7 +2116,8 @@ static uint dump_events_for_db(char *db)
/* nice comments */ /* nice comments */
print_comment(sql_file, 0, print_comment(sql_file, 0,
"\n--\n-- Dumping events for database '%s'\n--\n", db); "\n--\n-- Dumping events for database '%s'\n--\n",
fix_for_comment(db));
/* /*
not using "mysql_query_with_error_report" because we may have not not using "mysql_query_with_error_report" because we may have not
...@@ -2307,7 +2330,8 @@ static uint dump_routines_for_db(char *db) ...@@ -2307,7 +2330,8 @@ static uint dump_routines_for_db(char *db)
/* nice comments */ /* nice comments */
print_comment(sql_file, 0, print_comment(sql_file, 0,
"\n--\n-- Dumping routines for database '%s'\n--\n", db); "\n--\n-- Dumping routines for database '%s'\n--\n",
fix_for_comment(db));
/* /*
not using "mysql_query_with_error_report" because we may have not not using "mysql_query_with_error_report" because we may have not
...@@ -2580,11 +2604,11 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2580,11 +2604,11 @@ static uint get_table_structure(char *table, char *db, char *table_type,
if (strcmp (table_type, "VIEW") == 0) /* view */ if (strcmp (table_type, "VIEW") == 0) /* view */
print_comment(sql_file, 0, print_comment(sql_file, 0,
"\n--\n-- Temporary table structure for view %s\n--\n\n", "\n--\n-- Temporary table structure for view %s\n--\n\n",
result_table); fix_for_comment(result_table));
else else
print_comment(sql_file, 0, print_comment(sql_file, 0,
"\n--\n-- Table structure for table %s\n--\n\n", "\n--\n-- Table structure for table %s\n--\n\n",
result_table); fix_for_comment(result_table));
if (opt_drop) if (opt_drop)
{ {
...@@ -2826,7 +2850,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2826,7 +2850,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
print_comment(sql_file, 0, print_comment(sql_file, 0,
"\n--\n-- Table structure for table %s\n--\n\n", "\n--\n-- Table structure for table %s\n--\n\n",
result_table); fix_for_comment(result_table));
if (opt_drop) if (opt_drop)
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", result_table); fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", result_table);
if (!opt_xml) if (!opt_xml)
...@@ -3530,21 +3554,21 @@ static void dump_table(char *table, char *db) ...@@ -3530,21 +3554,21 @@ static void dump_table(char *table, char *db)
{ {
print_comment(md_result_file, 0, print_comment(md_result_file, 0,
"\n--\n-- Dumping data for table %s\n--\n", "\n--\n-- Dumping data for table %s\n--\n",
result_table); fix_for_comment(result_table));
dynstr_append_checked(&query_string, "SELECT /*!40001 SQL_NO_CACHE */ * FROM "); dynstr_append_checked(&query_string, "SELECT /*!40001 SQL_NO_CACHE */ * FROM ");
dynstr_append_checked(&query_string, result_table); dynstr_append_checked(&query_string, result_table);
if (where) if (where)
{ {
print_comment(md_result_file, 0, "-- WHERE: %s\n", where); print_comment(md_result_file, 0, "-- WHERE: %s\n", fix_for_comment(where));
dynstr_append_checked(&query_string, " WHERE "); dynstr_append_checked(&query_string, " WHERE ");
dynstr_append_checked(&query_string, where); dynstr_append_checked(&query_string, where);
} }
if (order_by) if (order_by)
{ {
print_comment(md_result_file, 0, "-- ORDER BY: %s\n", order_by); print_comment(md_result_file, 0, "-- ORDER BY: %s\n", fix_for_comment(order_by));
dynstr_append_checked(&query_string, " ORDER BY "); dynstr_append_checked(&query_string, " ORDER BY ");
dynstr_append_checked(&query_string, order_by); dynstr_append_checked(&query_string, order_by);
...@@ -4053,7 +4077,7 @@ static int dump_tablespaces(char* ts_where) ...@@ -4053,7 +4077,7 @@ static int dump_tablespaces(char* ts_where)
if (first) if (first)
{ {
print_comment(md_result_file, 0, "\n--\n-- Logfile group: %s\n--\n", print_comment(md_result_file, 0, "\n--\n-- Logfile group: %s\n--\n",
row[0]); fix_for_comment(row[0]));
fprintf(md_result_file, "\nCREATE"); fprintf(md_result_file, "\nCREATE");
} }
...@@ -4122,7 +4146,8 @@ static int dump_tablespaces(char* ts_where) ...@@ -4122,7 +4146,8 @@ static int dump_tablespaces(char* ts_where)
first= 1; first= 1;
if (first) if (first)
{ {
print_comment(md_result_file, 0, "\n--\n-- Tablespace: %s\n--\n", row[0]); print_comment(md_result_file, 0, "\n--\n-- Tablespace: %s\n--\n",
fix_for_comment(row[0]));
fprintf(md_result_file, "\nCREATE"); fprintf(md_result_file, "\nCREATE");
} }
else else
...@@ -4326,7 +4351,8 @@ static int init_dumping(char *database, int init_func(char*)) ...@@ -4326,7 +4351,8 @@ static int init_dumping(char *database, int init_func(char*))
char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted); char *qdatabase= quote_name(database,quoted_database_buf,opt_quoted);
print_comment(md_result_file, 0, print_comment(md_result_file, 0,
"\n--\n-- Current Database: %s\n--\n", qdatabase); "\n--\n-- Current Database: %s\n--\n",
fix_for_comment(qdatabase));
/* Call the view or table specific function */ /* Call the view or table specific function */
init_func(qdatabase); init_func(qdatabase);
...@@ -5356,7 +5382,7 @@ static my_bool get_view_structure(char *table, char* db) ...@@ -5356,7 +5382,7 @@ static my_bool get_view_structure(char *table, char* db)
print_comment(sql_file, 0, print_comment(sql_file, 0,
"\n--\n-- Final view structure for view %s\n--\n\n", "\n--\n-- Final view structure for view %s\n--\n\n",
result_table); fix_for_comment(result_table));
/* Table might not exist if this view was dumped with --tab. */ /* Table might not exist if this view was dumped with --tab. */
fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table); fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table);
......
...@@ -3349,10 +3349,6 @@ void do_exec(struct st_command *command) ...@@ -3349,10 +3349,6 @@ void do_exec(struct st_command *command)
#endif #endif
#endif #endif
/* exec command is interpreted externally and will not take newlines */
while(replace(&ds_cmd, "\n", 1, " ", 1) == 0)
;
DBUG_PRINT("info", ("Executing '%s' as '%s'", DBUG_PRINT("info", ("Executing '%s' as '%s'",
command->first_argument, ds_cmd.str)); command->first_argument, ds_cmd.str));
......
...@@ -12,6 +12,24 @@ before calling SSL_new(); ...@@ -12,6 +12,24 @@ before calling SSL_new();
*** end Note *** *** end Note ***
yaSSL Release notes, version 2.4.2 (9/22/2016)
This release of yaSSL fixes a medium security vulnerability. A fix for
potential AES side channel leaks is included that a local user monitoring
the same CPU core cache could exploit. VM users, hyper-threading users,
and users where potential attackers have access to the CPU cache will need
to update if they utilize AES.
DSA padding fixes for unusual sizes is included as well. Users with DSA
certficiates should update.
yaSSL Release notes, version 2.4.0 (5/20/2016)
This release of yaSSL fixes the OpenSSL compatibility function
SSL_CTX_load_verify_locations() when using the path directory to allow
unlimited path sizes. Minor Windows build fixes are included.
No high level security fixes in this version but we always recommend
updating.
yaSSL Release notes, version 2.3.9b (2/03/2016) yaSSL Release notes, version 2.3.9b (2/03/2016)
This release of yaSSL fixes the OpenSSL compatibility function This release of yaSSL fixes the OpenSSL compatibility function
X509_NAME_get_index_by_NID() to use the actual index of the common name X509_NAME_get_index_by_NID() to use the actual index of the common name
......
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIDqzCCA2ugAwIBAgIJAMGqrgDU6DyhMAkGByqGSM44BAMwgY4xCzAJBgNVBAYT MIIDrzCCA2+gAwIBAgIJAK1zRM7YFcNjMAkGByqGSM44BAMwgZAxCzAJBgNVBAYT
AlVTMQ8wDQYDVQQIDAZPcmVnb24xETAPBgNVBAcMCFBvcnRsYW5kMRAwDgYDVQQK AlVTMQ8wDQYDVQQIDAZ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TBAUwAwEB/zAJBgcqhkjOOAQDAy8AMCwCFCjGKIdOSV12LcTu SwbV5Ufb/IHHMAwGA1UdEwQFMAMBAf8wCQYHKoZIzjgEAwMvADAsAhQRYSCVN/Ge
k08owGM6YkO1AhQe+K173VuaO/OsDNsxZlKpyH8+1g== agV3mffU3qNZ92fI0QIUPH7Jp+iASI7U1ocaYDc10qXGaGY=
-----END CERTIFICATE----- -----END CERTIFICATE-----
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "rsa.h" #include "rsa.h"
#define YASSL_VERSION "2.3.9b" #define YASSL_VERSION "2.4.2"
#if defined(__cplusplus) #if defined(__cplusplus)
......
...@@ -161,7 +161,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) ...@@ -161,7 +161,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type)
TaoCrypt::DSA_PrivateKey dsaKey; TaoCrypt::DSA_PrivateKey dsaKey;
dsaKey.Initialize(dsaSource); dsaKey.Initialize(dsaSource);
if (rsaSource.GetError().What()) { if (dsaSource.GetError().What()) {
// neither worked // neither worked
ret = SSL_FAILURE; ret = SSL_FAILURE;
} }
...@@ -784,40 +784,67 @@ int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file, ...@@ -784,40 +784,67 @@ int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file,
WIN32_FIND_DATA FindFileData; WIN32_FIND_DATA FindFileData;
HANDLE hFind; HANDLE hFind;
char name[MAX_PATH + 1]; // directory specification const int DELIMITER_SZ = 2;
strncpy(name, path, MAX_PATH - 3); const int DELIMITER_STAR_SZ = 3;
strncat(name, "\\*", 3); int pathSz = (int)strlen(path);
int nameSz = pathSz + DELIMITER_STAR_SZ + 1; // plus 1 for terminator
char* name = NEW_YS char[nameSz]; // directory specification
memset(name, 0, nameSz);
strncpy(name, path, nameSz - DELIMITER_STAR_SZ - 1);
strncat(name, "\\*", DELIMITER_STAR_SZ);
hFind = FindFirstFile(name, &FindFileData); hFind = FindFirstFile(name, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) return SSL_BAD_PATH; if (hFind == INVALID_HANDLE_VALUE) {
ysArrayDelete(name);
return SSL_BAD_PATH;
}
do { do {
if (FindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) { if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
strncpy(name, path, MAX_PATH - 2 - HALF_PATH); int curSz = (int)strlen(FindFileData.cFileName);
strncat(name, "\\", 2); if (pathSz + curSz + DELIMITER_SZ + 1 > nameSz) {
strncat(name, FindFileData.cFileName, HALF_PATH); ysArrayDelete(name);
// plus 1 for terminator
nameSz = pathSz + curSz + DELIMITER_SZ + 1;
name = NEW_YS char[nameSz];
}
memset(name, 0, nameSz);
strncpy(name, path, nameSz - curSz - DELIMITER_SZ - 1);
strncat(name, "\\", DELIMITER_SZ);
strncat(name, FindFileData.cFileName,
nameSz - pathSz - DELIMITER_SZ - 1);
ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA); ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);
} }
} while (ret == SSL_SUCCESS && FindNextFile(hFind, &FindFileData)); } while (ret == SSL_SUCCESS && FindNextFile(hFind, &FindFileData));
ysArrayDelete(name);
FindClose(hFind); FindClose(hFind);
#else // _WIN32 #else // _WIN32
const int MAX_PATH = 260;
DIR* dir = opendir(path); DIR* dir = opendir(path);
if (!dir) return SSL_BAD_PATH; if (!dir) return SSL_BAD_PATH;
struct dirent* entry; struct dirent* entry;
struct stat buf; struct stat buf;
char name[MAX_PATH + 1]; const int DELIMITER_SZ = 1;
int pathSz = (int)strlen(path);
int nameSz = pathSz + DELIMITER_SZ + 1; //plus 1 for null terminator
char* name = NEW_YS char[nameSz]; // directory specification
while (ret == SSL_SUCCESS && (entry = readdir(dir))) { while (ret == SSL_SUCCESS && (entry = readdir(dir))) {
strncpy(name, path, MAX_PATH - 1 - HALF_PATH); int curSz = (int)strlen(entry->d_name);
strncat(name, "/", 1); if (pathSz + curSz + DELIMITER_SZ + 1 > nameSz) {
strncat(name, entry->d_name, HALF_PATH); ysArrayDelete(name);
nameSz = pathSz + DELIMITER_SZ + curSz + 1;
name = NEW_YS char[nameSz];
}
memset(name, 0, nameSz);
strncpy(name, path, nameSz - curSz - 1);
strncat(name, "/", DELIMITER_SZ);
strncat(name, entry->d_name, nameSz - pathSz - DELIMITER_SZ - 1);
if (stat(name, &buf) < 0) { if (stat(name, &buf) < 0) {
ysArrayDelete(name);
closedir(dir); closedir(dir);
return SSL_BAD_STAT; return SSL_BAD_STAT;
} }
...@@ -826,6 +853,7 @@ int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file, ...@@ -826,6 +853,7 @@ int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file,
ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA); ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);
} }
ysArrayDelete(name);
closedir(dir); closedir(dir);
#endif #endif
......
...@@ -60,6 +60,7 @@ private: ...@@ -60,6 +60,7 @@ private:
static const word32 Te[5][256]; static const word32 Te[5][256];
static const word32 Td[5][256]; static const word32 Td[5][256];
static const byte CTd4[256];
static const word32* Te0; static const word32* Te0;
static const word32* Te1; static const word32* Te1;
...@@ -80,11 +81,68 @@ private: ...@@ -80,11 +81,68 @@ private:
void ProcessAndXorBlock(const byte*, const byte*, byte*) const; void ProcessAndXorBlock(const byte*, const byte*, byte*) const;
word32 PreFetchTe() const;
word32 PreFetchTd() const;
word32 PreFetchCTd4() const;
AES(const AES&); // hide copy AES(const AES&); // hide copy
AES& operator=(const AES&); // and assign AES& operator=(const AES&); // and assign
}; };
#if defined(__x86_64__) || defined(_M_X64) || \
(defined(__ILP32__) && (__ILP32__ >= 1))
#define TC_CACHE_LINE_SZ 64
#else
/* default cache line size */
#define TC_CACHE_LINE_SZ 32
#endif
inline word32 AES::PreFetchTe() const
{
word32 x = 0;
/* 4 tables of 256 entries */
for (int i = 0; i < 4; i++) {
/* each entry is 4 bytes */
for (int j = 0; j < 256; j += TC_CACHE_LINE_SZ/4) {
x &= Te[i][j];
}
}
return x;
}
inline word32 AES::PreFetchTd() const
{
word32 x = 0;
/* 4 tables of 256 entries */
for (int i = 0; i < 4; i++) {
/* each entry is 4 bytes */
for (int j = 0; j < 256; j += TC_CACHE_LINE_SZ/4) {
x &= Td[i][j];
}
}
return x;
}
inline word32 AES::PreFetchCTd4() const
{
word32 x = 0;
int i;
for (i = 0; i < 256; i += TC_CACHE_LINE_SZ) {
x &= CTd4[i];
}
return x;
}
typedef BlockCipher<ENCRYPTION, AES, ECB> AES_ECB_Encryption; typedef BlockCipher<ENCRYPTION, AES, ECB> AES_ECB_Encryption;
typedef BlockCipher<DECRYPTION, AES, ECB> AES_ECB_Decryption; typedef BlockCipher<DECRYPTION, AES, ECB> AES_ECB_Decryption;
......
...@@ -119,6 +119,9 @@ namespace TaoCrypt { ...@@ -119,6 +119,9 @@ namespace TaoCrypt {
#ifdef _WIN32
#undef max // avoid name clash
#endif
// general MAX // general MAX
template<typename T> inline template<typename T> inline
const T& max(const T& a, const T& b) const T& max(const T& a, const T& b)
......
...@@ -109,10 +109,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) ...@@ -109,10 +109,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
{ {
temp = rk[3]; temp = rk[3];
rk[4] = rk[0] ^ rk[4] = rk[0] ^
(Te4[GETBYTE(temp, 2)] & 0xff000000) ^ (Te2[GETBYTE(temp, 2)] & 0xff000000) ^
(Te4[GETBYTE(temp, 1)] & 0x00ff0000) ^ (Te3[GETBYTE(temp, 1)] & 0x00ff0000) ^
(Te4[GETBYTE(temp, 0)] & 0x0000ff00) ^ (Te0[GETBYTE(temp, 0)] & 0x0000ff00) ^
(Te4[GETBYTE(temp, 3)] & 0x000000ff) ^ (Te1[GETBYTE(temp, 3)] & 0x000000ff) ^
rcon_[i]; rcon_[i];
rk[5] = rk[1] ^ rk[4]; rk[5] = rk[1] ^ rk[4];
rk[6] = rk[2] ^ rk[5]; rk[6] = rk[2] ^ rk[5];
...@@ -128,10 +128,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) ...@@ -128,10 +128,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
{ {
temp = rk[ 5]; temp = rk[ 5];
rk[ 6] = rk[ 0] ^ rk[ 6] = rk[ 0] ^
(Te4[GETBYTE(temp, 2)] & 0xff000000) ^ (Te2[GETBYTE(temp, 2)] & 0xff000000) ^
(Te4[GETBYTE(temp, 1)] & 0x00ff0000) ^ (Te3[GETBYTE(temp, 1)] & 0x00ff0000) ^
(Te4[GETBYTE(temp, 0)] & 0x0000ff00) ^ (Te0[GETBYTE(temp, 0)] & 0x0000ff00) ^
(Te4[GETBYTE(temp, 3)] & 0x000000ff) ^ (Te1[GETBYTE(temp, 3)] & 0x000000ff) ^
rcon_[i]; rcon_[i];
rk[ 7] = rk[ 1] ^ rk[ 6]; rk[ 7] = rk[ 1] ^ rk[ 6];
rk[ 8] = rk[ 2] ^ rk[ 7]; rk[ 8] = rk[ 2] ^ rk[ 7];
...@@ -149,10 +149,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) ...@@ -149,10 +149,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
{ {
temp = rk[ 7]; temp = rk[ 7];
rk[ 8] = rk[ 0] ^ rk[ 8] = rk[ 0] ^
(Te4[GETBYTE(temp, 2)] & 0xff000000) ^ (Te2[GETBYTE(temp, 2)] & 0xff000000) ^
(Te4[GETBYTE(temp, 1)] & 0x00ff0000) ^ (Te3[GETBYTE(temp, 1)] & 0x00ff0000) ^
(Te4[GETBYTE(temp, 0)] & 0x0000ff00) ^ (Te0[GETBYTE(temp, 0)] & 0x0000ff00) ^
(Te4[GETBYTE(temp, 3)] & 0x000000ff) ^ (Te1[GETBYTE(temp, 3)] & 0x000000ff) ^
rcon_[i]; rcon_[i];
rk[ 9] = rk[ 1] ^ rk[ 8]; rk[ 9] = rk[ 1] ^ rk[ 8];
rk[10] = rk[ 2] ^ rk[ 9]; rk[10] = rk[ 2] ^ rk[ 9];
...@@ -161,10 +161,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) ...@@ -161,10 +161,10 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
break; break;
temp = rk[11]; temp = rk[11];
rk[12] = rk[ 4] ^ rk[12] = rk[ 4] ^
(Te4[GETBYTE(temp, 3)] & 0xff000000) ^ (Te2[GETBYTE(temp, 3)] & 0xff000000) ^
(Te4[GETBYTE(temp, 2)] & 0x00ff0000) ^ (Te3[GETBYTE(temp, 2)] & 0x00ff0000) ^
(Te4[GETBYTE(temp, 1)] & 0x0000ff00) ^ (Te0[GETBYTE(temp, 1)] & 0x0000ff00) ^
(Te4[GETBYTE(temp, 0)] & 0x000000ff); (Te1[GETBYTE(temp, 0)] & 0x000000ff);
rk[13] = rk[ 5] ^ rk[12]; rk[13] = rk[ 5] ^ rk[12];
rk[14] = rk[ 6] ^ rk[13]; rk[14] = rk[ 6] ^ rk[13];
rk[15] = rk[ 7] ^ rk[14]; rk[15] = rk[ 7] ^ rk[14];
...@@ -191,25 +191,25 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/) ...@@ -191,25 +191,25 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
for (i = 1; i < rounds_; i++) { for (i = 1; i < rounds_; i++) {
rk += 4; rk += 4;
rk[0] = rk[0] =
Td0[Te4[GETBYTE(rk[0], 3)] & 0xff] ^ Td0[Te1[GETBYTE(rk[0], 3)] & 0xff] ^
Td1[Te4[GETBYTE(rk[0], 2)] & 0xff] ^ Td1[Te1[GETBYTE(rk[0], 2)] & 0xff] ^
Td2[Te4[GETBYTE(rk[0], 1)] & 0xff] ^ Td2[Te1[GETBYTE(rk[0], 1)] & 0xff] ^
Td3[Te4[GETBYTE(rk[0], 0)] & 0xff]; Td3[Te1[GETBYTE(rk[0], 0)] & 0xff];
rk[1] = rk[1] =
Td0[Te4[GETBYTE(rk[1], 3)] & 0xff] ^ Td0[Te1[GETBYTE(rk[1], 3)] & 0xff] ^
Td1[Te4[GETBYTE(rk[1], 2)] & 0xff] ^ Td1[Te1[GETBYTE(rk[1], 2)] & 0xff] ^
Td2[Te4[GETBYTE(rk[1], 1)] & 0xff] ^ Td2[Te1[GETBYTE(rk[1], 1)] & 0xff] ^
Td3[Te4[GETBYTE(rk[1], 0)] & 0xff]; Td3[Te1[GETBYTE(rk[1], 0)] & 0xff];
rk[2] = rk[2] =
Td0[Te4[GETBYTE(rk[2], 3)] & 0xff] ^ Td0[Te1[GETBYTE(rk[2], 3)] & 0xff] ^
Td1[Te4[GETBYTE(rk[2], 2)] & 0xff] ^ Td1[Te1[GETBYTE(rk[2], 2)] & 0xff] ^
Td2[Te4[GETBYTE(rk[2], 1)] & 0xff] ^ Td2[Te1[GETBYTE(rk[2], 1)] & 0xff] ^
Td3[Te4[GETBYTE(rk[2], 0)] & 0xff]; Td3[Te1[GETBYTE(rk[2], 0)] & 0xff];
rk[3] = rk[3] =
Td0[Te4[GETBYTE(rk[3], 3)] & 0xff] ^ Td0[Te1[GETBYTE(rk[3], 3)] & 0xff] ^
Td1[Te4[GETBYTE(rk[3], 2)] & 0xff] ^ Td1[Te1[GETBYTE(rk[3], 2)] & 0xff] ^
Td2[Te4[GETBYTE(rk[3], 1)] & 0xff] ^ Td2[Te1[GETBYTE(rk[3], 1)] & 0xff] ^
Td3[Te4[GETBYTE(rk[3], 0)] & 0xff]; Td3[Te1[GETBYTE(rk[3], 0)] & 0xff];
} }
} }
} }
...@@ -244,6 +244,7 @@ void AES::encrypt(const byte* inBlock, const byte* xorBlock, ...@@ -244,6 +244,7 @@ void AES::encrypt(const byte* inBlock, const byte* xorBlock,
s2 ^= rk[2]; s2 ^= rk[2];
s3 ^= rk[3]; s3 ^= rk[3];
s0 |= PreFetchTe();
/* /*
* Nr - 1 full rounds: * Nr - 1 full rounds:
*/ */
...@@ -312,28 +313,28 @@ void AES::encrypt(const byte* inBlock, const byte* xorBlock, ...@@ -312,28 +313,28 @@ void AES::encrypt(const byte* inBlock, const byte* xorBlock,
*/ */
s0 = s0 =
(Te4[GETBYTE(t0, 3)] & 0xff000000) ^ (Te2[GETBYTE(t0, 3)] & 0xff000000) ^
(Te4[GETBYTE(t1, 2)] & 0x00ff0000) ^ (Te3[GETBYTE(t1, 2)] & 0x00ff0000) ^
(Te4[GETBYTE(t2, 1)] & 0x0000ff00) ^ (Te0[GETBYTE(t2, 1)] & 0x0000ff00) ^
(Te4[GETBYTE(t3, 0)] & 0x000000ff) ^ (Te1[GETBYTE(t3, 0)] & 0x000000ff) ^
rk[0]; rk[0];
s1 = s1 =
(Te4[GETBYTE(t1, 3)] & 0xff000000) ^ (Te2[GETBYTE(t1, 3)] & 0xff000000) ^
(Te4[GETBYTE(t2, 2)] & 0x00ff0000) ^ (Te3[GETBYTE(t2, 2)] & 0x00ff0000) ^
(Te4[GETBYTE(t3, 1)] & 0x0000ff00) ^ (Te0[GETBYTE(t3, 1)] & 0x0000ff00) ^
(Te4[GETBYTE(t0, 0)] & 0x000000ff) ^ (Te1[GETBYTE(t0, 0)] & 0x000000ff) ^
rk[1]; rk[1];
s2 = s2 =
(Te4[GETBYTE(t2, 3)] & 0xff000000) ^ (Te2[GETBYTE(t2, 3)] & 0xff000000) ^
(Te4[GETBYTE(t3, 2)] & 0x00ff0000) ^ (Te3[GETBYTE(t3, 2)] & 0x00ff0000) ^
(Te4[GETBYTE(t0, 1)] & 0x0000ff00) ^ (Te0[GETBYTE(t0, 1)] & 0x0000ff00) ^
(Te4[GETBYTE(t1, 0)] & 0x000000ff) ^ (Te1[GETBYTE(t1, 0)] & 0x000000ff) ^
rk[2]; rk[2];
s3 = s3 =
(Te4[GETBYTE(t3, 3)] & 0xff000000) ^ (Te2[GETBYTE(t3, 3)] & 0xff000000) ^
(Te4[GETBYTE(t0, 2)] & 0x00ff0000) ^ (Te3[GETBYTE(t0, 2)] & 0x00ff0000) ^
(Te4[GETBYTE(t1, 1)] & 0x0000ff00) ^ (Te0[GETBYTE(t1, 1)] & 0x0000ff00) ^
(Te4[GETBYTE(t2, 0)] & 0x000000ff) ^ (Te1[GETBYTE(t2, 0)] & 0x000000ff) ^
rk[3]; rk[3];
...@@ -358,6 +359,8 @@ void AES::decrypt(const byte* inBlock, const byte* xorBlock, ...@@ -358,6 +359,8 @@ void AES::decrypt(const byte* inBlock, const byte* xorBlock,
s2 ^= rk[2]; s2 ^= rk[2];
s3 ^= rk[3]; s3 ^= rk[3];
s0 |= PreFetchTd();
/* /*
* Nr - 1 full rounds: * Nr - 1 full rounds:
*/ */
...@@ -423,29 +426,32 @@ void AES::decrypt(const byte* inBlock, const byte* xorBlock, ...@@ -423,29 +426,32 @@ void AES::decrypt(const byte* inBlock, const byte* xorBlock,
* apply last round and * apply last round and
* map cipher state to byte array block: * map cipher state to byte array block:
*/ */
t0 |= PreFetchCTd4();
s0 = s0 =
(Td4[GETBYTE(t0, 3)] & 0xff000000) ^ ((word32)CTd4[GETBYTE(t0, 3)] << 24) ^
(Td4[GETBYTE(t3, 2)] & 0x00ff0000) ^ ((word32)CTd4[GETBYTE(t3, 2)] << 16) ^
(Td4[GETBYTE(t2, 1)] & 0x0000ff00) ^ ((word32)CTd4[GETBYTE(t2, 1)] << 8) ^
(Td4[GETBYTE(t1, 0)] & 0x000000ff) ^ ((word32)CTd4[GETBYTE(t1, 0)]) ^
rk[0]; rk[0];
s1 = s1 =
(Td4[GETBYTE(t1, 3)] & 0xff000000) ^ ((word32)CTd4[GETBYTE(t1, 3)] << 24) ^
(Td4[GETBYTE(t0, 2)] & 0x00ff0000) ^ ((word32)CTd4[GETBYTE(t0, 2)] << 16) ^
(Td4[GETBYTE(t3, 1)] & 0x0000ff00) ^ ((word32)CTd4[GETBYTE(t3, 1)] << 8) ^
(Td4[GETBYTE(t2, 0)] & 0x000000ff) ^ ((word32)CTd4[GETBYTE(t2, 0)]) ^
rk[1]; rk[1];
s2 = s2 =
(Td4[GETBYTE(t2, 3)] & 0xff000000) ^ ((word32)CTd4[GETBYTE(t2, 3)] << 24 ) ^
(Td4[GETBYTE(t1, 2)] & 0x00ff0000) ^ ((word32)CTd4[GETBYTE(t1, 2)] << 16 ) ^
(Td4[GETBYTE(t0, 1)] & 0x0000ff00) ^ ((word32)CTd4[GETBYTE(t0, 1)] << 8 ) ^
(Td4[GETBYTE(t3, 0)] & 0x000000ff) ^ ((word32)CTd4[GETBYTE(t3, 0)]) ^
rk[2]; rk[2];
s3 = s3 =
(Td4[GETBYTE(t3, 3)] & 0xff000000) ^ ((word32)CTd4[GETBYTE(t3, 3)] << 24) ^
(Td4[GETBYTE(t2, 2)] & 0x00ff0000) ^ ((word32)CTd4[GETBYTE(t2, 2)] << 16) ^
(Td4[GETBYTE(t1, 1)] & 0x0000ff00) ^ ((word32)CTd4[GETBYTE(t1, 1)] << 8) ^
(Td4[GETBYTE(t0, 0)] & 0x000000ff) ^ ((word32)CTd4[GETBYTE(t0, 0)]) ^
rk[3]; rk[3];
gpBlock::Put(xorBlock, outBlock)(s0)(s1)(s2)(s3); gpBlock::Put(xorBlock, outBlock)(s0)(s1)(s2)(s3);
...@@ -1826,18 +1832,52 @@ const word32 AES::Td[5][256] = { ...@@ -1826,18 +1832,52 @@ const word32 AES::Td[5][256] = {
} }
}; };
const byte AES::CTd4[256] =
{
0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U,
0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU,
0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U,
0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU,
0x54U, 0x7bU, 0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0x5aU, 0xf4U,
0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U,
0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU,
0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU,
0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU,
0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U,
0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U,
0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U,
0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU,
};
const word32* AES::Te0 = AES::Te[0]; const word32* AES::Te0 = AES::Te[0];
const word32* AES::Te1 = AES::Te[1]; const word32* AES::Te1 = AES::Te[1];
const word32* AES::Te2 = AES::Te[2]; const word32* AES::Te2 = AES::Te[2];
const word32* AES::Te3 = AES::Te[3]; const word32* AES::Te3 = AES::Te[3];
const word32* AES::Te4 = AES::Te[4];
const word32* AES::Td0 = AES::Td[0]; const word32* AES::Td0 = AES::Td[0];
const word32* AES::Td1 = AES::Td[1]; const word32* AES::Td1 = AES::Td[1];
const word32* AES::Td2 = AES::Td[2]; const word32* AES::Td2 = AES::Td[2];
const word32* AES::Td3 = AES::Td[3]; const word32* AES::Td3 = AES::Td[3];
const word32* AES::Td4 = AES::Td[4];
......
...@@ -1209,17 +1209,17 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz) ...@@ -1209,17 +1209,17 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)
} }
word32 rLen = GetLength(source); word32 rLen = GetLength(source);
if (rLen != 20) { if (rLen != 20) {
if (rLen == 21) { // zero at front, eat while (rLen > 20 && source.remaining() > 0) { // zero's at front, eat
source.next(); source.next();
--rLen; --rLen;
} }
else if (rLen == 19) { // add zero to front so 20 bytes if (rLen < 20) { // add zero's to front so 20 bytes
word32 tmpLen = rLen;
while (tmpLen < 20) {
decoded[0] = 0; decoded[0] = 0;
decoded++; decoded++;
tmpLen++;
} }
else {
source.SetError(DSA_SZ_E);
return 0;
} }
} }
memcpy(decoded, source.get_buffer() + source.get_index(), rLen); memcpy(decoded, source.get_buffer() + source.get_index(), rLen);
...@@ -1232,17 +1232,17 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz) ...@@ -1232,17 +1232,17 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)
} }
word32 sLen = GetLength(source); word32 sLen = GetLength(source);
if (sLen != 20) { if (sLen != 20) {
if (sLen == 21) { while (sLen > 20 && source.remaining() > 0) {
source.next(); // zero at front, eat source.next(); // zero's at front, eat
--sLen; --sLen;
} }
else if (sLen == 19) { if (sLen < 20) { // add zero's to front so 20 bytes
decoded[rLen] = 0; // add zero to front so 20 bytes word32 tmpLen = sLen;
while (tmpLen < 20) {
decoded[rLen] = 0;
decoded++; decoded++;
tmpLen++;
} }
else {
source.SetError(DSA_SZ_E);
return 0;
} }
} }
memcpy(decoded + rLen, source.get_buffer() + source.get_index(), sLen); memcpy(decoded + rLen, source.get_buffer() + source.get_index(), sLen);
......
...@@ -172,6 +172,7 @@ word32 DSA_Signer::Sign(const byte* sha_digest, byte* sig, ...@@ -172,6 +172,7 @@ word32 DSA_Signer::Sign(const byte* sha_digest, byte* sig,
const Integer& q = key_.GetSubGroupOrder(); const Integer& q = key_.GetSubGroupOrder();
const Integer& g = key_.GetSubGroupGenerator(); const Integer& g = key_.GetSubGroupGenerator();
const Integer& x = key_.GetPrivatePart(); const Integer& x = key_.GetPrivatePart();
byte* tmpPtr = sig; // initial signature output
Integer k(rng, 1, q - 1); Integer k(rng, 1, q - 1);
...@@ -187,22 +188,23 @@ word32 DSA_Signer::Sign(const byte* sha_digest, byte* sig, ...@@ -187,22 +188,23 @@ word32 DSA_Signer::Sign(const byte* sha_digest, byte* sig,
return (word32) -1; return (word32) -1;
int rSz = r_.ByteCount(); int rSz = r_.ByteCount();
int tmpSz = rSz;
if (rSz == 19) { while (tmpSz++ < SHA::DIGEST_SIZE) {
sig[0] = 0; *sig++ = 0;
sig++;
} }
r_.Encode(sig, rSz); r_.Encode(sig, rSz);
sig = tmpPtr + SHA::DIGEST_SIZE; // advance sig output to s
int sSz = s_.ByteCount(); int sSz = s_.ByteCount();
tmpSz = sSz;
if (sSz == 19) { while (tmpSz++ < SHA::DIGEST_SIZE) {
sig[rSz] = 0; *sig++ = 0;
sig++;
} }
s_.Encode(sig + rSz, sSz); s_.Encode(sig, sSz);
return 40; return 40;
} }
......
...@@ -1281,6 +1281,9 @@ int dsa_test() ...@@ -1281,6 +1281,9 @@ int dsa_test()
if (!verifier.Verify(digest, decoded)) if (!verifier.Verify(digest, decoded))
return -90; return -90;
if (!verifier.Verify(digest, signature))
return -91;
return 0; return 0;
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#define yaSSL_TEST_HPP #define yaSSL_TEST_HPP
#include "runtime.hpp" #include "runtime.hpp"
#include "openssl/ssl.h" /* openssl compatibility test */
#include "error.hpp" #include "error.hpp"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -56,6 +55,7 @@ ...@@ -56,6 +55,7 @@
#endif #endif
#define SOCKET_T int #define SOCKET_T int
#endif /* _WIN32 */ #endif /* _WIN32 */
#include "openssl/ssl.h" /* openssl compatibility test */
#ifdef _MSC_VER #ifdef _MSC_VER
......
...@@ -857,8 +857,7 @@ typedef long long my_ptrdiff_t; ...@@ -857,8 +857,7 @@ typedef long long my_ptrdiff_t;
and related routines are refactored. and related routines are refactored.
*/ */
#define my_offsetof(TYPE, MEMBER) \ #define my_offsetof(TYPE, MEMBER) PTR_BYTE_DIFF(&((TYPE *)0x10)->MEMBER, 0x10)
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
#define NullS (char *) 0 #define NullS (char *) 0
......
...@@ -260,12 +260,8 @@ sub show { ...@@ -260,12 +260,8 @@ sub show {
# On Windows, rely on cdb to be there... # On Windows, rely on cdb to be there...
if (IS_WINDOWS) if (IS_WINDOWS)
{
# Starting cdb is unsafe when used with --parallel > 1 option
if ( $parallel < 2 )
{ {
_cdb($core_name); _cdb($core_name);
}
return; return;
} }
......
...@@ -24,7 +24,7 @@ use File::Path; ...@@ -24,7 +24,7 @@ use File::Path;
use base qw(Exporter); use base qw(Exporter);
our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL
native_path posix_path mixed_path native_path posix_path mixed_path
check_socket_path_length process_alive); check_socket_path_length process_alive open_for_append);
BEGIN { BEGIN {
if ($^O eq "cygwin") { if ($^O eq "cygwin") {
...@@ -161,4 +161,51 @@ sub process_alive { ...@@ -161,4 +161,51 @@ sub process_alive {
} }
use Symbol qw( gensym );
use if $^O eq 'MSWin32', 'Win32API::File', qw( CloseHandle CreateFile GetOsFHandle OsFHandleOpen OPEN_ALWAYS FILE_APPEND_DATA
FILE_SHARE_READ FILE_SHARE_WRITE FILE_SHARE_DELETE );
use if $^O eq 'MSWin32', 'Win32::API';
use constant WIN32API_FILE_NULL => [];
# Open a file for append
# On Windows we use CreateFile with FILE_APPEND_DATA
# to insure that writes are atomic, not interleaved
# with writes by another processes.
sub open_for_append
{
my ($file) = @_;
my $fh = gensym();
if (IS_WIN32PERL)
{
my $handle;
if (!($handle = CreateFile(
$file,
FILE_APPEND_DATA(),
FILE_SHARE_READ()|FILE_SHARE_WRITE()|FILE_SHARE_DELETE(),
WIN32API_FILE_NULL,
OPEN_ALWAYS(),# Create if doesn't exist.
0,
WIN32API_FILE_NULL,
)))
{
return undef;
}
if (!OsFHandleOpen($fh, $handle, 'wat'))
{
CloseHandle($handle);
return undef;
}
return $fh;
}
open($fh,">>",$file) or return undef;
return $fh;
}
1; 1;
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
use strict; use strict;
use Carp; use Carp;
use My::Platform;
sub mtr_fromfile ($); sub mtr_fromfile ($);
sub mtr_tofile ($@); sub mtr_tofile ($@);
...@@ -45,10 +46,10 @@ sub mtr_fromfile ($) { ...@@ -45,10 +46,10 @@ sub mtr_fromfile ($) {
sub mtr_tofile ($@) { sub mtr_tofile ($@) {
my $file= shift; my $file= shift;
my $fh= open_for_append $file;
open(FILE,">>",$file) or mtr_error("can't open file \"$file\": $!"); mtr_error("can't open file \"$file\": $!") unless defined($fh);
print FILE join("", @_); print $fh join("", @_);
close FILE; close $fh;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment