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
0cc9a64b
Commit
0cc9a64b
authored
Oct 01, 2012
by
Martin Storsjö
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blowfish: Factorize testing into a separate function
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
51a15ed7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
blowfish.c
libavutil/blowfish.c
+21
-11
No files found.
libavutil/blowfish.c
View file @
0cc9a64b
...
...
@@ -522,6 +522,25 @@ static const uint8_t ciphertext[8] = {
0x32
,
0x4E
,
0xD0
,
0xFE
,
0xF4
,
0x13
,
0xA2
,
0x03
};
#undef exit
static
void
test_blowfish
(
AVBlowfish
*
ctx
,
uint8_t
*
dst
,
const
uint8_t
*
src
,
const
uint8_t
*
ref
,
int
len
,
uint8_t
*
iv
,
int
dir
,
const
char
*
test
)
{
av_blowfish_crypt
(
ctx
,
dst
,
src
,
len
,
iv
,
dir
);
if
(
memcmp
(
dst
,
ref
,
8
*
len
))
{
int
i
;
printf
(
"%s failed
\n
got "
,
test
);
for
(
i
=
0
;
i
<
8
*
len
;
i
++
)
printf
(
"%02x "
,
dst
[
i
]);
printf
(
"
\n
expected "
);
for
(
i
=
0
;
i
<
8
*
len
;
i
++
)
printf
(
"%02x "
,
ref
[
i
]);
printf
(
"
\n
"
);
exit
(
1
);
}
}
int
main
(
void
)
{
AVBlowfish
ctx
;
...
...
@@ -532,17 +551,8 @@ int main(void)
av_blowfish_init
(
&
ctx
,
"abcdefghijklmnopqrstuvwxyz"
,
26
);
av_blowfish_crypt
(
&
ctx
,
tmp
,
plaintext
,
1
,
NULL
,
0
);
if
(
memcmp
(
tmp
,
ciphertext
,
8
))
{
printf
(
"Test encryption failed.
\n
"
);
return
1
;
}
av_blowfish_crypt
(
&
ctx
,
tmp
,
ciphertext
,
1
,
NULL
,
1
);
if
(
memcmp
(
tmp
,
plaintext
,
8
))
{
printf
(
"Test decryption failed.
\n
"
);
return
1
;
}
test_blowfish
(
&
ctx
,
tmp
,
plaintext
,
ciphertext
,
1
,
NULL
,
0
,
"encryption"
);
test_blowfish
(
&
ctx
,
tmp
,
ciphertext
,
plaintext
,
1
,
NULL
,
1
,
"decryption"
);
memcpy
(
tmptext_l
,
plaintext_l
,
sizeof
(
*
plaintext_l
)
*
NUM_VARIABLE_KEY_TESTS
);
memcpy
(
tmptext_r
,
plaintext_r
,
sizeof
(
*
plaintext_r
)
*
NUM_VARIABLE_KEY_TESTS
);
...
...
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