summaryrefslogtreecommitdiff
path: root/libavformat/srtp.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-21 15:07:04 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-21 15:07:07 +0100
commit248140f8a2a6a00a668f59607791d24244a8ff50 (patch)
tree05ff31e54795cc5040a58f769470864ced286a62 /libavformat/srtp.c
parentbc639dbd9b835622b2b0713f24cacbdbf464d065 (diff)
parent3ef6d22e1ba544ab37c73e8fc61382f13aac250f (diff)
Merge commit '3ef6d22e1ba544ab37c73e8fc61382f13aac250f'
* commit '3ef6d22e1ba544ab37c73e8fc61382f13aac250f': srtp: cosmetics: Use fewer lines for the test vectors srtp: Don't require more input data than what actually is needed Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/srtp.c')
-rw-r--r--libavformat/srtp.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/libavformat/srtp.c b/libavformat/srtp.c
index 1f068d4c9c..a93d03d539 100644
--- a/libavformat/srtp.c
+++ b/libavformat/srtp.c
@@ -243,8 +243,8 @@ int ff_srtp_encrypt(struct SRTPContext *s, const uint8_t *in, int len,
int rtcp, hmac_size, padding;
uint8_t *buf;
- if (len < 12)
- return 0;
+ if (len < 8)
+ return AVERROR_INVALIDDATA;
rtcp = RTP_PT_IS_RTCP(in[1]);
hmac_size = rtcp ? s->rtcp_hmac_size : s->rtp_hmac_size;
@@ -267,6 +267,10 @@ int ff_srtp_encrypt(struct SRTPContext *s, const uint8_t *in, int len,
} else {
int ext, csrc;
int seq = AV_RB16(buf + 2);
+
+ if (len < 12)
+ return AVERROR_INVALIDDATA;
+
ssrc = AV_RB32(buf + 8);
if (seq < s->seq_largest)
@@ -326,9 +330,7 @@ static const char *aes128_80_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn";
static const uint8_t rtp_aes128_80[] = {
// RTP header
- 0x80, 0xe0, 0x12, 0x34,
- 0x12, 0x34, 0x56, 0x78,
- 0x12, 0x34, 0x56, 0x78,
+ 0x80, 0xe0, 0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78,
// encrypted payload
0x62, 0x69, 0x76, 0xca, 0xc5,
// HMAC
@@ -337,15 +339,10 @@ static const uint8_t rtp_aes128_80[] = {
static const uint8_t rtcp_aes128_80[] = {
// RTCP header
- 0x81, 0xc9, 0x00, 0x07,
- 0x12, 0x34, 0x56, 0x78,
+ 0x81, 0xc9, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78,
// encrypted payload
- 0x8a, 0xac, 0xdc, 0xa5,
- 0x4c, 0xf6, 0x78, 0xa6,
- 0x62, 0x8f, 0x24, 0xda,
- 0x6c, 0x09, 0x3f, 0xa9,
- 0x28, 0x7a, 0xb5, 0x7f,
- 0x1f, 0x0f, 0xc9, 0x35,
+ 0x8a, 0xac, 0xdc, 0xa5, 0x4c, 0xf6, 0x78, 0xa6, 0x62, 0x8f, 0x24, 0xda,
+ 0x6c, 0x09, 0x3f, 0xa9, 0x28, 0x7a, 0xb5, 0x7f, 0x1f, 0x0f, 0xc9, 0x35,
// RTCP index
0x80, 0x00, 0x00, 0x03,
// HMAC
@@ -356,9 +353,7 @@ static const char *aes128_32_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn";
static const uint8_t rtp_aes128_32[] = {
// RTP header
- 0x80, 0xe0, 0x12, 0x34,
- 0x12, 0x34, 0x56, 0x78,
- 0x12, 0x34, 0x56, 0x78,
+ 0x80, 0xe0, 0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78,
// encrypted payload
0x62, 0x69, 0x76, 0xca, 0xc5,
// HMAC
@@ -367,15 +362,10 @@ static const uint8_t rtp_aes128_32[] = {
static const uint8_t rtcp_aes128_32[] = {
// RTCP header
- 0x81, 0xc9, 0x00, 0x07,
- 0x12, 0x34, 0x56, 0x78,
+ 0x81, 0xc9, 0x00, 0x07, 0x12, 0x34, 0x56, 0x78,
// encrypted payload
- 0x35, 0xe9, 0xb5, 0xff,
- 0x0d, 0xd1, 0xde, 0x70,
- 0x74, 0x10, 0xaa, 0x1b,
- 0xb2, 0x8d, 0xf0, 0x20,
- 0x02, 0x99, 0x6b, 0x1b,
- 0x0b, 0xd0, 0x47, 0x34,
+ 0x35, 0xe9, 0xb5, 0xff, 0x0d, 0xd1, 0xde, 0x70, 0x74, 0x10, 0xaa, 0x1b,
+ 0xb2, 0x8d, 0xf0, 0x20, 0x02, 0x99, 0x6b, 0x1b, 0x0b, 0xd0, 0x47, 0x34,
// RTCP index
0x80, 0x00, 0x00, 0x04,
// HMAC