Skip to content

Commit 53fecff

Browse files
author
Konstantin Osipov
committed
Backport of:
[email protected], 2007-12-07 09:35:28-05:00, [email protected] +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.
1 parent 04b601a commit 53fecff

40 files changed

+2315
-83
lines changed

.bzrignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ libmysqld/rpl_record_old.cc
11501150
libmysqld/rpl_utility.cc
11511151
libmysqld/scheduler.cc
11521152
libmysqld/set_var.cc
1153+
libmysqld/sha2.cc
11531154
libmysqld/simple-test
11541155
libmysqld/slave.cc
11551156
libmysqld/sp.cc

client/mysql.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,7 +4300,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
43004300
mysql_options(&mysql, MYSQL_SECURE_AUTH, (char *) &opt_secure_auth);
43014301
if (using_opt_local_infile)
43024302
mysql_options(&mysql,MYSQL_OPT_LOCAL_INFILE, (char*) &opt_local_infile);
4303-
#ifdef HAVE_OPENSSL
4303+
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
43044304
if (opt_use_ssl)
43054305
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
43064306
opt_ssl_capath, opt_ssl_cipher);
@@ -4421,12 +4421,12 @@ com_status(String *buffer __attribute__((unused)),
44214421
mysql_free_result(result);
44224422
}
44234423

4424-
#ifdef HAVE_OPENSSL
4424+
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
44254425
if ((status_str= mysql_get_ssl_cipher(&mysql)))
44264426
tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
44274427
status_str);
44284428
else
4429-
#endif /* HAVE_OPENSSL */
4429+
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
44304430
tee_puts("SSL:\t\t\tNot in use", stdout);
44314431

44324432
if (skip_updates)

client/mysqltest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5170,7 +5170,7 @@ void do_connect(struct st_command *command)
51705170
mysql_options(&con_slot->mysql, MYSQL_SET_CHARSET_DIR,
51715171
opt_charsets_dir);
51725172

5173-
#ifdef HAVE_OPENSSL
5173+
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
51745174
if (opt_use_ssl || con_ssl)
51755175
{
51765176
mysql_ssl_set(&con_slot->mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
@@ -7916,7 +7916,7 @@ int main(int argc, char **argv)
79167916
mysql_options(&con->mysql, MYSQL_SET_CHARSET_DIR,
79177917
opt_charsets_dir);
79187918

7919-
#ifdef HAVE_OPENSSL
7919+
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
79207920

79217921
if (opt_use_ssl)
79227922
{

include/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
3737
heap.h my_bitmap.h my_uctype.h password.h \
3838
myisam.h myisampack.h myisammrg.h ft_global.h\
3939
mysys_err.h my_base.h help_start.h help_end.h \
40-
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
40+
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h sha2.h \
4141
my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
4242
thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
4343
my_handler.h my_time.h service_versions.h \

include/mysql_embed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */
2525

2626
#undef HAVE_PSTACK /* No stacktrace */
27-
#undef HAVE_OPENSSL
27+
#undef HAVE_DLOPEN /* No udf functions */
2828
#undef HAVE_SMEM /* No shared memory */
2929
#undef HAVE_NDBCLUSTER_DB /* No NDB cluster */
3030

include/sha2.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* Copyright (C) 2007 MySQL AB
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
15+
16+
#ifndef included_sha2_h
17+
#define included_sha2_h
18+
19+
#include <my_config.h>
20+
21+
# ifndef HAVE_YASSL
22+
# include <openssl/sha.h>
23+
# endif
24+
25+
# ifdef HAVE_YASSL
26+
27+
#include "../extra/yassl/taocrypt/include/sha.hpp"
28+
29+
# ifdef __cplusplus
30+
extern "C" {
31+
# endif
32+
33+
#ifndef SHA512_DIGEST_LENGTH
34+
#define SHA512_DIGEST_LENGTH TaoCrypt::SHA512::DIGEST_SIZE
35+
#endif
36+
37+
#ifndef SHA384_DIGEST_LENGTH
38+
#define SHA384_DIGEST_LENGTH TaoCrypt::SHA384::DIGEST_SIZE
39+
#endif
40+
41+
#ifndef SHA256_DIGEST_LENGTH
42+
#define SHA256_DIGEST_LENGTH TaoCrypt::SHA256::DIGEST_SIZE
43+
#endif
44+
45+
#ifndef SHA224_DIGEST_LENGTH
46+
#define SHA224_DIGEST_LENGTH TaoCrypt::SHA224::DIGEST_SIZE
47+
#endif
48+
49+
#define GEN_YASSL_SHA2_BRIDGE(size) \
50+
unsigned char* SHA##size(const unsigned char *input_ptr, size_t input_length, \
51+
char unsigned *output_ptr);
52+
53+
GEN_YASSL_SHA2_BRIDGE(512);
54+
GEN_YASSL_SHA2_BRIDGE(384);
55+
GEN_YASSL_SHA2_BRIDGE(256);
56+
GEN_YASSL_SHA2_BRIDGE(224);
57+
58+
#undef GEN_YASSL_SHA2_BRIDGE
59+
60+
# ifdef __cplusplus
61+
}
62+
# endif
63+
64+
# endif /* HAVE_YASSL */
65+
66+
#endif /* included_sha2_h */

include/sslopt-case.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
along with this program; if not, write to the Free Software
1717
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1818

19-
#ifdef HAVE_OPENSSL
19+
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
2020
case OPT_SSL_KEY:
2121
case OPT_SSL_CERT:
2222
case OPT_SSL_CA:

include/sslopt-longopts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
along with this program; if not, write to the Free Software
1717
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1818

19-
#ifdef HAVE_OPENSSL
19+
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
2020

2121
{"ssl", OPT_SSL_SSL,
2222
"Enable SSL for connection (automatically enabled with other flags).",

include/sslopt-vars.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
along with this program; if not, write to the Free Software
1717
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1818

19-
#ifdef HAVE_OPENSSL
19+
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
2020
#ifdef SSL_VARS_NOT_STATIC
2121
#define SSL_STATIC
2222
#else

include/violite.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ typedef my_socket YASSL_SOCKET_T;
118118
#include <openssl/ssl.h>
119119
#include <openssl/err.h>
120120

121+
#ifndef EMBEDDED_LIBRARY
121122
enum enum_ssl_init_error
122123
{
123124
SSL_INITERR_NOERROR= 0, SSL_INITERR_CERT, SSL_INITERR_KEY,
@@ -143,6 +144,7 @@ struct st_VioSSLFd
143144
const char *ca_file,const char *ca_path,
144145
const char *cipher, enum enum_ssl_init_error* error);
145146
void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd);
147+
#endif /* ! EMBEDDED_LIBRARY */
146148
#endif /* HAVE_OPENSSL */
147149

148150
void vio_end(void);

0 commit comments

Comments
 (0)