MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
my_sha2.cc
Go to the documentation of this file.
1 /* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
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 Foundation,
14  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15 
16 
23 #include <my_global.h>
24 #include <sha2.h>
25 
26 #ifdef HAVE_YASSL
27 
28 /*
29  If TaoCrypt::SHA512 or ::SHA384 are not defined (but ::SHA256 is), it's
30  probably that neither of config.h's SIZEOF_LONG or SIZEOF_LONG_LONG are
31  64 bits long. At present, both OpenSSL and YaSSL require 64-bit integers
32  for SHA-512. (The SIZEOF_* definitions come from autoconf's config.h .)
33 */
34 
35 # define GEN_YASSL_SHA2_BRIDGE(size) \
36 unsigned char* SHA##size(const unsigned char *input_ptr, size_t input_length, \
37  char unsigned *output_ptr) { \
38  TaoCrypt::SHA##size hasher; \
39  \
40  hasher.Update(input_ptr, input_length); \
41  hasher.Final(output_ptr); \
42  return(output_ptr); \
43 }
44 
45 
57 # ifndef OPENSSL_NO_SHA512
58 GEN_YASSL_SHA2_BRIDGE(512);
59 GEN_YASSL_SHA2_BRIDGE(384);
60 # else
61 # warning Some SHA2 functionality is missing. See OPENSSL_NO_SHA512.
62 # endif
63 GEN_YASSL_SHA2_BRIDGE(256);
64 GEN_YASSL_SHA2_BRIDGE(224);
65 
66 # undef GEN_YASSL_SHA2_BRIDGE
67 
68 #endif /* HAVE_YASSL */