summaryrefslogtreecommitdiff
path: root/mysys_ssl
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-04-01 22:15:11 +0200
committerSergei Golubchik <serg@mariadb.org>2015-04-09 18:42:44 +0200
commit4d40a7d133b1e5a3241ec673721687158e235be0 (patch)
tree0e434bd7789a09ef39cf52389b0b9bb80ad08add /mysys_ssl
parent65e782607031721b22397010bd7be57bbd5f6439 (diff)
downloadmariadb-git-4d40a7d133b1e5a3241ec673721687158e235be0.tar.gz
remove now-empty my_aes.{h,cc}
move remaning defines to my_crypt, add MY_ namespace prefix
Diffstat (limited to 'mysys_ssl')
-rw-r--r--mysys_ssl/CMakeLists.txt1
-rw-r--r--mysys_ssl/my_aes.cc40
-rw-r--r--mysys_ssl/my_crypt.cc39
3 files changed, 28 insertions, 52 deletions
diff --git a/mysys_ssl/CMakeLists.txt b/mysys_ssl/CMakeLists.txt
index 5eead8d6aaf..8a8f81d70ae 100644
--- a/mysys_ssl/CMakeLists.txt
+++ b/mysys_ssl/CMakeLists.txt
@@ -33,7 +33,6 @@ IF(WITH_SSL STREQUAL "bundled" AND HAVE_VISIBILITY_HIDDEN)
ENDIF()
SET(MYSYS_SSL_SOURCES
- my_aes.cc
my_sha1.cc
my_sha2.cc
my_md5.cc
diff --git a/mysys_ssl/my_aes.cc b/mysys_ssl/my_aes.cc
deleted file mode 100644
index 069d8d74ab2..00000000000
--- a/mysys_ssl/my_aes.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Copyright (c) 2002, 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
-
-#include <my_global.h>
-#include <m_string.h>
-#include <my_aes.h>
-#include <my_crypt.h>
-
-/**
- Initialize encryption methods
-*/
-
-/**
- Get size of buffer which will be large enough for encrypted data
-
- SYNOPSIS
- my_aes_get_size()
- @param source_length [in] Length of data to be encrypted
-
- @return
- Size of buffer required to store encrypted data
-*/
-
-int my_aes_get_size(int source_length)
-{
- return MY_AES_BLOCK_SIZE * (source_length / MY_AES_BLOCK_SIZE)
- + MY_AES_BLOCK_SIZE;
-}
diff --git a/mysys_ssl/my_crypt.cc b/mysys_ssl/my_crypt.cc
index 1709ae5e5eb..3bb8f860c37 100644
--- a/mysys_ssl/my_crypt.cc
+++ b/mysys_ssl/my_crypt.cc
@@ -78,7 +78,7 @@ static int do_crypt(CipherMode cipher, Dir dir,
TaoCrypt::AES ctx(dir, cipher);
if (unlikely(key_length != 16 && key_length != 24 && key_length != 32))
- return AES_BAD_KEYSIZE;
+ return MY_AES_BAD_KEYSIZE;
ctx.SetKey(key, key_length);
if (iv)
@@ -106,7 +106,7 @@ static int do_crypt(CipherMode cipher, Dir dir,
{
int n= dest[source_length - 1];
if (tail || n == 0 || n > MY_AES_BLOCK_SIZE)
- return AES_OPENSSL_ERROR;
+ return MY_AES_BAD_DATA;
*dest_length-= n;
}
}
@@ -116,10 +116,10 @@ static int do_crypt(CipherMode cipher, Dir dir,
struct MyCTX ctx;
if (unlikely(!cipher))
- return AES_BAD_KEYSIZE;
+ return MY_AES_BAD_KEYSIZE;
if (!EVP_CipherInit_ex(&ctx, cipher, NULL, key, iv, dir))
- return AES_OPENSSL_ERROR;
+ return MY_AES_OPENSSL_ERROR;
EVP_CIPHER_CTX_set_padding(&ctx, !no_padding);
@@ -130,9 +130,9 @@ static int do_crypt(CipherMode cipher, Dir dir,
/* use built-in OpenSSL padding, if possible */
if (!EVP_CipherUpdate(&ctx, dest, (int*)dest_length,
source, source_length - (no_padding ? tail : 0)))
- return AES_OPENSSL_ERROR;
+ return MY_AES_OPENSSL_ERROR;
if (!EVP_CipherFinal_ex(&ctx, dest + *dest_length, &fin))
- return AES_OPENSSL_ERROR;
+ return MY_AES_BAD_DATA;
*dest_length += fin;
#endif
@@ -146,7 +146,7 @@ static int do_crypt(CipherMode cipher, Dir dir,
*/
if (unlikely(source_length < MY_AES_BLOCK_SIZE))
- return AES_OPENSSL_ERROR;
+ return MY_AES_BAD_DATA;
const uchar *s= source + source_length - tail;
const uchar *e= source + source_length;
@@ -157,7 +157,7 @@ static int do_crypt(CipherMode cipher, Dir dir,
*dest_length= source_length;
}
- return AES_OK;
+ return MY_AES_OK;
}
C_MODE_START
@@ -240,7 +240,7 @@ int my_random_bytes(uchar* buf, int num)
{
TaoCrypt::RandomNumberGenerator rand;
rand.GenerateBlock((TaoCrypt::byte*) buf, num);
- return AES_OK;
+ return MY_AES_OK;
}
C_MODE_END
@@ -261,9 +261,26 @@ int my_random_bytes(uchar* buf, int num)
*/
RAND_METHOD* rand = RAND_SSLeay();
if (rand == NULL || rand->bytes(buf, num) != 1)
- return AES_OPENSSL_ERROR;
- return AES_OK;
+ return MY_AES_OPENSSL_ERROR;
+ return MY_AES_OK;
}
C_MODE_END
#endif /* HAVE_YASSL */
+
+/**
+ Get size of buffer which will be large enough for encrypted data
+
+ SYNOPSIS
+ my_aes_get_size()
+ @param source_length [in] Length of data to be encrypted
+
+ @return
+ Size of buffer required to store encrypted data
+*/
+
+int my_aes_get_size(int source_length)
+{
+ return MY_AES_BLOCK_SIZE * (source_length / MY_AES_BLOCK_SIZE)
+ + MY_AES_BLOCK_SIZE;
+}