Skip to content

Commit ad0013c

Browse files
committed
MDEV-14343 Server crash on FIPS with openssl-1.0.2k
don't use internal undocumented OpenSSL functionality
1 parent fb24eb8 commit ad0013c

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

mysys_ssl/my_crypt.cc

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <openssl/evp.h>
2727
#include <openssl/aes.h>
2828
#include <openssl/err.h>
29+
#include <openssl/rand.h>
2930

3031
#ifdef HAVE_ERR_remove_thread_state
3132
#define ERR_remove_state(X) ERR_remove_thread_state(NULL)
@@ -292,31 +293,11 @@ unsigned int my_aes_ctx_size(enum my_aes_mode)
292293
return MY_AES_CTX_SIZE;
293294
}
294295

295-
#ifdef HAVE_YASSL
296-
#include <random.hpp>
297-
int my_random_bytes(uchar* buf, int num)
298-
{
299-
TaoCrypt::RandomNumberGenerator rand;
300-
rand.GenerateBlock((TaoCrypt::byte*) buf, num);
301-
return MY_AES_OK;
302-
}
303-
#else
304-
#include <openssl/rand.h>
305-
306296
int my_random_bytes(uchar *buf, int num)
307297
{
308-
/*
309-
Unfortunately RAND_bytes manual page does not provide any guarantees
310-
in relation to blocking behavior. Here we explicitly use SSLeay random
311-
instead of whatever random engine is currently set in OpenSSL. That way
312-
we are guaranteed to have a non-blocking random.
313-
*/
314-
RAND_METHOD *rand = RAND_SSLeay();
315-
if (rand == NULL || rand->bytes(buf, num) != 1)
298+
if (RAND_bytes(buf, num) != 1)
316299
return MY_AES_OPENSSL_ERROR;
317300
return MY_AES_OK;
318301
}
319-
#endif
320302

321303
}
322-

mysys_ssl/yassl.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "aes.hpp"
2727

2828
using yaSSL::yaERR_remove_state;
29+
using yaSSL::yaRAND_bytes;
2930

3031
#define EVP_CIPH_ECB_MODE 0x1
3132
#define EVP_CIPH_CBC_MODE 0x2

0 commit comments

Comments
 (0)