MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
my_md5.cc
Go to the documentation of this file.
1 /* Copyright (c) 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 
25 #include <my_global.h>
26 #include <my_md5.h>
27 
28 #if defined(HAVE_YASSL)
29 #include "my_config.h"
30 #include "md5.hpp"
31 
32 static void my_md5_hash(char *digest, const char *buf, int len)
33 {
34  TaoCrypt::MD5 hasher;
35  hasher.Update((TaoCrypt::byte *) buf, len);
36  hasher.Final((TaoCrypt::byte *) digest);
37 }
38 
39 #elif defined(HAVE_OPENSSL)
40 #include <openssl/md5.h>
41 
42 static void my_md5_hash(unsigned char* digest, unsigned const char *buf, int len)
43 {
44  MD5_CTX ctx;
45  MD5_Init (&ctx);
46  MD5_Update (&ctx, buf, len);
47  MD5_Final (digest, &ctx);
48 }
49 
50 #endif /* HAVE_YASSL */
51 
61 void compute_md5_hash(char *digest, const char *buf, int len)
62 {
63 #if defined(HAVE_YASSL)
64  my_md5_hash(digest, buf, len);
65 #elif defined(HAVE_OPENSSL)
66  my_md5_hash((unsigned char*)digest, (unsigned const char*)buf, len);
67 #endif /* HAVE_YASSL */
68 }