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
8827eb83
Commit
8827eb83
authored
May 14, 2015
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-8162 func_str crashes on SELECT AES_DECRYPT(AES_ENCRYPT(...)) on line 107
encrypting 0 byte string *is* possible
parent
8258a348
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
23 deletions
+24
-23
mysys_ssl/my_crypt.cc
mysys_ssl/my_crypt.cc
+24
-23
No files found.
mysys_ssl/my_crypt.cc
View file @
8827eb83
...
@@ -71,8 +71,6 @@ static int block_crypt(CipherMode cipher, Dir dir,
...
@@ -71,8 +71,6 @@ static int block_crypt(CipherMode cipher, Dir dir,
{
{
int
tail
=
source_length
%
MY_AES_BLOCK_SIZE
;
int
tail
=
source_length
%
MY_AES_BLOCK_SIZE
;
DBUG_ASSERT
(
source_length
);
if
(
likely
(
source_length
>=
MY_AES_BLOCK_SIZE
||
!
no_padding
))
if
(
likely
(
source_length
>=
MY_AES_BLOCK_SIZE
||
!
no_padding
))
{
{
#ifdef HAVE_YASSL
#ifdef HAVE_YASSL
...
@@ -139,28 +137,31 @@ static int block_crypt(CipherMode cipher, Dir dir,
...
@@ -139,28 +137,31 @@ static int block_crypt(CipherMode cipher, Dir dir,
#endif
#endif
}
}
if
(
no_padding
&&
tail
)
if
(
no_padding
)
{
{
/*
if
(
tail
)
Not much we can do, block ciphers cannot encrypt data that aren't
{
a multiple of the block length. At least not without padding.
/*
Let's do something CTR-like for the last partial block.
Not much we can do, block ciphers cannot encrypt data that aren't
*/
a multiple of the block length. At least not without padding.
Let's do something CTR-like for the last partial block.
uchar
mask
[
MY_AES_BLOCK_SIZE
];
*/
uint
mlen
;
uchar
mask
[
MY_AES_BLOCK_SIZE
];
DBUG_ASSERT
(
iv_length
>=
sizeof
(
mask
));
uint
mlen
;
my_aes_encrypt_ecb
(
iv
,
sizeof
(
mask
),
mask
,
&
mlen
,
key
,
key_length
,
0
,
0
,
1
);
DBUG_ASSERT
(
iv_length
>=
sizeof
(
mask
));
DBUG_ASSERT
(
mlen
==
sizeof
(
mask
));
my_aes_encrypt_ecb
(
iv
,
sizeof
(
mask
),
mask
,
&
mlen
,
key
,
key_length
,
0
,
0
,
1
);
const
uchar
*
s
=
source
+
source_length
-
tail
;
DBUG_ASSERT
(
mlen
==
sizeof
(
mask
));
const
uchar
*
e
=
source
+
source_length
;
uchar
*
d
=
dest
+
source_length
-
tail
;
const
uchar
*
s
=
source
+
source_length
-
tail
;
const
uchar
*
m
=
mask
;
const
uchar
*
e
=
source
+
source_length
;
while
(
s
<
e
)
uchar
*
d
=
dest
+
source_length
-
tail
;
*
d
++
=
*
s
++
^
*
m
++
;
const
uchar
*
m
=
mask
;
while
(
s
<
e
)
*
d
++
=
*
s
++
^
*
m
++
;
}
*
dest_length
=
source_length
;
*
dest_length
=
source_length
;
}
}
...
...
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