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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
98595620
Commit
98595620
authored
Dec 13, 2001
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge work:/home/bk/mysql-4.0 into hundin.mysql.fi:/my/bk/mysql-4.0
parents
b656c048
1ad683a4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
31 deletions
+35
-31
sql/Makefile.am
sql/Makefile.am
+1
-1
sql/des_key_file.cc
sql/des_key_file.cc
+4
-4
sql/item_strfunc.cc
sql/item_strfunc.cc
+21
-17
sql/lex.h
sql/lex.h
+2
-2
sql/mysql_priv.h
sql/mysql_priv.h
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+6
-6
No files found.
sql/Makefile.am
View file @
98595620
...
...
@@ -56,7 +56,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
sql_select.h structs.h table.h sql_udf.h hash_filo.h
\
lex.h lex_symbol.h sql_acl.h sql_crypt.h
\
log_event.h mini_client.h sql_repl.h slave.h
\
stacktrace.h sql_sort.h
stacktrace.h sql_sort.h
sql_cache.h
mysqld_SOURCES
=
sql_lex.cc sql_handler.cc
\
item.cc item_sum.cc item_buff.cc item_func.cc
\
item_cmpfunc.cc item_strfunc.cc item_timefunc.cc
\
...
...
sql/des_key_file.cc
View file @
98595620
...
...
@@ -25,7 +25,7 @@
*/
struct
st_des_keyschedule
des_keyschedule
[
10
];
uint
default_des
_key
;
uint
des_default
_key
;
void
load_des_key_file
(
const
char
*
file_name
)
...
...
@@ -43,7 +43,7 @@ load_des_key_file(const char *file_name)
goto
error
;
bzero
((
char
*
)
des_keyschedule
,
sizeof
(
struct
st_des_keyschedule
)
*
10
);
de
fault_des
_key
=
15
;
// Impossible key
de
s_default
_key
=
15
;
// Impossible key
for
(;;)
{
char
*
start
,
*
end
;
...
...
@@ -72,8 +72,8 @@ load_des_key_file(const char *file_name)
des_set_key_unchecked
(
&
keyblock
.
key1
,
des_keyschedule
[(
int
)
offset
].
ks1
);
des_set_key_unchecked
(
&
keyblock
.
key2
,
des_keyschedule
[(
int
)
offset
].
ks2
);
des_set_key_unchecked
(
&
keyblock
.
key3
,
des_keyschedule
[(
int
)
offset
].
ks3
);
if
(
de
fault_des
_key
==
15
)
de
fault_des
_key
=
(
uint
)
offset
;
// use first as def.
if
(
de
s_default
_key
==
15
)
de
s_default
_key
=
(
uint
)
offset
;
// use first as def.
}
}
else
...
...
sql/item_strfunc.cc
View file @
98595620
...
...
@@ -221,8 +221,9 @@ String *Item_func_des_encrypt::val_str(String *str)
des_cblock
ivec
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
struct
st_des_keyblock
keyblock
;
struct
st_des_keyschedule
keyschedule
;
struct
st_des_keyschedule
*
keyschedule_ptr
=&
keyschedule
;
uint
key_number
=
15
;
struct
st_des_keyschedule
*
keyschedule_ptr
;
const
char
*
append_str
=
"********"
;
uint
key_number
,
res_length
,
tail
;
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
((
null_value
=
args
[
0
]
->
null_value
))
...
...
@@ -231,23 +232,24 @@ String *Item_func_des_encrypt::val_str(String *str)
return
&
empty_string
;
if
(
arg_count
==
1
)
keyschedule_ptr
=
des_keyschedule
[
key_number
=
default_des
_key
];
else
if
(
args
[
1
]
->
result_type
==
INT_RESULT
)
keyschedule_ptr
=
&
des_keyschedule
[
key_number
=
des_default
_key
];
else
if
(
args
[
1
]
->
result_type
()
==
INT_RESULT
)
{
key_number
=
(
uint
)
args
[
1
]
->
val_int
();
if
(
key_number
>
9
)
goto
error
;
keyschedule_ptr
=
des_keyschedule
[
key_number
];
keyschedule_ptr
=
&
des_keyschedule
[
key_number
];
}
else
{
const
char
*
append_str
=
"********"
;
uint
tail
,
res_length
;
String
*
keystr
=
args
[
1
]
->
val_str
(
&
tmp_value
);
if
(
!
keystr
)
goto
error
;
key_number
=
15
;
// User key string
/* We make good 24-byte (168 bit) key from given plaintext key with MD5 */
keyschedule_ptr
=
&
keyschedule
;
EVP_BytesToKey
(
EVP_des_ede3_cbc
(),
EVP_md5
(),
NULL
,
(
uchar
*
)
keystr
->
ptr
(),
(
int
)
keystr
->
length
(),
1
,
(
uchar
*
)
&
keyblock
,
ivec
);
...
...
@@ -268,13 +270,13 @@ String *Item_func_des_encrypt::val_str(String *str)
tail
=
(
7
-
(
res
->
length
()
+
7
)
%
8
);
// 0..7 marking extra length
res_length
=
res
->
length
()
+
tail
+
1
;
if
(
tail
&&
res
->
append
(
append_str
,
tail
)
||
tmp_value
.
alloc
(
res_length
))
goto
err
;
goto
err
or
;
tmp_value
.
length
(
res_length
);
tmp_value
.
[
0
]
=
(
char
)
(
128
|
tail
<<
4
|
key_number
);
tmp_value
[
0
]
=
(
char
)
(
128
|
tail
<<
4
|
key_number
);
// Real encryption
des_ede3_cbc_encrypt
((
const
uchar
*
)
(
res
->
ptr
()),
(
uchar
*
)
(
tmp_value
->
ptr
()
+
1
),
(
uchar
*
)
(
tmp_value
.
ptr
()
+
1
),
res
->
length
(),
keyschedule_ptr
->
ks1
,
keyschedule_ptr
->
ks2
,
...
...
@@ -296,28 +298,30 @@ String *Item_func_des_decrypt::val_str(String *str)
des_cblock
ivec
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
struct
st_des_keyblock
keyblock
;
struct
st_des_keyschedule
keyschedule
;
struct
st_des_keyschedule
*
keyschedule_ptr
=&
keyschedule
;
struct
st_des_keyschedule
*
keyschedule_ptr
;
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
if
(
res
->
length
(
0
)
<
9
||
(
res
->
length
())
%
8
!=
1
||
!
(
res
->
[
0
]
&
128
))
if
(
res
->
length
(
)
<
9
||
(
res
->
length
()
%
8
)
!=
1
||
!
((
*
res
)
[
0
]
&
128
))
return
res
;
// Skip decryption if not encrypted
if
(
arg_count
==
1
)
// If automatic uncompression
{
uint
key_number
=
res
->
[
0
]
&
15
;
uint
key_number
=
(
uint
)
(
*
res
)
[
0
]
&
15
;
// Check if automatic key and that we have privilege to uncompress using it
if
(
!
(
current_thd
->
master_access
&
PROCESS_ACL
)
||
key_number
>
9
)
goto
error
;
keyschedule_ptr
=
des_keyschedule
[
key_number
-
1
];
keyschedule_ptr
=
&
des_keyschedule
[
key_number
];
}
else
{
// We make good 24-byte (168 bit) key from given plaintext key with MD5
String
*
keystr
=
args
[
1
]
->
val_str
(
&
tmp_value
);
if
(
!
key
_
str
)
if
(
!
keystr
)
goto
error
;
keyschedule_ptr
=
&
keyschedule
;
EVP_BytesToKey
(
EVP_des_ede3_cbc
(),
EVP_md5
(),
NULL
,
(
uchar
*
)
keystr
->
ptr
(),(
int
)
keystr
->
length
(),
1
,(
uchar
*
)
&
keyblock
,
ivec
);
...
...
@@ -327,11 +331,11 @@ String *Item_func_des_decrypt::val_str(String *str)
des_set_key_unchecked
(
&
keyblock
.
key3
,
keyschedule_ptr
->
ks3
);
}
if
(
tmp_value
.
alloc
(
res
->
length
()
-
1
))
goto
err
;
goto
err
or
;
/* Restore old length of key */
tmp_value
.
length
(
res
->
length
()
-
1
-
(((
uchar
)
res
->
[
0
]
>>
4
)
&
7
));
tmp_value
.
length
(
res
->
length
()
-
1
-
(((
uchar
)
(
*
res
)
[
0
]
>>
4
)
&
7
));
des_ede3_cbc_encrypt
((
const
uchar
*
)
res
->
ptr
()
+
1
,
(
uchar
*
)
(
tmp_value
->
ptr
()),
(
uchar
*
)
(
tmp_value
.
ptr
()),
res
->
length
()
-
1
,
keyschedule_ptr
->
ks1
,
keyschedule_ptr
->
ks2
,
...
...
sql/lex.h
View file @
98595620
...
...
@@ -412,8 +412,8 @@ static SYMBOL sql_functions[] = {
{
"DAYOFYEAR"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_dayofyear
)},
{
"DECODE"
,
SYM
(
DECODE_SYM
),
0
,
0
},
{
"DEGREES"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_degrees
)},
{
"DES_ENCRYPT"
,
SYM
(
DES_ENCRYPT
),
0
,
0
},
{
"DES_DECRYPT"
,
SYM
(
DES_DECRYPT
),
0
,
0
},
{
"DES_ENCRYPT"
,
SYM
(
DES_ENCRYPT
_SYM
),
0
,
0
},
{
"DES_DECRYPT"
,
SYM
(
DES_DECRYPT
_SYM
),
0
,
0
},
{
"ELT"
,
SYM
(
ELT_FUNC
),
0
,
0
},
{
"ENCODE"
,
SYM
(
ENCODE_SYM
),
0
,
0
},
{
"ENCRYPT"
,
SYM
(
ENCRYPT
),
0
,
0
},
...
...
sql/mysql_priv.h
View file @
98595620
...
...
@@ -405,7 +405,7 @@ struct st_des_keyschedule
{
des_key_schedule
ks1
,
ks2
,
ks3
;
};
extern
struct
st_des_keyschedule
des_keyschedule
[
9
];
extern
struct
st_des_keyschedule
des_keyschedule
[
10
];
extern
uint
des_default_key
;
void
load_des_key_file
(
const
char
*
file_name
);
#endif
/* HAVE_OPENSSL */
...
...
sql/sql_yacc.yy
View file @
98595620
...
...
@@ -382,8 +382,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token DAY_SECOND_SYM
%token DAY_SYM
%token DECODE_SYM
%token DES_ENCRYPT
%token DES_DECRYPT
%token DES_ENCRYPT
_SYM
%token DES_DECRYPT
_SYM
%token ELSE
%token ELT_FUNC
%token ENCODE_SYM
...
...
@@ -1647,13 +1647,13 @@ simple_expr:
{ $$= new Item_func_decode($3,$5.str); }
| ENCODE_SYM '(' expr ',' TEXT_STRING ')'
{ $$= new Item_func_encode($3,$5.str); }
| DES_DECRYPT '(' expr ')'
| DES_DECRYPT
_SYM
'(' expr ')'
{ $$= new Item_func_des_decrypt($3); }
| DES_DECRYPT '(' expr ',' expr ')'
| DES_DECRYPT
_SYM
'(' expr ',' expr ')'
{ $$= new Item_func_des_decrypt($3,$5); }
| DES_ENCRYPT '(' expr ')'
| DES_ENCRYPT
_SYM
'(' expr ')'
{ $$= new Item_func_des_encrypt($3); }
| DES_ENCRYPT '(' expr ',' expr ')'
| DES_ENCRYPT
_SYM
'(' expr ',' expr ')'
{ $$= new Item_func_des_encrypt($3,$5); }
| EXPORT_SET '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_export_set($3, $5, $7); }
...
...
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