]> git.sesse.net Git - vlc/commitdiff
Maintain the SRTCP index
authorRémi Denis-Courmont <rem@videolan.org>
Sat, 10 Mar 2007 20:08:33 +0000 (20:08 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 10 Mar 2007 20:08:33 +0000 (20:08 +0000)
This is not very useful at the moment, but will be needed for proper
replay attack protection

libs/srtp/srtp.c

index f60147bfa6c0dcdabda9b5ea160787ff83168c82..c9414374a42b63db0a3b605a74fbc02657372355 100644 (file)
@@ -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);
 }