From 5c09dbbad9c76ea76d7060b0fee10b7d3c8abb3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 10 Mar 2007 20:08:33 +0000 Subject: [PATCH] Maintain the SRTCP index This is not very useful at the moment, but will be needed for proper replay attack protection --- libs/srtp/srtp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/srtp/srtp.c b/libs/srtp/srtp.c index f60147bfa6..c9414374a4 100644 --- a/libs/srtp/srtp.c +++ b/libs/srtp/srtp.c @@ -651,6 +651,7 @@ srtcp_send (srtp_session_t *s, uint8_t *buf, size_t *lenp, size_t bufsize) const uint8_t *tag = rtcp_digest (s->rtp.mac, buf, len); memcpy (buf + len, tag, s->tag_len); *lenp = len + s->tag_len; + s->rtcp_index++; /* Update index */ return 0; } @@ -682,8 +683,13 @@ srtcp_recv (srtp_session_t *s, uint8_t *buf, size_t *lenp) return EACCES; len -= 4; /* Remove SRTCP index before decryption */ - *lenp = len; + uint32_t index; + memcpy (&index, buf + len, 4); + index = ntohl (index); + if (((index - s->rtcp_index) & 0xffffffff) < 0x80000000) + s->rtcp_index = index; /* Update index */ + *lenp = len; return srtp_crypt (s, buf, len); } -- 2.39.2