diff options
-rw-r--r-- | include/sha2.h | 72 | ||||
-rw-r--r-- | libmysqld/CMakeLists.txt | 2 | ||||
-rw-r--r-- | mysys_ssl/CMakeLists.txt | 1 | ||||
-rw-r--r-- | mysys_ssl/my_sha2.cc | 68 | ||||
-rw-r--r-- | sql/CMakeLists.txt | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 72 | ||||
-rw-r--r-- | sql/sha2.cc | 68 |
7 files changed, 19 insertions, 266 deletions
diff --git a/include/sha2.h b/include/sha2.h deleted file mode 100644 index 737658e9ced..00000000000 --- a/include/sha2.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - -#ifndef included_sha2_h -#define included_sha2_h - -#include <my_config.h> - -#if defined(HAVE_YASSL) || defined(HAVE_OPENSSL) - -# ifdef HAVE_STDDEF_H -# include <stddef.h> -# endif - -# ifndef HAVE_YASSL -# include <openssl/sha.h> - -# else - -#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 /* HAVE_OPENSSL || HAVE_YASSL */ -#endif /* included_sha2_h */ diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 515105f49e8..07bee9848b6 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -56,7 +56,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/net_serv.cc ../sql/opt_range.cc ../sql/opt_sum.cc ../sql/parse_file.cc ../sql/procedure.cc ../sql/protocol.cc ../sql/records.cc ../sql/repl_failsafe.cc ../sql/rpl_filter.cc - ../sql/rpl_record.cc ../sql/sha2.cc ../sql/des_key_file.cc + ../sql/rpl_record.cc ../sql/des_key_file.cc ../sql/rpl_injector.cc ../sql/set_var.cc ../sql/spatial.cc ../sql/sp_cache.cc ../sql/sp.cc ../sql/sp_head.cc ../sql/sp_pcontext.cc ../sql/sp_rcontext.cc ../sql/sql_acl.cc diff --git a/mysys_ssl/CMakeLists.txt b/mysys_ssl/CMakeLists.txt index 7251d8777f8..4f6f7458c5b 100644 --- a/mysys_ssl/CMakeLists.txt +++ b/mysys_ssl/CMakeLists.txt @@ -27,7 +27,6 @@ SET(MYSYS_SSL_HIDDEN_SOURCES my_sha256.cc my_sha384.cc my_sha512.cc - my_sha2.cc my_md5.cc ) diff --git a/mysys_ssl/my_sha2.cc b/mysys_ssl/my_sha2.cc deleted file mode 100644 index 00200337f08..00000000000 --- a/mysys_ssl/my_sha2.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ - - -/** - @file - A compatibility layer to our built-in SSL implementation, to mimic the - oft-used external library, OpenSSL. -*/ - -#include <my_global.h> -#include <sha2.h> - -#ifdef HAVE_YASSL - -/* - If TaoCrypt::SHA512 or ::SHA384 are not defined (but ::SHA256 is), it's - probably that neither of config.h's SIZEOF_LONG or SIZEOF_LONG_LONG are - 64 bits long. At present, both OpenSSL and YaSSL require 64-bit integers - for SHA-512. (The SIZEOF_* definitions come from autoconf's config.h .) -*/ - -# define GEN_YASSL_SHA2_BRIDGE(size) \ -unsigned char* SHA##size(const unsigned char *input_ptr, size_t input_length, \ - char unsigned *output_ptr) { \ - TaoCrypt::SHA##size hasher; \ - \ - hasher.Update(input_ptr, input_length); \ - hasher.Final(output_ptr); \ - return(output_ptr); \ -} - - -/** - @fn SHA512 - @fn SHA384 - @fn SHA256 - @fn SHA224 - - Instantiate an hash object, fill in the cleartext value, compute the digest, - and extract the result from the object. - - (Generate the functions. See similar .h code for the prototypes.) -*/ -# ifndef OPENSSL_NO_SHA512 -GEN_YASSL_SHA2_BRIDGE(512); -GEN_YASSL_SHA2_BRIDGE(384); -# else -# warning Some SHA2 functionality is missing. See OPENSSL_NO_SHA512. -# endif -GEN_YASSL_SHA2_BRIDGE(256); -GEN_YASSL_SHA2_BRIDGE(224); - -# undef GEN_YASSL_SHA2_BRIDGE - -#endif /* HAVE_YASSL */ diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 46eb4bec3cc..8944233cb5b 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -81,7 +81,7 @@ SET (SQL_SOURCE ../sql-common/client.c compat56.cc derror.cc des_key_file.cc discover.cc ../libmysql/errmsg.c field.cc field_conv.cc filesort_utils.cc - filesort.cc gstream.cc sha2.cc + filesort.cc gstream.cc signal_handler.cc handler.cc hash_filo.h hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 893398bb2a0..84cf21bd0d3 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -33,9 +33,6 @@ #include <my_global.h> // HAVE_* -/* May include caustic 3rd-party defs. Use early, so it can override nothing */ -#include "sha2.h" - #include "sql_priv.h" /* It is necessary to include set_var.h instead of item.h because there @@ -196,12 +193,10 @@ void Item_func_sha::fix_length_and_dec() String *Item_func_sha2::val_str_ascii(String *str) { DBUG_ASSERT(fixed == 1); -#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) - unsigned char digest_buf[SHA512_DIGEST_LENGTH]; + unsigned char digest_buf[512/8]; // enough for SHA512 String *input_string; - unsigned char *input_ptr; + const char *input_ptr; size_t input_len; - uint digest_length= 0; str->set_charset(&my_charset_bin); @@ -216,31 +211,26 @@ String *Item_func_sha2::val_str_ascii(String *str) if (null_value) return (String *) NULL; - input_ptr= (unsigned char *) input_string->ptr(); + input_ptr= input_string->ptr(); input_len= input_string->length(); - switch ((uint) args[1]->val_int()) { -#ifndef OPENSSL_NO_SHA512 + longlong digest_length= args[1]->val_int(); + switch (digest_length) { case 512: - digest_length= SHA512_DIGEST_LENGTH; - (void) SHA512(input_ptr, input_len, digest_buf); + my_sha512(digest_buf, input_ptr, input_len); break; case 384: - digest_length= SHA384_DIGEST_LENGTH; - (void) SHA384(input_ptr, input_len, digest_buf); + my_sha384(digest_buf, input_ptr, input_len); break; -#endif -#ifndef OPENSSL_NO_SHA256 case 224: - digest_length= SHA224_DIGEST_LENGTH; - (void) SHA224(input_ptr, input_len, digest_buf); + my_sha224(digest_buf, input_ptr, input_len); break; - case 256: case 0: // SHA-256 is the default - digest_length= SHA256_DIGEST_LENGTH; - (void) SHA256(input_ptr, input_len, digest_buf); + digest_length= 256; + /* fall trough */ + case 256: + my_sha256(digest_buf, input_ptr, input_len); break; -#endif default: if (!args[1]->const_item()) { @@ -254,6 +244,7 @@ String *Item_func_sha2::val_str_ascii(String *str) null_value= TRUE; return NULL; } + digest_length/= 8; /* bits to bytes */ /* Since we're subverting the usual String methods, we must make sure that @@ -269,17 +260,6 @@ String *Item_func_sha2::val_str_ascii(String *str) null_value= FALSE; return str; - -#else - THD *thd= current_thd; - push_warning_printf(thd, - Sql_condition::WARN_LEVEL_WARN, - ER_FEATURE_DISABLED, - ER_THD(thd, ER_FEATURE_DISABLED), - "sha2", "--with-ssl"); - null_value= TRUE; - return (String *) NULL; -#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */ } @@ -288,27 +268,18 @@ void Item_func_sha2::fix_length_and_dec() maybe_null= 1; max_length = 0; -#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) int sha_variant= args[1]->const_item() ? args[1]->val_int() : 512; switch (sha_variant) { -#ifndef OPENSSL_NO_SHA512 + case 0: // SHA-256 is the default + sha_variant= 256; + /* fall trough */ case 512: - fix_length_and_charset(SHA512_DIGEST_LENGTH * 2, default_charset()); - break; case 384: - fix_length_and_charset(SHA384_DIGEST_LENGTH * 2, default_charset()); - break; -#endif -#ifndef OPENSSL_NO_SHA256 case 256: - case 0: // SHA-256 is the default - fix_length_and_charset(SHA256_DIGEST_LENGTH * 2, default_charset()); - break; case 224: - fix_length_and_charset(SHA224_DIGEST_LENGTH * 2, default_charset()); + fix_length_and_charset(sha_variant/8 * 2, default_charset()); break; -#endif default: THD *thd= current_thd; push_warning_printf(thd, @@ -317,15 +288,6 @@ void Item_func_sha2::fix_length_and_dec() ER_THD(thd, ER_WRONG_PARAMETERS_TO_NATIVE_FCT), "sha2"); } - -#else - THD *thd= current_thd; - push_warning_printf(thd, - Sql_condition::WARN_LEVEL_WARN, - ER_FEATURE_DISABLED, - ER_THD(thd, ER_FEATURE_DISABLED), - "sha2", "--with-ssl"); -#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */ } /* Implementation of AES encryption routines */ diff --git a/sql/sha2.cc b/sql/sha2.cc deleted file mode 100644 index f2201974172..00000000000 --- a/sql/sha2.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - - -/** - @file - A compatibility layer to our built-in SSL implementation, to mimic the - oft-used external library, OpenSSL. -*/ - -#include <my_global.h> -#include <sha2.h> - -#ifdef HAVE_YASSL - -/* - If TaoCrypt::SHA512 or ::SHA384 are not defined (but ::SHA256 is), it's - probably that neither of config.h's SIZEOF_LONG or SIZEOF_LONG_LONG are - 64 bits long. At present, both OpenSSL and YaSSL require 64-bit integers - for SHA-512. (The SIZEOF_* definitions come from autoconf's config.h .) -*/ - -# define GEN_YASSL_SHA2_BRIDGE(size) \ -unsigned char* SHA##size(const unsigned char *input_ptr, size_t input_length, \ - char unsigned *output_ptr) { \ - TaoCrypt::SHA##size hasher; \ - \ - hasher.Update(input_ptr, input_length); \ - hasher.Final(output_ptr); \ - return(output_ptr); \ -} - - -/** - @fn SHA512 - @fn SHA384 - @fn SHA256 - @fn SHA224 - - Instantiate an hash object, fill in the cleartext value, compute the digest, - and extract the result from the object. - - (Generate the functions. See similar .h code for the prototypes.) -*/ -# ifndef OPENSSL_NO_SHA512 -GEN_YASSL_SHA2_BRIDGE(512); -GEN_YASSL_SHA2_BRIDGE(384); -# else -# warning Some SHA2 functionality is missing. See OPENSSL_NO_SHA512. -# endif -GEN_YASSL_SHA2_BRIDGE(256); -GEN_YASSL_SHA2_BRIDGE(224); - -# undef GEN_YASSL_SHA2_BRIDGE - -#endif /* HAVE_YASSL */ |