diff --git a/daemon/call.c b/daemon/call.c index 54de3542d..5f6c19c7d 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -359,7 +359,7 @@ static int __k_srtp_crypt(struct mediaproxy_srtp *s, struct crypto_context *c) { .hmac = c->crypto_suite->kernel_hmac, .mki = c->mki, .mki_len = c->mki_len, - .last_index = c->s_l, + .last_index = c->last_index, .auth_tag_len = c->crypto_suite->srtp_auth_tag, }; memcpy(s->master_key, c->master_key, c->crypto_suite->master_key_len); @@ -1071,13 +1071,13 @@ static void callmaster_timer(void *ptr) { update = 0; if (sr->other->crypto.out.crypto_suite - && ke->target.encrypt.last_index - sr->other->crypto.out.s_l > 0x4000) { - sr->other->crypto.out.s_l = ke->target.encrypt.last_index; + && ke->target.encrypt.last_index - sr->other->crypto.out.last_index > 0x4000) { + sr->other->crypto.out.last_index = ke->target.encrypt.last_index; update = 1; } if (sr->crypto.in.crypto_suite - && ke->target.decrypt.last_index - sr->crypto.in.s_l > 0x4000) { - sr->crypto.in.s_l = ke->target.decrypt.last_index; + && ke->target.decrypt.last_index - sr->crypto.in.last_index > 0x4000) { + sr->crypto.in.last_index = ke->target.decrypt.last_index; update = 1; } diff --git a/daemon/crypto.h b/daemon/crypto.h index 4e5a2aef1..280484643 100644 --- a/daemon/crypto.h +++ b/daemon/crypto.h @@ -55,9 +55,7 @@ struct crypto_context { unsigned int mki_len; unsigned int tag; - /* from rfc 3711 */ - u_int32_t roc; - u_int64_t s_l; + u_int64_t last_index; /* XXX replay list */ /* ? */ diff --git a/daemon/rtcp.c b/daemon/rtcp.c index 446c9e442..0eea8efc1 100644 --- a/daemon/rtcp.c +++ b/daemon/rtcp.c @@ -395,11 +395,11 @@ int rtcp_avp2savp(str *s, struct crypto_context *c) { if (check_session_keys(c)) return -1; - if (crypto_encrypt_rtcp(c, rtcp, &payload, c->s_l)) + if (crypto_encrypt_rtcp(c, rtcp, &payload, c->last_index)) return -1; idx = (void *) s->s + s->len; - *idx = htonl(0x80000000ULL | c->s_l++); + *idx = htonl(0x80000000ULL | c->last_index++); s->len += sizeof(*idx); to_auth = *s; diff --git a/daemon/rtp.c b/daemon/rtp.c index a3ce49901..9fb088f36 100644 --- a/daemon/rtp.c +++ b/daemon/rtp.c @@ -96,15 +96,15 @@ static u_int64_t packet_index(struct crypto_context *c, struct rtp_header *rtp) seq = ntohs(rtp->seq_num); /* rfc 3711 section 3.3.1 */ - if (G_UNLIKELY(!c->s_l)) - c->s_l = seq; + if (G_UNLIKELY(!c->last_index)) + c->last_index = seq; /* rfc 3711 appendix A, modified, and sections 3.3 and 3.3.1 */ - index = ((u_int64_t) c->roc << 16) | seq; - diff = index - c->s_l; + index = (c->last_index & 0xffffffff0000ULL) | seq; + diff = index - c->last_index; if (diff >= 0) { if (diff < 0x8000) - c->s_l = index; + c->last_index = index; else if (index >= 0x10000) index -= 0x10000; } @@ -113,8 +113,7 @@ static u_int64_t packet_index(struct crypto_context *c, struct rtp_header *rtp) ; else { index += 0x10000; - c->roc++; - c->s_l = index; + c->last_index = index; } }