Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
3130fa51
Commit
3130fa51
authored
12 years ago
by
Martin Storsjö
Browse files
Options
Downloads
Patches
Plain Diff
lavu: Add a fate test for the HMAC API
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
fb845ffd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
libavutil/Makefile
+1
-0
1 addition, 0 deletions
libavutil/Makefile
libavutil/hmac.c
+48
-0
48 additions, 0 deletions
libavutil/hmac.c
tests/fate/libavutil.mak
+4
-0
4 additions, 0 deletions
tests/fate/libavutil.mak
tests/ref/fate/hmac
+6
-0
6 additions, 0 deletions
tests/ref/fate/hmac
with
59 additions
and
0 deletions
libavutil/Makefile
+
1
−
0
View file @
3130fa51
...
@@ -108,6 +108,7 @@ TESTPROGS = adler32 \
...
@@ -108,6 +108,7 @@ TESTPROGS = adler32 \
des
\
des
\
eval
\
eval
\
fifo
\
fifo
\
hmac
\
lfg
\
lfg
\
lls
\
lls
\
md5
\
md5
\
...
...
This diff is collapsed.
Click to expand it.
libavutil/hmac.c
+
48
−
0
View file @
3130fa51
...
@@ -136,3 +136,51 @@ int av_hmac_calc(AVHMAC *c, const uint8_t *data, unsigned int len,
...
@@ -136,3 +136,51 @@ int av_hmac_calc(AVHMAC *c, const uint8_t *data, unsigned int len,
av_hmac_update
(
c
,
data
,
len
);
av_hmac_update
(
c
,
data
,
len
);
return
av_hmac_final
(
c
,
out
,
outlen
);
return
av_hmac_final
(
c
,
out
,
outlen
);
}
}
#ifdef TEST
#include
<stdio.h>
static
void
test
(
AVHMAC
*
hmac
,
const
uint8_t
*
key
,
int
keylen
,
const
uint8_t
*
data
,
int
datalen
)
{
uint8_t
buf
[
MAX_HASHLEN
];
int
out
,
i
;
// Some of the test vectors are strings, where sizeof() includes the
// trailing null byte - remove that.
if
(
!
key
[
keylen
-
1
])
keylen
--
;
if
(
!
data
[
datalen
-
1
])
datalen
--
;
out
=
av_hmac_calc
(
hmac
,
data
,
datalen
,
key
,
keylen
,
buf
,
sizeof
(
buf
));
for
(
i
=
0
;
i
<
out
;
i
++
)
printf
(
"%02x"
,
buf
[
i
]);
printf
(
"
\n
"
);
}
int
main
(
void
)
{
uint8_t
key1
[
16
],
key3
[
16
],
data3
[
50
],
key4
[
63
],
key5
[
64
],
key6
[
65
];
const
uint8_t
key2
[]
=
"Jefe"
;
const
uint8_t
data1
[]
=
"Hi There"
;
const
uint8_t
data2
[]
=
"what do ya want for nothing?"
;
AVHMAC
*
hmac
=
av_hmac_alloc
(
AV_HMAC_MD5
);
if
(
!
hmac
)
return
1
;
memset
(
key1
,
0x0b
,
sizeof
(
key1
));
memset
(
key3
,
0xaa
,
sizeof
(
key3
));
memset
(
key4
,
0x44
,
sizeof
(
key4
));
memset
(
key5
,
0x55
,
sizeof
(
key5
));
memset
(
key6
,
0x66
,
sizeof
(
key6
));
memset
(
data3
,
0xdd
,
sizeof
(
data3
));
// RFC 2104 test vectors
test
(
hmac
,
key1
,
sizeof
(
key1
),
data1
,
sizeof
(
data1
));
test
(
hmac
,
key2
,
sizeof
(
key2
),
data2
,
sizeof
(
data2
));
test
(
hmac
,
key3
,
sizeof
(
key3
),
data3
,
sizeof
(
data3
));
// Additional tests, to test cases where the key is too long
test
(
hmac
,
key4
,
sizeof
(
key4
),
data1
,
sizeof
(
data1
));
test
(
hmac
,
key5
,
sizeof
(
key5
),
data2
,
sizeof
(
data2
));
test
(
hmac
,
key6
,
sizeof
(
key6
),
data3
,
sizeof
(
data3
));
av_hmac_free
(
hmac
);
return
0
;
}
#endif
/* TEST */
This diff is collapsed.
Click to expand it.
tests/fate/libavutil.mak
+
4
−
0
View file @
3130fa51
...
@@ -37,6 +37,10 @@ FATE_LIBAVUTIL += fate-fifo
...
@@ -37,6 +37,10 @@ FATE_LIBAVUTIL += fate-fifo
fate-fifo
:
libavutil/fifo-test$(EXESUF)
fate-fifo
:
libavutil/fifo-test$(EXESUF)
fate-fifo
:
CMD = run libavutil/fifo-test
fate-fifo
:
CMD = run libavutil/fifo-test
FATE_LIBAVUTIL
+=
fate-hmac
fate-hmac
:
libavutil/hmac-test$(EXESUF)
fate-hmac
:
CMD = run libavutil/hmac-test
FATE_LIBAVUTIL
+=
fate-md5
FATE_LIBAVUTIL
+=
fate-md5
fate-md5
:
libavutil/md5-test$(EXESUF)
fate-md5
:
libavutil/md5-test$(EXESUF)
fate-md5
:
CMD = run libavutil/md5-test
fate-md5
:
CMD = run libavutil/md5-test
...
...
This diff is collapsed.
Click to expand it.
tests/ref/fate/hmac
0 → 100644
+
6
−
0
View file @
3130fa51
9294727a3638bb1c13f48ef8158bfc9d
750c783e6ab0b503eaa86e310a5db738
56be34521d144c88dbb8c733f0e8b3f6
467cb2560355d7fa3ab2d6b939e6e47c
5a6ffd741d3e23b12f78b1baee9e609a
8b4b9d11c9e186c58f2a53b08ddfa436
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment