summaryrefslogtreecommitdiff
path: root/mysys_ssl
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2019-06-04 10:07:39 +0200
committerVladislav Vaintroub <wlad@mariadb.com>2019-06-04 10:07:39 +0200
commitc5beac68472ed2020c12d078031b8c35ed5d7cb5 (patch)
treea73afaf565c0aa8484766f2ea85d5e9bdebff43c /mysys_ssl
parent92df31dfbfcf6068f4f4a7e7794a15333158c569 (diff)
downloadmariadb-git-c5beac68472ed2020c12d078031b8c35ed5d7cb5.tar.gz
MDEV-19684 enable intel assembly (AESNI etc) and fastmath when compiling WolfSSL
Using different recommended speedup options for WolfSSL. - Enable x64 assembly code on Intel. - in my_crypt.cc, align EVP_CIPHER_CTX buffer, since some members need alignment of 16 (for AESNI instructions), when assembler is enabled. - Adjust MY_AES_CTX_SIZE - Enable fastmath in wolfssl (large integer math).
Diffstat (limited to 'mysys_ssl')
-rw-r--r--mysys_ssl/my_crypt.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/mysys_ssl/my_crypt.cc b/mysys_ssl/my_crypt.cc
index a668c222b79..fda909e6530 100644
--- a/mysys_ssl/my_crypt.cc
+++ b/mysys_ssl/my_crypt.cc
@@ -25,16 +25,28 @@
#include <my_crypt.h>
#include <ssl_compat.h>
+#include <cstdint>
+
+#ifdef HAVE_WOLFSSL
+#define CTX_ALIGN 16
+#else
+#define CTX_ALIGN 0
+#endif
class MyCTX
{
public:
- char ctx_buf[EVP_CIPHER_CTX_SIZE];
- EVP_CIPHER_CTX *ctx;
-
+ char ctx_buf[EVP_CIPHER_CTX_SIZE + CTX_ALIGN];
+ EVP_CIPHER_CTX* ctx;
MyCTX()
{
- ctx= (EVP_CIPHER_CTX *)ctx_buf;
+#if CTX_ALIGN > 0
+ uintptr_t p= ((uintptr_t)ctx_buf + (CTX_ALIGN - 1)) & ~(CTX_ALIGN - 1);
+ ctx = reinterpret_cast<EVP_CIPHER_CTX*>(p);
+#else
+ ctx = (EVP_CIPHER_CTX*)ctx_buf;
+#endif
+
EVP_CIPHER_CTX_init(ctx);
}
virtual ~MyCTX()
@@ -149,8 +161,11 @@ public:
uchar mask[MY_AES_BLOCK_SIZE];
uint mlen;
- my_aes_crypt(MY_AES_ECB, ENCRYPTION_FLAG_ENCRYPT | ENCRYPTION_FLAG_NOPAD,
+ int rc= my_aes_crypt(MY_AES_ECB, ENCRYPTION_FLAG_ENCRYPT | ENCRYPTION_FLAG_NOPAD,
oiv, sizeof(mask), mask, &mlen, key, klen, 0, 0);
+ DBUG_ASSERT(rc == MY_AES_OK);
+ if (rc)
+ return rc;
DBUG_ASSERT(mlen == sizeof(mask));
for (uint i=0; i < buf_len; i++)