diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-04-13 19:04:45 +0400 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-04-13 19:04:45 +0400 |
commit | 3227ba706fac95367ed53a48966303bc996b1d7f (patch) | |
tree | 30820e84d6b99238e1ecd963c1995382a93a7cf6 /include | |
parent | cd35dd73a1487166733fcc3a364c4e86939b46ea (diff) | |
download | mariadb-git-3227ba706fac95367ed53a48966303bc996b1d7f.tar.gz |
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.
.bzrignore:
Added libmysqld/sha2.cc to the ignore list.
client/mysql.cc:
Add condition to remove code for embedded server.
client/mysqltest.cc:
Add condition to remove code for embedded server.
include/Makefile.am:
New header file to header list.
include/mysql_embed.h:
Embedded servers can use SSL-library functions too!
include/sha2.h:
Compatibility layer to make YaSSL behave like OpenSSL.
include/sslopt-case.h:
Remove SSL-communication parameters from command lines.
include/sslopt-longopts.h:
Remove SSL-communication parameters from command lines.
include/sslopt-vars.h:
Don't declare variables that are only used in SSL communication, if
we are compiling the embedded server.
include/violite.h:
Don't even compile the SSL-communication function if we're in the
embedded server.
---
Remove CPP condition indentation.
libmysqld/CMakeLists.txt:
Add new file to source list.
libmysqld/Makefile.am:
Include standard DEFS in embedded compilation. It's an undiscovered
but that it's not there.
Add new file to source list.
libmysqld/examples/Makefile.am:
Include autoconf DEFS.
libmysqld/lib_sql.cc:
Initialize SSL-related variables in embedded server.
mysql-test/include/have_ssl_crypto_functs.inc:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/r/func_digest.result:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
mysql-test/r/func_encrypt_nossl.result:
Update results to the new error message text.
mysql-test/r/have_ssl_is_yes_or_disabled_only.require:
Distinguish between communication and crypto.
Use the tristate value of "have_ssl" variable to know whether to
test or not for SSL-provided crypto functions.
mysql-test/suite/rpl/t/rpl_ssl.test:
Distinguish between communication and crypto.
mysql-test/suite/rpl/t/rpl_ssl1.test:
Distinguish between communication and crypto.
mysql-test/t/func_des_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/func_digest.test:
Test against the sample test vectors in the NIST Secure
Hash Standard (http://csrc.nist.gov/cryptval/shs.htm)
Also, test that various parameters (legal and illegal)
do what we expect.
---
Distinguish between communication and crypto.
mysql-test/t/func_encrypt.test:
Distinguish between communication and crypto.
mysql-test/t/openssl_1.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl-big.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_8k_key.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_compress.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
mysql-test/t/ssl_connect.test:
Don't test SSL communication if we're in the embedded server.
---
Distinguish between communication and crypto.
sql-common/client.c:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/CMakeLists.txt:
Add new source file to source list so that we have access to SHA2
functions.
sql/Makefile.am:
Add new source file to source list so that we have access to SHA2
functions.
sql/item_create.cc:
Bootstrap the SHA2 function into the server.
sql/item_strfunc.cc:
Add new SHA2 Item class methods.
Clean up two minor problems.
---
Remove extraneous debugging.
---
We must check nullness of a parameter only /after/ computing its
value.
sql/item_strfunc.h:
Declare new SHA2 Item class.
sql/mysqld.cc:
For embedded server, don't refer to SSL-communications variables
or values.
---
Remove CPP condition indentation.
sql/sha2.cc:
Compatibility layer to make YaSSL behave like OpenSSL.
---
Add comment for generated functions.
sql/sql_acl.cc:
For embedded server, don't refer to SSL-communications variables
or values.
sql/sql_connect.cc:
SSL is useful for more functionality than just connecting. Test
for whether we are not embedded server also.
sql/sys_vars.cc:
For embedded server, don't refer to SSL-communications variables
or values.
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 2 | ||||
-rw-r--r-- | include/mysql_embed.h | 2 | ||||
-rw-r--r-- | include/sha2.h | 66 | ||||
-rw-r--r-- | include/sslopt-case.h | 2 | ||||
-rw-r--r-- | include/sslopt-longopts.h | 2 | ||||
-rw-r--r-- | include/sslopt-vars.h | 2 | ||||
-rw-r--r-- | include/violite.h | 2 |
7 files changed, 73 insertions, 5 deletions
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 <my_config.h> + +# ifndef HAVE_YASSL +# include <openssl/sha.h> +# 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 <openssl/ssl.h> #include <openssl/err.h> +#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); |