Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
61a3e16b
Commit
61a3e16b
authored
Jun 22, 2005
by
msvensson@neptunus.(none)
Browse files
Options
Browse Files
Download
Plain Diff
Merge neptunus.(none):/home/msvensson/mysql/mysql-4.1
into neptunus.(none):/home/msvensson/mysql/bug10589
parents
ddeaf342
daba295d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
229 additions
and
3 deletions
+229
-3
mysql-test/include/not_openssl.inc
mysql-test/include/not_openssl.inc
+4
-0
mysql-test/r/func_encrypt.result
mysql-test/r/func_encrypt.result
+56
-0
mysql-test/r/func_encrypt_nossl.result
mysql-test/r/func_encrypt_nossl.result
+93
-0
mysql-test/r/not_openssl.require
mysql-test/r/not_openssl.require
+2
-0
mysql-test/t/func_encrypt.test
mysql-test/t/func_encrypt.test
+16
-0
mysql-test/t/func_encrypt_nossl.test
mysql-test/t/func_encrypt_nossl.test
+36
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+22
-3
No files found.
mysql-test/include/not_openssl.inc
0 → 100644
View file @
61a3e16b
--
require
r
/
not_openssl
.
require
disable_query_log
;
show
variables
like
"have_openssl"
;
enable_query_log
;
mysql-test/r/func_encrypt.result
View file @
61a3e16b
...
...
@@ -120,6 +120,60 @@ hello
select des_decrypt(des_encrypt("hello",4),'password4');
des_decrypt(des_encrypt("hello",4),'password4')
hello
select des_encrypt("hello",10);
des_encrypt("hello",10)
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(NULL);
des_encrypt(NULL)
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(NULL, 10);
des_encrypt(NULL, 10)
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(NULL, NULL);
des_encrypt(NULL, NULL)
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt(10, NULL);
des_encrypt(10, NULL)
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_encrypt("hello", NULL);
des_encrypt("hello", NULL)
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_encrypt'
select des_decrypt("hello",10);
des_decrypt("hello",10)
hello
select des_decrypt(NULL);
des_decrypt(NULL)
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_decrypt'
select des_decrypt(NULL, 10);
des_decrypt(NULL, 10)
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_decrypt'
select des_decrypt(NULL, NULL);
des_decrypt(NULL, NULL)
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_decrypt'
select des_decrypt(10, NULL);
des_decrypt(10, NULL)
10
select des_decrypt("hello", NULL);
des_decrypt("hello", NULL)
hello
SET @a=des_decrypt(des_encrypt("hello"));
flush des_key_file;
select @a = des_decrypt(des_encrypt("hello"));
...
...
@@ -134,6 +188,8 @@ NULL
select hex(des_decrypt(des_encrypt("hello","hidden")));
hex(des_decrypt(des_encrypt("hello","hidden")))
NULL
Warnings:
Error 1108 Incorrect parameters to procedure 'des_decrypt'
explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_decrypt(des_encrypt("hello","hidden"));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
...
...
mysql-test/r/func_encrypt_nossl.result
0 → 100644
View file @
61a3e16b
select des_encrypt("test", 'akeystr');
des_encrypt("test", 'akeystr')
NULL
Warnings:
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_encrypt("test", 1);
des_encrypt("test", 1)
NULL
Warnings:
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_encrypt("test", 9);
des_encrypt("test", 9)
NULL
Warnings:
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_encrypt("test", 100);
des_encrypt("test", 100)
NULL
Warnings:
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_encrypt("test", NULL);
des_encrypt("test", NULL)
NULL
Warnings:
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_decrypt("test", 'anotherkeystr');
des_decrypt("test", 'anotherkeystr')
NULL
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_decrypt(1, 1);
des_decrypt(1, 1)
NULL
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_decrypt(des_encrypt("test", 'thekey'));
des_decrypt(des_encrypt("test", 'thekey'))
NULL
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select hex(des_encrypt("hello")),des_decrypt(des_encrypt("hello"));
hex(des_encrypt("hello")) des_decrypt(des_encrypt("hello"))
NULL NULL
Warnings:
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_decrypt(des_encrypt("hello",4));
des_decrypt(des_encrypt("hello",4))
NULL
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_decrypt(des_encrypt("hello",'test'),'test');
des_decrypt(des_encrypt("hello",'test'),'test')
NULL
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select hex(des_encrypt("hello")),hex(des_encrypt("hello",5)),hex(des_encrypt("hello",'default_password'));
hex(des_encrypt("hello")) hex(des_encrypt("hello",5)) hex(des_encrypt("hello",'default_password'))
NULL NULL NULL
Warnings:
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
Error 1289 The 'des_encrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_decrypt(des_encrypt("hello"),'default_password');
des_decrypt(des_encrypt("hello"),'default_password')
NULL
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select des_decrypt(des_encrypt("hello",4),'password4');
des_decrypt(des_encrypt("hello",4),'password4')
NULL
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
SET @a=des_decrypt(des_encrypt("hello"));
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
flush des_key_file;
select @a = des_decrypt(des_encrypt("hello"));
@a = des_decrypt(des_encrypt("hello"))
NULL
select hex("hello");
hex("hello")
68656C6C6F
select hex(des_decrypt(des_encrypt("hello",4),'password2'));
hex(des_decrypt(des_encrypt("hello",4),'password2'))
NULL
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
select hex(des_decrypt(des_encrypt("hello","hidden")));
hex(des_decrypt(des_encrypt("hello","hidden")))
NULL
Warnings:
Error 1289 The 'des_decrypt' feature is disabled; you need MySQL built with '--with-openssl' to have it working
mysql-test/r/not_openssl.require
0 → 100644
View file @
61a3e16b
Variable_name Value
have_openssl NO
mysql-test/t/func_encrypt.test
View file @
61a3e16b
...
...
@@ -59,6 +59,22 @@ select hex(des_encrypt("hello")),hex(des_encrypt("hello",5)),hex(des_encrypt("he
select
des_decrypt
(
des_encrypt
(
"hello"
),
'default_password'
);
select
des_decrypt
(
des_encrypt
(
"hello"
,
4
),
'password4'
);
# Test use of invalid parameters
select
des_encrypt
(
"hello"
,
10
);
select
des_encrypt
(
NULL
);
select
des_encrypt
(
NULL
,
10
);
select
des_encrypt
(
NULL
,
NULL
);
select
des_encrypt
(
10
,
NULL
);
select
des_encrypt
(
"hello"
,
NULL
);
select
des_decrypt
(
"hello"
,
10
);
select
des_decrypt
(
NULL
);
select
des_decrypt
(
NULL
,
10
);
select
des_decrypt
(
NULL
,
NULL
);
select
des_decrypt
(
10
,
NULL
);
select
des_decrypt
(
"hello"
,
NULL
);
# Test flush
SET
@
a
=
des_decrypt
(
des_encrypt
(
"hello"
));
flush
des_key_file
;
...
...
mysql-test/t/func_encrypt_nossl.test
0 → 100644
View file @
61a3e16b
--
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"
)));
sql/item_strfunc.cc
View file @
61a3e16b
...
...
@@ -373,6 +373,7 @@ String *Item_func_des_encrypt::val_str(String *str)
{
DBUG_ASSERT
(
fixed
==
1
);
#ifdef HAVE_OPENSSL
uint
code
=
ER_WRONG_PARAMETERS_TO_PROCEDURE
;
DES_cblock
ivec
;
struct
st_des_keyblock
keyblock
;
struct
st_des_keyschedule
keyschedule
;
...
...
@@ -381,7 +382,7 @@ String *Item_func_des_encrypt::val_str(String *str)
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
goto
error
;
if
((
res_length
=
res
->
length
())
==
0
)
return
&
my_empty_string
;
...
...
@@ -429,6 +430,7 @@ String *Item_func_des_encrypt::val_str(String *str)
tail
=
(
8
-
(
res_length
)
%
8
);
// 1..8 marking extra length
res_length
+=
tail
;
code
=
ER_OUT_OF_RESOURCES
;
if
(
tail
&&
res
->
append
(
append_str
,
tail
)
||
tmp_value
.
alloc
(
res_length
+
1
))
goto
error
;
(
*
res
)[
res_length
-
1
]
=
tail
;
// save extra length
...
...
@@ -446,6 +448,13 @@ String *Item_func_des_encrypt::val_str(String *str)
return
&
tmp_value
;
error:
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_ERROR
,
code
,
ER
(
code
),
"des_encrypt"
);
#else
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_ERROR
,
ER_FEATURE_DISABLED
,
ER
(
ER_FEATURE_DISABLED
),
"des_encrypt"
,
"--with-openssl"
);
#endif
/* HAVE_OPENSSL */
null_value
=
1
;
return
0
;
...
...
@@ -456,6 +465,7 @@ String *Item_func_des_decrypt::val_str(String *str)
{
DBUG_ASSERT
(
fixed
==
1
);
#ifdef HAVE_OPENSSL
uint
code
=
ER_WRONG_PARAMETERS_TO_PROCEDURE
;
DES_key_schedule
ks1
,
ks2
,
ks3
;
DES_cblock
ivec
;
struct
st_des_keyblock
keyblock
;
...
...
@@ -464,7 +474,7 @@ String *Item_func_des_decrypt::val_str(String *str)
uint
length
=
res
->
length
(),
tail
;
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
goto
error
;
length
=
res
->
length
();
if
(
length
<
9
||
(
length
%
8
)
!=
1
||
!
((
*
res
)[
0
]
&
128
))
return
res
;
// Skip decryption if not encrypted
...
...
@@ -495,6 +505,7 @@ String *Item_func_des_decrypt::val_str(String *str)
DES_set_key_unchecked
(
&
keyblock
.
key2
,
&
keyschedule
.
ks2
);
DES_set_key_unchecked
(
&
keyblock
.
key3
,
&
keyschedule
.
ks3
);
}
code
=
ER_OUT_OF_RESOURCES
;
if
(
tmp_value
.
alloc
(
length
-
1
))
goto
error
;
...
...
@@ -508,11 +519,19 @@ String *Item_func_des_decrypt::val_str(String *str)
&
ivec
,
FALSE
);
/* Restore old length of key */
if
((
tail
=
(
uint
)
(
uchar
)
tmp_value
[
length
-
2
])
>
8
)
goto
error
;
// Wrong key
goto
wrong_key
;
// Wrong key
tmp_value
.
length
(
length
-
1
-
tail
);
return
&
tmp_value
;
error:
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_ERROR
,
code
,
ER
(
code
),
"des_decrypt"
);
wrong_key:
#else
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_ERROR
,
ER_FEATURE_DISABLED
,
ER
(
ER_FEATURE_DISABLED
),
"des_decrypt"
,
"--with-openssl"
);
#endif
/* HAVE_OPENSSL */
null_value
=
1
;
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment