]> git.sesse.net Git - vlc/blobdiff - libs/srtp/srtp.c
Fix hashing when using RFC4711
[vlc] / libs / srtp / srtp.c
index efc434fdd8983c2697fcc5e67d73b4fa447f6630..60c07b6f72bfa0b7e25eecef27fed0c5aa292ded 100644 (file)
@@ -208,7 +208,7 @@ srtp_create (int encr, int auth, unsigned tag_len, int prf, unsigned flags)
             return NULL;
     }
 
-    if (tag_len > gcry_md_get_algo_dlen (auth))
+    if (tag_len > gcry_md_get_algo_dlen (md))
         return NULL;
 
     if (prf != SRTP_PRF_AES_CM)
@@ -331,6 +331,7 @@ srtp_derive (srtp_session_t *s, const void *key, size_t keylen,
      || gcry_cipher_setkey (prf, key, keylen))
         return -1;
 
+#if 0
     /* RTP key derivation */
     if (s->kdr != 0)
     {
@@ -344,6 +345,7 @@ srtp_derive (srtp_session_t *s, const void *key, size_t keylen,
         }
     }
     else
+#endif
         memset (r, 0, sizeof (r));
 
     if (proto_derive (&s->rtp, prf, salt, saltlen, r, 6, false))
@@ -649,7 +651,16 @@ srtp_recv (srtp_session_t *s, uint8_t *buf, size_t *lenp)
             rcc = roc;
 
         const uint8_t *tag = rtp_digest (s, buf, len, rcc);
-        if (memcmp (buf + len + roc_len, tag, s->tag_len))
+#if 0
+        printf ("Computed: 0x");
+        for (unsigned i = 0; i < tag_len; i++)
+            printf ("%02x", tag[i]);
+        printf ("\nReceived: 0x");
+        for (unsigned i = 0; i < tag_len; i++)
+            printf ("%02x", buf[len + roc_len + i]);
+        puts ("");
+#endif
+        if (memcmp (buf + len + roc_len, tag, tag_len))
             return EACCES;
 
         if (roc_len)