diff options
Diffstat (limited to 'mysys_ssl')
-rw-r--r-- | mysys_ssl/my_crypt.cc | 25 |
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++) |