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
ded4a654
Commit
ded4a654
authored
May 17, 2016
by
Diego Biurrun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xtea-test: Use struct allocation functions from the API
parent
8131bd4c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
xtea.c
libavutil/tests/xtea.c
+14
-10
No files found.
libavutil/tests/xtea.c
View file @
ded4a654
...
...
@@ -22,6 +22,7 @@
#include <string.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/xtea.h"
#define XTEA_NUM_TESTS 6
...
...
@@ -80,41 +81,44 @@ static void test_xtea(AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
int
main
(
void
)
{
AVXTEA
ctx
;
uint8_t
buf
[
16
],
iv
[
8
];
int
i
,
j
;
static
const
uint8_t
src
[
32
]
=
"HelloWorldHelloWorldHelloWorld"
;
uint8_t
ct
[
32
];
uint8_t
pl
[
32
];
AVXTEA
*
ctx
=
av_xtea_alloc
();
if
(
!
ctx
)
return
1
;
for
(
i
=
0
;
i
<
XTEA_NUM_TESTS
;
i
++
)
{
av_xtea_init
(
&
ctx
,
xtea_test_key
[
i
]);
av_xtea_init
(
ctx
,
xtea_test_key
[
i
]);
test_xtea
(
&
ctx
,
buf
,
xtea_test_pt
[
i
],
xtea_test_ct
[
i
],
1
,
NULL
,
0
,
"encryption"
,
av_xtea_crypt
);
test_xtea
(
&
ctx
,
buf
,
xtea_test_ct
[
i
],
xtea_test_pt
[
i
],
1
,
NULL
,
1
,
"decryption"
,
av_xtea_crypt
);
test_xtea
(
ctx
,
buf
,
xtea_test_pt
[
i
],
xtea_test_ct
[
i
],
1
,
NULL
,
0
,
"encryption"
,
av_xtea_crypt
);
test_xtea
(
ctx
,
buf
,
xtea_test_ct
[
i
],
xtea_test_pt
[
i
],
1
,
NULL
,
1
,
"decryption"
,
av_xtea_crypt
);
for
(
j
=
0
;
j
<
4
;
j
++
)
AV_WL32
(
&
buf
[
4
*
j
],
AV_RB32
(
&
xtea_test_key
[
i
][
4
*
j
]));
av_xtea_le_init
(
&
ctx
,
buf
);
av_xtea_le_init
(
ctx
,
buf
);
for
(
j
=
0
;
j
<
2
;
j
++
)
{
AV_WL32
(
&
ct
[
4
*
j
],
AV_RB32
(
&
xtea_test_ct
[
i
][
4
*
j
]));
AV_WL32
(
&
pl
[
4
*
j
],
AV_RB32
(
&
xtea_test_pt
[
i
][
4
*
j
]));
}
test_xtea
(
&
ctx
,
buf
,
pl
,
ct
,
1
,
NULL
,
0
,
"encryption"
,
av_xtea_le_crypt
);
test_xtea
(
&
ctx
,
buf
,
ct
,
pl
,
1
,
NULL
,
1
,
"decryption"
,
av_xtea_le_crypt
);
test_xtea
(
ctx
,
buf
,
pl
,
ct
,
1
,
NULL
,
0
,
"encryption"
,
av_xtea_le_crypt
);
test_xtea
(
ctx
,
buf
,
ct
,
pl
,
1
,
NULL
,
1
,
"decryption"
,
av_xtea_le_crypt
);
/* encrypt */
memcpy
(
iv
,
"HALLO123"
,
8
);
av_xtea_crypt
(
&
ctx
,
ct
,
src
,
4
,
iv
,
0
);
av_xtea_crypt
(
ctx
,
ct
,
src
,
4
,
iv
,
0
);
/* decrypt into pl */
memcpy
(
iv
,
"HALLO123"
,
8
);
test_xtea
(
&
ctx
,
pl
,
ct
,
src
,
4
,
iv
,
1
,
"CBC decryption"
,
av_xtea_crypt
);
test_xtea
(
ctx
,
pl
,
ct
,
src
,
4
,
iv
,
1
,
"CBC decryption"
,
av_xtea_crypt
);
memcpy
(
iv
,
"HALLO123"
,
8
);
test_xtea
(
&
ctx
,
ct
,
ct
,
src
,
4
,
iv
,
1
,
"CBC inplace decryption"
,
av_xtea_crypt
);
test_xtea
(
ctx
,
ct
,
ct
,
src
,
4
,
iv
,
1
,
"CBC inplace decryption"
,
av_xtea_crypt
);
}
printf
(
"Test encryption/decryption success.
\n
"
);
av_free
(
ctx
);
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