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
ae01e8d2
Commit
ae01e8d2
authored
Jan 18, 2013
by
Martin Storsjö
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
srtp: Add tests for the crypto suite with 32/80 bit HMAC
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
3ef6d22e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
srtp.c
libavformat/srtp.c
+32
-0
srtp
tests/ref/fate/srtp
+4
-0
No files found.
libavformat/srtp.c
View file @
ae01e8d2
...
...
@@ -372,6 +372,29 @@ static const uint8_t rtcp_aes128_32[] = {
0x5b
,
0xd2
,
0xa9
,
0x9d
,
};
static
const
char
*
aes128_80_32_key
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn"
;
static
const
uint8_t
rtp_aes128_80_32
[]
=
{
// RTP header
0x80
,
0xe0
,
0x12
,
0x34
,
0x12
,
0x34
,
0x56
,
0x78
,
0x12
,
0x34
,
0x56
,
0x78
,
// encrypted payload
0x62
,
0x69
,
0x76
,
0xca
,
0xc5
,
// HMAC
0xa1
,
0xac
,
0x1b
,
0xb4
,
};
static
const
uint8_t
rtcp_aes128_80_32
[]
=
{
// RTCP header
0x81
,
0xc9
,
0x00
,
0x07
,
0x12
,
0x34
,
0x56
,
0x78
,
// encrypted payload
0xd6
,
0xae
,
0xc1
,
0x58
,
0x63
,
0x70
,
0xc9
,
0x88
,
0x66
,
0x26
,
0x1c
,
0x53
,
0xff
,
0x5d
,
0x5d
,
0x2b
,
0x0f
,
0x8c
,
0x72
,
0x3e
,
0xc9
,
0x1d
,
0x43
,
0xf9
,
// RTCP index
0x80
,
0x00
,
0x00
,
0x05
,
// HMAC
0x09
,
0x16
,
0xb4
,
0x27
,
0x9a
,
0xe9
,
0x92
,
0x26
,
0x4e
,
0x10
,
};
static
void
print_data
(
const
uint8_t
*
buf
,
int
len
)
{
int
i
;
...
...
@@ -416,6 +439,7 @@ int main(void)
{
static
const
char
*
aes128_80_suite
=
"AES_CM_128_HMAC_SHA1_80"
;
static
const
char
*
aes128_32_suite
=
"AES_CM_128_HMAC_SHA1_32"
;
static
const
char
*
aes128_80_32_suite
=
"SRTP_AES128_CM_HMAC_SHA1_32"
;
static
const
char
*
test_key
=
"abcdefghijklmnopqrstuvwxyz1234567890ABCD"
;
uint8_t
buf
[
1500
];
struct
SRTPContext
srtp
=
{
0
};
...
...
@@ -424,9 +448,11 @@ int main(void)
len
=
test_decrypt
(
&
srtp
,
rtp_aes128_80
,
sizeof
(
rtp_aes128_80
),
buf
);
test_encrypt
(
buf
,
len
,
aes128_80_suite
,
test_key
);
test_encrypt
(
buf
,
len
,
aes128_32_suite
,
test_key
);
test_encrypt
(
buf
,
len
,
aes128_80_32_suite
,
test_key
);
test_decrypt
(
&
srtp
,
rtcp_aes128_80
,
sizeof
(
rtcp_aes128_80
),
buf
);
test_encrypt
(
buf
,
len
,
aes128_80_suite
,
test_key
);
test_encrypt
(
buf
,
len
,
aes128_32_suite
,
test_key
);
test_encrypt
(
buf
,
len
,
aes128_80_32_suite
,
test_key
);
ff_srtp_free
(
&
srtp
);
memset
(
&
srtp
,
0
,
sizeof
(
srtp
));
// Clear the context
...
...
@@ -434,6 +460,12 @@ int main(void)
test_decrypt
(
&
srtp
,
rtp_aes128_32
,
sizeof
(
rtp_aes128_32
),
buf
);
test_decrypt
(
&
srtp
,
rtcp_aes128_32
,
sizeof
(
rtcp_aes128_32
),
buf
);
ff_srtp_free
(
&
srtp
);
memset
(
&
srtp
,
0
,
sizeof
(
srtp
));
// Clear the context
ff_srtp_set_crypto
(
&
srtp
,
aes128_80_32_suite
,
aes128_80_32_key
);
test_decrypt
(
&
srtp
,
rtp_aes128_80_32
,
sizeof
(
rtp_aes128_80_32
),
buf
);
test_decrypt
(
&
srtp
,
rtcp_aes128_80_32
,
sizeof
(
rtcp_aes128_80_32
),
buf
);
ff_srtp_free
(
&
srtp
);
return
0
;
}
#endif
/* TEST */
tests/ref/fate/srtp
View file @
ae01e8d2
80e0123412345678123456780102030405
Decrypted content matches input
Decrypted content matches input
Decrypted content matches input
81c90007123456788765432100000000000012340000069ec73069ba000001fd
Decrypted content matches input
Decrypted content matches input
Decrypted content matches input
80e0123412345678123456780102030405
81c90007123456788765432100000000000012340000069ec73069ba000001fd
80e0123412345678123456780102030405
81c90007123456788765432100000000000012340000069ec73069ba000001fd
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