Commit c6b95222 authored by Sergei Golubchik's avatar Sergei Golubchik

use MD5 service in innodb/xtradb

parent d6141a55
#ifndef MYSQL_SERVICE_MD5_INCLUDED
/* Copyright (c) 2013, Monty Program Ab
/* Copyright (c) 2014, Monty Program Ab
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
......
/* Copyright (c) 2013 Monty Program Ab
/* Copyright (c) 2014 Monty Program Ab
Use is subject to license terms.
This program is free software; you can redistribute it and/or modify
......
......@@ -251,27 +251,6 @@ ENDIF()
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include
${CMAKE_SOURCE_DIR}/storage/innobase/handler)
IF(WITH_WSREP)
# ssl include directory
INCLUDE_DIRECTORIES(${SSL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/storage/innobase/wsrep)
IF(SSL_DEFINES)
ADD_DEFINITIONS(${SSL_DEFINES})
ENDIF()
LINK_LIBRARIES(${SSL_LIBRARIES})
# We do RESTRICT_SYMBOL_EXPORTS(yassl) elsewhere.
# In order to get correct symbol visibility, these files
# must be compiled with "-fvisibility=hidden"
IF(WITH_SSL STREQUAL "bundled" AND HAVE_VISIBILITY_HIDDEN)
SET_SOURCE_FILES_PROPERTIES(
{CMAKE_CURRENT_SOURCE_DIR}/wsrep/md5.cc
PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
ENDIF()
ENDIF()
# Sun Studio bug with -xO2
IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro"
AND CMAKE_CXX_FLAGS_RELEASE MATCHES "O2"
......@@ -420,10 +399,6 @@ SET(INNOBASE_SOURCES
ut/ut0wqueue.cc
ut/ut0timer.cc)
IF(WITH_WSREP)
SET(INNOBASE_SOURCES ${INNOBASE_SOURCES} wsrep/md5.cc)
ENDIF()
IF(WITH_INNODB)
# Legacy option
SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
......
......@@ -122,7 +122,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include "dict0priv.h"
#include "../storage/innobase/include/ut0byte.h"
#include <wsrep_mysqld.h>
#include <wsrep_md5.h>
#include <mysql/service_md5.h>
extern my_bool wsrep_certify_nonPK;
class binlog_trx_data;
......@@ -8142,7 +8142,8 @@ wsrep_calc_row_hash(
ulint col_type;
uint i;
void *ctx = wsrep_md5_init();
void *ctx = alloca(my_md5_context_size());
my_md5_init(ctx);
n_fields = table->s->fields;
......@@ -8191,14 +8192,14 @@ wsrep_calc_row_hash(
*/
if (field->is_null_in_record(row)) {
wsrep_md5_update(ctx, (char*)&null_byte, 1);
my_md5_input(ctx, &null_byte, 1);
} else {
wsrep_md5_update(ctx, (char*)&true_byte, 1);
wsrep_md5_update(ctx, (char*)ptr, len);
my_md5_input(ctx, &true_byte, 1);
my_md5_input(ctx, ptr, len);
}
}
wsrep_compute_md5_hash((char*)digest, ctx);
my_md5_result(ctx, digest);
return(0);
}
......
/*
Copyright (c) 2014 SkySQL AB.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "my_config.h"
#if defined(HAVE_YASSL)
#include "md5.hpp"
#elif defined(HAVE_OPENSSL)
#include <openssl/md5.h>
#endif /* HAVE_YASSL */
#ifdef WITH_WSREP
/* Initialize md5 object. */
void *wsrep_md5_init()
{
#if defined(HAVE_YASSL)
TaoCrypt::MD5 *hasher= new TaoCrypt::MD5;
return (void*)hasher;
#elif defined(HAVE_OPENSSL)
MD5_CTX *ctx = new MD5_CTX();
MD5_Init (ctx);
return (void *)ctx;
#endif /* HAVE_YASSL */
}
/**
Supply message to be hashed.
@param ctx [IN] Pointer to MD5 context
@param buf [IN] Message to be computed.
@param len [IN] Length of the message.
*/
void wsrep_md5_update(void *ctx, char* buf, int len)
{
#if defined(HAVE_YASSL)
((TaoCrypt::MD5 *)ctx)->Update((TaoCrypt::byte *) buf, len);
#elif defined(HAVE_OPENSSL)
MD5_Update((MD5_CTX*)(ctx), buf, len);
#endif /* HAVE_YASSL */
}
/**
Place computed MD5 digest into the given buffer.
@param digest [OUT] Computed MD5 digest
@param ctx [IN] Pointer to MD5 context
*/
void wsrep_compute_md5_hash(char *digest, void *ctx)
{
#if defined(HAVE_YASSL)
((TaoCrypt::MD5*)ctx)->Final((TaoCrypt::byte *) digest);
delete (TaoCrypt::MD5*)ctx;
#elif defined(HAVE_OPENSSL)
MD5_Final ((unsigned char*)digest, (MD5_CTX*)ctx);
delete (MD5_CTX*)ctx;
#endif /* HAVE_YASSL */
}
#endif /* WITH_WSREP */
#ifndef WSREP_MD5_INCLUDED
#define WSREP_MD5_INCLUDED
/* Copyright (c) 2014 SkySQL AB.
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 Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef WITH_WSREP
void *wsrep_md5_init();
void wsrep_md5_update(void *ctx, char* buf, int len);
void wsrep_compute_md5_hash(char *digest, void *ctx);
#endif /* WITH_WSREP */
#endif /* WSREP_MD5_INCLUDED */
......@@ -268,27 +268,6 @@ ENDIF()
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/xtradb/include
${CMAKE_SOURCE_DIR}/storage/xtradb/handler)
IF(WITH_WSREP)
# ssl include directory
INCLUDE_DIRECTORIES(${SSL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/storage/xtradb/wsrep)
IF(SSL_DEFINES)
ADD_DEFINITIONS(${SSL_DEFINES})
ENDIF()
LINK_LIBRARIES(${SSL_LIBRARIES})
# We do RESTRICT_SYMBOL_EXPORTS(yassl) elsewhere.
# In order to get correct symbol visibility, these files
# must be compiled with "-fvisibility=hidden"
IF(WITH_SSL STREQUAL "bundled" AND HAVE_VISIBILITY_HIDDEN)
SET_SOURCE_FILES_PROPERTIES(
{CMAKE_CURRENT_SOURCE_DIR}/wsrep/md5.cc
PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
ENDIF()
ENDIF()
# Sun Studio bug with -xO2
IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro"
AND CMAKE_CXX_FLAGS_RELEASE MATCHES "O2"
......@@ -430,10 +409,6 @@ SET(INNOBASE_SOURCES
ut/ut0wqueue.cc
ut/ut0timer.cc)
IF(WITH_WSREP)
SET(INNOBASE_SOURCES ${INNOBASE_SOURCES} wsrep/md5.cc)
ENDIF()
IF(NOT XTRADB_OK)
MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform")
ENDIF()
......
......@@ -125,7 +125,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include "dict0priv.h"
#include "../storage/innobase/include/ut0byte.h"
#include <wsrep_mysqld.h>
#include <wsrep_md5.h>
#include <mysql/service_md5.h>
extern my_bool wsrep_certify_nonPK;
class binlog_trx_data;
......@@ -8605,7 +8605,8 @@ wsrep_calc_row_hash(
ulint col_type;
uint i;
void *ctx = wsrep_md5_init();
void *ctx = alloca(my_md5_context_size());
my_md5_init(ctx);
n_fields = table->s->fields;
......@@ -8654,14 +8655,14 @@ wsrep_calc_row_hash(
*/
if (field->is_null_in_record(row)) {
wsrep_md5_update(ctx, (char*)&null_byte, 1);
my_md5_input(ctx, &null_byte, 1);
} else {
wsrep_md5_update(ctx, (char*)&true_byte, 1);
wsrep_md5_update(ctx, (char*)ptr, len);
my_md5_input(ctx, &true_byte, 1);
my_md5_input(ctx, ptr, len);
}
}
wsrep_compute_md5_hash((char*)digest, ctx);
my_md5_result(ctx, digest);
return(0);
}
......
/*
Copyright (c) 2014 SkySQL AB.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "my_config.h"
#if defined(HAVE_YASSL)
#include "md5.hpp"
#elif defined(HAVE_OPENSSL)
#include <openssl/md5.h>
#endif /* HAVE_YASSL */
#ifdef WITH_WSREP
/* Initialize md5 object. */
void *wsrep_md5_init()
{
#if defined(HAVE_YASSL)
TaoCrypt::MD5 *hasher= new TaoCrypt::MD5;
return (void*)hasher;
#elif defined(HAVE_OPENSSL)
MD5_CTX *ctx = new MD5_CTX();
MD5_Init (ctx);
return (void *)ctx;
#endif /* HAVE_YASSL */
}
/**
Supply message to be hashed.
@param ctx [IN] Pointer to MD5 context
@param buf [IN] Message to be computed.
@param len [IN] Length of the message.
*/
void wsrep_md5_update(void *ctx, char* buf, int len)
{
#if defined(HAVE_YASSL)
((TaoCrypt::MD5 *)ctx)->Update((TaoCrypt::byte *) buf, len);
#elif defined(HAVE_OPENSSL)
MD5_Update((MD5_CTX*)(ctx), buf, len);
#endif /* HAVE_YASSL */
}
/**
Place computed MD5 digest into the given buffer.
@param digest [OUT] Computed MD5 digest
@param ctx [IN] Pointer to MD5 context
*/
void wsrep_compute_md5_hash(char *digest, void *ctx)
{
#if defined(HAVE_YASSL)
((TaoCrypt::MD5*)ctx)->Final((TaoCrypt::byte *) digest);
delete (TaoCrypt::MD5*)ctx;
#elif defined(HAVE_OPENSSL)
MD5_Final ((unsigned char*)digest, (MD5_CTX*)ctx);
delete (MD5_CTX*)ctx;
#endif /* HAVE_YASSL */
}
#endif /* WITH_WSREP */
#ifndef WSREP_MD5_INCLUDED
#define WSREP_MD5_INCLUDED
/* Copyright (c) 2014 SkySQL AB.
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 Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef WITH_WSREP
void *wsrep_md5_init();
void wsrep_md5_update(void *ctx, char* buf, int len);
void wsrep_compute_md5_hash(char *digest, void *ctx);
#endif /* WITH_WSREP */
#endif /* WSREP_MD5_INCLUDED */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment