Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
70a2efde
Commit
70a2efde
authored
Mar 06, 2017
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove old API for SHA2
parent
d6a7aece
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
266 deletions
+19
-266
include/sha2.h
include/sha2.h
+0
-72
libmysqld/CMakeLists.txt
libmysqld/CMakeLists.txt
+1
-1
mysys_ssl/CMakeLists.txt
mysys_ssl/CMakeLists.txt
+0
-1
mysys_ssl/my_sha2.cc
mysys_ssl/my_sha2.cc
+0
-68
sql/CMakeLists.txt
sql/CMakeLists.txt
+1
-1
sql/item_strfunc.cc
sql/item_strfunc.cc
+17
-55
sql/sha2.cc
sql/sha2.cc
+0
-68
No files found.
include/sha2.h
deleted
100644 → 0
View file @
d6a7aece
/* 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 */
libmysqld/CMakeLists.txt
View file @
70a2efde
...
...
@@ -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
...
...
mysys_ssl/CMakeLists.txt
View file @
70a2efde
...
...
@@ -27,7 +27,6 @@ SET(MYSYS_SSL_HIDDEN_SOURCES
my_sha256.cc
my_sha384.cc
my_sha512.cc
my_sha2.cc
my_md5.cc
)
...
...
mysys_ssl/my_sha2.cc
deleted
100644 → 0
View file @
d6a7aece
/* 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 */
sql/CMakeLists.txt
View file @
70a2efde
...
...
@@ -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
...
...
sql/item_strfunc.cc
View file @
70a2efde
...
...
@@ -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 */
...
...
sql/sha2.cc
deleted
100644 → 0
View file @
d6a7aece
/* 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 */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment