Skip to content
Permalink
Browse files

remove old API for SHA2

  • Loading branch information...
vuvova committed Mar 6, 2017
1 parent d6a7aec commit 70a2efde0352052fce5a44481055542e0b050048
Showing with 19 additions and 266 deletions.
  1. +0 −72 include/sha2.h
  2. +1 −1 libmysqld/CMakeLists.txt
  3. +0 −1 mysys_ssl/CMakeLists.txt
  4. +0 −68 mysys_ssl/my_sha2.cc
  5. +1 −1 sql/CMakeLists.txt
  6. +17 −55 sql/item_strfunc.cc
  7. +0 −68 sql/sha2.cc

This file was deleted.

@@ -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
@@ -27,7 +27,6 @@ SET(MYSYS_SSL_HIDDEN_SOURCES
my_sha256.cc
my_sha384.cc
my_sha512.cc
my_sha2.cc
my_md5.cc
)

This file was deleted.

@@ -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
@@ -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 */

This file was deleted.

0 comments on commit 70a2efd

Please sign in to comment.
You can’t perform that action at this time.