- const uint8_t *tag = rtp_digest (s, buf, len);
- memcpy (buf + len, tag, s->tag_len);
- *lenp = len + s->tag_len;
+ uint32_t roc = srtp_compute_roc (s, rtp_seq (buf));
+ const uint8_t *tag = rtp_digest (s, buf, len, roc);
+ if (rcc_mode (s))
+ {
+ assert (s->rtp_rcc);
+ if ((rtp_seq (buf) % s->rtp_rcc) == 0)
+ {
+ memcpy (buf + len, &(uint32_t){ htonl (s->rtp_roc) }, 4);
+ len += 4;
+ if (rcc_mode (s) == 3)
+ tag_len = 0;
+ else
+ tag_len -= 4;
+ }
+ else
+ {
+ if (rcc_mode (s) & 1)
+ tag_len = 0;
+ }
+ }
+ memcpy (buf + len, tag, tag_len);