aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-21 15:18:57 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-21 15:18:57 +0100
commit2cf9ab655549cf2f25ba57ee84baa6d38530ec3b (patch)
treeae0a70dc008a9dfccd0b313f6888665662c048a0 /libavformat
parent248140f8a2a6a00a668f59607791d24244a8ff50 (diff)
parent8a4f26206d7914eaf2903954ce97cb7686933382 (diff)
downloadffmpeg-2cf9ab655549cf2f25ba57ee84baa6d38530ec3b.tar.gz
Merge commit '8a4f26206d7914eaf2903954ce97cb7686933382'
* commit '8a4f26206d7914eaf2903954ce97cb7686933382': dsputil: remove butterflies_float_interleave. srtp: Move a variable to a local scope srtp: Add tests for the crypto suite with 32/80 bit HMAC Conflicts: libavcodec/x86/dsputil.asm libavcodec/x86/dsputil_mmx.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/srtp.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/libavformat/srtp.c b/libavformat/srtp.c
index a93d03d539..65309d0763 100644
--- a/libavformat/srtp.c
+++ b/libavformat/srtp.c
@@ -126,7 +126,7 @@ int ff_srtp_decrypt(struct SRTPContext *s, uint8_t *buf, int *lenptr)
{
uint8_t iv[16] = { 0 }, hmac[20];
int len = *lenptr;
- int ext, av_uninit(seq_largest);
+ int av_uninit(seq_largest);
uint32_t ssrc, av_uninit(roc);
uint64_t index;
int rtcp, hmac_size;
@@ -199,7 +199,7 @@ int ff_srtp_decrypt(struct SRTPContext *s, uint8_t *buf, int *lenptr)
if (!(srtcp_index & 0x80000000))
return 0;
} else {
- int csrc;
+ int ext, csrc;
s->seq_initialized = 1;
s->seq_largest = seq_largest;
s->roc = roc;
@@ -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 */