• unknown's avatar
    BUG#10589: des_encrypt functionality always return NULL · 2e0ac6d6
    unknown authored
     - Push warnings if des_encrypt or des_descrypt function fails because of out of resources or wrong params.
     - Push warning if des_encrypt or des_decrypt function is used when server is missing support for openssl.
     - Add test func_encrypt_nossl that is tun when the server is missing support for openssl. 
    
    
    mysql-test/r/func_encrypt.result:
      Add tests for use of des_* function with invalid parameters
    mysql-test/t/func_encrypt.test:
      Add tests for use of des_* function with invalid parameters
    sql/item_strfunc.cc:
      Push warning if invalid paremeters are used
      Push warning if out of resources
      Push warning if user tries to use des_* function when the server has been compiled without support for openssl.
    2e0ac6d6
func_encrypt_nossl.test 1.11 KB
-- source include/not_openssl.inc

#
# Test output from des_encrypt and des_decrypt when server is
# compiled without openssl suuport
#
select des_encrypt("test", 'akeystr');
select des_encrypt("test", 1);
select des_encrypt("test", 9);
select des_encrypt("test", 100);
select des_encrypt("test", NULL);
select des_decrypt("test", 'anotherkeystr');
select des_decrypt(1, 1);
select des_decrypt(des_encrypt("test", 'thekey'));


#
# Test default keys
#
select hex(des_encrypt("hello")),des_decrypt(des_encrypt("hello"));
select des_decrypt(des_encrypt("hello",4));
select des_decrypt(des_encrypt("hello",'test'),'test');
select hex(des_encrypt("hello")),hex(des_encrypt("hello",5)),hex(des_encrypt("hello",'default_password'));
select des_decrypt(des_encrypt("hello"),'default_password');
select des_decrypt(des_encrypt("hello",4),'password4');

# Test flush
SET @a=des_decrypt(des_encrypt("hello"));
flush des_key_file;
select @a = des_decrypt(des_encrypt("hello"));

# Test usage of wrong password
select hex("hello");
select hex(des_decrypt(des_encrypt("hello",4),'password2'));
select hex(des_decrypt(des_encrypt("hello","hidden")));