Skip to content

Commit

Permalink
remove old API for SHA2
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Mar 10, 2017
1 parent d6a7aec commit 70a2efd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 266 deletions.
72 changes: 0 additions & 72 deletions include/sha2.h

This file was deleted.

2 changes: 1 addition & 1 deletion libmysqld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion mysys_ssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ SET(MYSYS_SSL_HIDDEN_SOURCES
my_sha256.cc
my_sha384.cc
my_sha512.cc
my_sha2.cc
my_md5.cc
)

Expand Down
68 changes: 0 additions & 68 deletions mysys_ssl/my_sha2.cc

This file was deleted.

2 changes: 1 addition & 1 deletion sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
72 changes: 17 additions & 55 deletions sql/item_strfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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())
{
Expand All @@ -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
Expand All @@ -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) */
}


Expand All @@ -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,
Expand All @@ -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 */
Expand Down
68 changes: 0 additions & 68 deletions sql/sha2.cc

This file was deleted.

0 comments on commit 70a2efd

Please sign in to comment.