From 53fecff1ef023e5020d17dbe38ec8ee4fa499d12 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Tue, 13 Apr 2010 19:04:45 +0400 Subject: Backport of: ChangeSet@1.2703, 2007-12-07 09:35:28-05:00, cmiller@zippy.cornsilk.net +40 -0 Bug#13174: SHA2 function Patch contributed from Bill Karwin, paper unnumbered CLA in Seattle Implement SHA2 functions. Chad added code to make it work with YaSSL. Also, he removed the (probable) bug of embedded server never using SSL-dependent functions. (libmysqld/Makefile.am didn't read ANY autoconf defs.) Function specification: SHA2( string cleartext, integer hash_length ) -> string hash, or NULL where hash_length is one of 224, 256, 384, or 512. If either is NULL or a length is unsupported, then the result is NULL. The resulting string is always the length of the hash_length parameter or is NULL. Include the canonical hash examples from the NIST in the test results. --- Polish and address concerns of reviewers. --- include/Makefile.am | 2 +- include/mysql_embed.h | 2 +- include/sha2.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++ include/sslopt-case.h | 2 +- include/sslopt-longopts.h | 2 +- include/sslopt-vars.h | 2 +- include/violite.h | 2 ++ 7 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 include/sha2.h (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index c60965fd385..5ede6d7591f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -37,7 +37,7 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \ heap.h my_bitmap.h my_uctype.h password.h \ myisam.h myisampack.h myisammrg.h ft_global.h\ mysys_err.h my_base.h help_start.h help_end.h \ - my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \ + my_nosys.h my_alarm.h queues.h rijndael.h sha1.h sha2.h \ my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \ thr_lock.h t_ctype.h violite.h my_md5.h base64.h \ my_handler.h my_time.h service_versions.h \ diff --git a/include/mysql_embed.h b/include/mysql_embed.h index 0e5a360585e..b26b723381d 100644 --- a/include/mysql_embed.h +++ b/include/mysql_embed.h @@ -24,7 +24,7 @@ /* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */ #undef HAVE_PSTACK /* No stacktrace */ -#undef HAVE_OPENSSL +#undef HAVE_DLOPEN /* No udf functions */ #undef HAVE_SMEM /* No shared memory */ #undef HAVE_NDBCLUSTER_DB /* No NDB cluster */ diff --git a/include/sha2.h b/include/sha2.h new file mode 100644 index 00000000000..3c10be8958c --- /dev/null +++ b/include/sha2.h @@ -0,0 +1,66 @@ +/* Copyright (C) 2007 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef included_sha2_h +#define included_sha2_h + +#include + +# ifndef HAVE_YASSL +# include +# endif + +# ifdef HAVE_YASSL + +#include "../extra/yassl/taocrypt/include/sha.hpp" + +# ifdef __cplusplus +extern "C" { +# endif + +#ifndef SHA512_DIGEST_LENGTH +#define SHA512_DIGEST_LENGTH TaoCrypt::SHA512::DIGEST_SIZE +#endif + +#ifndef SHA384_DIGEST_LENGTH +#define SHA384_DIGEST_LENGTH TaoCrypt::SHA384::DIGEST_SIZE +#endif + +#ifndef SHA256_DIGEST_LENGTH +#define SHA256_DIGEST_LENGTH TaoCrypt::SHA256::DIGEST_SIZE +#endif + +#ifndef SHA224_DIGEST_LENGTH +#define SHA224_DIGEST_LENGTH TaoCrypt::SHA224::DIGEST_SIZE +#endif + +#define GEN_YASSL_SHA2_BRIDGE(size) \ +unsigned char* SHA##size(const unsigned char *input_ptr, size_t input_length, \ + char unsigned *output_ptr); + +GEN_YASSL_SHA2_BRIDGE(512); +GEN_YASSL_SHA2_BRIDGE(384); +GEN_YASSL_SHA2_BRIDGE(256); +GEN_YASSL_SHA2_BRIDGE(224); + +#undef GEN_YASSL_SHA2_BRIDGE + +# ifdef __cplusplus +} +# endif + +# endif /* HAVE_YASSL */ + +#endif /* included_sha2_h */ diff --git a/include/sslopt-case.h b/include/sslopt-case.h index ce46cf65cc9..3b64a225fe2 100644 --- a/include/sslopt-case.h +++ b/include/sslopt-case.h @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef HAVE_OPENSSL +#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) case OPT_SSL_KEY: case OPT_SSL_CERT: case OPT_SSL_CA: diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index b98e72e298e..151287e1718 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef HAVE_OPENSSL +#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) {"ssl", OPT_SSL_SSL, "Enable SSL for connection (automatically enabled with other flags).", diff --git a/include/sslopt-vars.h b/include/sslopt-vars.h index 4493fbc59ab..d0eec3b6d74 100644 --- a/include/sslopt-vars.h +++ b/include/sslopt-vars.h @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef HAVE_OPENSSL +#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) #ifdef SSL_VARS_NOT_STATIC #define SSL_STATIC #else diff --git a/include/violite.h b/include/violite.h index 904c383d64a..05ceaa272c1 100644 --- a/include/violite.h +++ b/include/violite.h @@ -118,6 +118,7 @@ typedef my_socket YASSL_SOCKET_T; #include #include +#ifndef EMBEDDED_LIBRARY enum enum_ssl_init_error { SSL_INITERR_NOERROR= 0, SSL_INITERR_CERT, SSL_INITERR_KEY, @@ -143,6 +144,7 @@ struct st_VioSSLFd const char *ca_file,const char *ca_path, const char *cipher, enum enum_ssl_init_error* error); void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd); +#endif /* ! EMBEDDED_LIBRARY */ #endif /* HAVE_OPENSSL */ void vio_end(void); -- cgit v1.2.1 From fad9478ebad33523bf66e65930056929847cb7b1 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 13 Apr 2010 20:10:51 +0400 Subject: Post-fix for Bug#13174. --- include/sha2.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/sha2.h b/include/sha2.h index 3c10be8958c..e67a4100ff2 100644 --- a/include/sha2.h +++ b/include/sha2.h @@ -18,11 +18,16 @@ #include +#if defined(HAVE_YASSL) || defined(HAVE_OPENSSL) + +# ifdef HAVE_STDDEF_H +# include +# endif + # ifndef HAVE_YASSL # include -# endif -# ifdef HAVE_YASSL +# else #include "../extra/yassl/taocrypt/include/sha.hpp" @@ -63,4 +68,5 @@ GEN_YASSL_SHA2_BRIDGE(224); # endif /* HAVE_YASSL */ +#endif /* HAVE_OPENSSL || HAVE_YASSL */ #endif /* included_sha2_h */ -- cgit v1.2.1 From 1b12f4c2334f6a5a20628e48a97eac876a47b6fb Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Thu, 15 Apr 2010 13:05:17 +0400 Subject: BUG#47059 - In audit plugin I cannot see the event subclasses, e.g.MYSQL_AUDIT_GENERAL_ERROR General audit API (MYSQL_AUDIT_GENERAL_CLASS) didn't expose event subclass to plugins. This patch exposes event subclass to plugins via struct mysql_event_general::event_subclass. This change is not compatible with existing general audit plugins. Audit interface major version has been incremented. --- include/mysql/plugin_audit.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/mysql/plugin_audit.h b/include/mysql/plugin_audit.h index 8932767075d..41505da64af 100644 --- a/include/mysql/plugin_audit.h +++ b/include/mysql/plugin_audit.h @@ -24,7 +24,7 @@ #define MYSQL_AUDIT_CLASS_MASK_SIZE 1 -#define MYSQL_AUDIT_INTERFACE_VERSION 0x0100 +#define MYSQL_AUDIT_INTERFACE_VERSION 0x0200 /* The first word in every event class struct indicates the specific @@ -32,7 +32,7 @@ */ struct mysql_event { - int event_class; + unsigned int event_class; }; @@ -52,7 +52,8 @@ struct mysql_event struct mysql_event_general { - int event_class; + unsigned int event_class; + unsigned int event_subclass; int general_error_code; unsigned long general_thread_id; const char *general_user; -- cgit v1.2.1 From 29f098f2d3b8cabe352bd255567c4eae4bcfea00 Mon Sep 17 00:00:00 2001 From: Daniel Fischer Date: Fri, 16 Apr 2010 10:27:18 +0200 Subject: Make the libraries we produce on Windows actually usable --- include/my_global.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/my_global.h b/include/my_global.h index b4bc61e0a48..c0a55e0f4e4 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -18,6 +18,11 @@ #ifndef _global_h #define _global_h +/* Client library users on Windows need this macro defined here. */ +#if !defined(__WIN__) && defined(_WIN32) +#define __WIN__ +#endif + /* InnoDB depends on some MySQL internals which other plugins should not need. This is because of InnoDB's foreign key support, "safe" binlog @@ -1089,10 +1094,14 @@ typedef long long my_ptrdiff_t; #define HUGE_PTR #endif #endif -#if defined(__IBMC__) || defined(__IBMCPP__) -/* This was _System _Export but caused a lot of warnings on _AIX43 */ -#define STDCALL -#elif !defined( STDCALL) + +#ifdef STDCALL +#undef STDCALL +#endif + +#ifdef _WIN32 +#define STDCALL __stdcall +#else #define STDCALL #endif -- cgit v1.2.1 From f96694f9c72e8e1c55a7990c1673920f7d3d4845 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Wed, 21 Apr 2010 00:29:30 +0200 Subject: WL#5030: Splitting mysql_priv.h Removing traces of mysql_priv.h from comments and other non-source files that were missed before. --- include/mysql/innodb_priv.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/mysql/innodb_priv.h b/include/mysql/innodb_priv.h index 56d8434f9b0..993dad7cf99 100644 --- a/include/mysql/innodb_priv.h +++ b/include/mysql/innodb_priv.h @@ -24,12 +24,14 @@ class THD; uint filename_to_tablename(const char *from, char *to, uint to_length); int get_quote_char_for_identifier(THD *thd, const char *name, uint length); +bool schema_table_store_record(THD *thd, TABLE *table); +void localtime_to_TIME(MYSQL_TIME *to, struct tm *from); bool check_global_access(THD *thd, ulong want_access); - uint strconvert(CHARSET_INFO *from_cs, const char *from, CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors); void sql_print_error(const char *format, ...); + #endif /* INNODB_PRIV_INCLUDED */ -- cgit v1.2.1