Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
b4345004
Commit
b4345004
authored
Sep 30, 2012
by
Michael Niedermayer
Committed by
Martin Storsjö
Oct 03, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xtea: Fix CBC decryption when src==dst
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
ca074cc3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
xtea.c
libavutil/xtea.c
+9
-10
No files found.
libavutil/xtea.c
View file @
b4345004
...
...
@@ -36,7 +36,7 @@ void av_xtea_init(AVXTEA *ctx, const uint8_t key[16])
}
static
void
xtea_crypt_ecb
(
AVXTEA
*
ctx
,
uint8_t
*
dst
,
const
uint8_t
*
src
,
int
decrypt
)
int
decrypt
,
uint8_t
*
iv
)
{
uint32_t
v0
,
v1
;
int
i
;
...
...
@@ -52,6 +52,11 @@ static void xtea_crypt_ecb(AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
sum
-=
delta
;
v0
-=
(((
v1
<<
4
)
^
(
v1
>>
5
))
+
v1
)
^
(
sum
+
ctx
->
key
[
sum
&
3
]);
}
if
(
iv
)
{
v0
^=
AV_RB32
(
iv
);
v1
^=
AV_RB32
(
iv
+
4
);
memcpy
(
iv
,
src
,
8
);
}
}
else
{
uint32_t
sum
=
0
,
delta
=
0x9E3779B9
;
...
...
@@ -73,13 +78,7 @@ void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
if
(
decrypt
)
{
while
(
count
--
)
{
xtea_crypt_ecb
(
ctx
,
dst
,
src
,
decrypt
);
if
(
iv
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
dst
[
i
]
=
dst
[
i
]
^
iv
[
i
];
memcpy
(
iv
,
src
,
8
);
}
xtea_crypt_ecb
(
ctx
,
dst
,
src
,
decrypt
,
iv
);
src
+=
8
;
dst
+=
8
;
...
...
@@ -89,10 +88,10 @@ void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
if
(
iv
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
dst
[
i
]
=
src
[
i
]
^
iv
[
i
];
xtea_crypt_ecb
(
ctx
,
dst
,
dst
,
decrypt
);
xtea_crypt_ecb
(
ctx
,
dst
,
dst
,
decrypt
,
NULL
);
memcpy
(
iv
,
dst
,
8
);
}
else
{
xtea_crypt_ecb
(
ctx
,
dst
,
src
,
decrypt
);
xtea_crypt_ecb
(
ctx
,
dst
,
src
,
decrypt
,
NULL
);
}
src
+=
8
;
dst
+=
8
;
...
...
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