Skip to content

Commit

Permalink
MDEV-8482 mysql-test - main.func_encrypt fails if FIPS=1
Browse files Browse the repository at this point in the history
* check for openssl errors in DES_ENCRYPT/DES_DECRYPT
* disable the test when DES doesn't work
* also disable main.func_des_encrypt
  • Loading branch information
vuvova committed Apr 24, 2016
1 parent 906f97d commit 797cadc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions mysql-test/include/have_des.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# in the FIPS mode, OpenSSL disables DES and other weak algorithms
source include/have_ssl_crypto_functs.inc;

if (`select des_encrypt("a", "b") IS NULL`) {
skip DES is disabled (fips mode?);
}
2 changes: 1 addition & 1 deletion mysql-test/t/func_des_encrypt.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- source include/have_ssl_crypto_functs.inc
-- source include/have_des.inc

# This test can't be in func_encrypt.test, because it requires
# --des-key-file to not be set.
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/t/func_encrypt.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- source include/have_ssl_crypto_functs.inc
-- source include/have_des.inc

--disable_warnings
drop table if exists t1;
Expand Down
10 changes: 6 additions & 4 deletions sql/item_strfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,10 @@ String *Item_func_des_encrypt::val_str(String *str)

/* We make good 24-byte (168 bit) key from given plaintext key with MD5 */
bzero((char*) &ivec,sizeof(ivec));
EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL,
if (!EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL,
(uchar*) keystr->ptr(), (int) keystr->length(),
1, (uchar*) &keyblock,ivec);
1, (uchar*) &keyblock,ivec))
goto error;
DES_set_key_unchecked(&keyblock.key1,&keyschedule.ks1);
DES_set_key_unchecked(&keyblock.key2,&keyschedule.ks2);
DES_set_key_unchecked(&keyblock.key3,&keyschedule.ks3);
Expand Down Expand Up @@ -921,9 +922,10 @@ String *Item_func_des_decrypt::val_str(String *str)
goto error;

bzero((char*) &ivec,sizeof(ivec));
EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL,
if (!EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL,
(uchar*) keystr->ptr(),(int) keystr->length(),
1,(uchar*) &keyblock,ivec);
1,(uchar*) &keyblock,ivec))
goto error;
// Here we set all 64-bit keys (56 effective) one by one
DES_set_key_unchecked(&keyblock.key1,&keyschedule.ks1);
DES_set_key_unchecked(&keyblock.key2,&keyschedule.ks2);
Expand Down

0 comments on commit 797cadc

Please sign in to comment.