From bc3995754809bc4df48c06033289c23381a703ab Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 17 Jun 2013 09:22:29 -0400 Subject: [PATCH] remember the crypto "tag" value for the SDP answer --- daemon/crypto.h | 1 + daemon/sdp.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/daemon/crypto.h b/daemon/crypto.h index a9dca4598..168dc003d 100644 --- a/daemon/crypto.h +++ b/daemon/crypto.h @@ -65,6 +65,7 @@ struct crypto_context { char master_salt[14]; u_int64_t mki; unsigned int mki_len; + unsigned int tag; /* from rfc 3711 */ u_int32_t roc; diff --git a/daemon/sdp.c b/daemon/sdp.c index 281b74241..6f1ee70fd 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -327,6 +327,10 @@ static int parse_attribute_crypto(struct sdp_attribute *output) { c = &output->u.crypto; + c->tag = strtoul(c->tag_str.s, NULL, 10); + if (!c->tag) + return -1; + c->crypto_suite = crypto_find_suite(&c->crypto_suite_str); if (!c->crypto_suite) return -1; @@ -760,6 +764,7 @@ int sdp_streams(const GQueue *sessions, GQueue *streams, GHashTable *streamhash, cctx.crypto_suite = attr->u.crypto.crypto_suite; cctx.mki = attr->u.crypto.mki; cctx.mki_len = attr->u.crypto.mki_len; + cctx.tag = attr->u.crypto.tag; assert(sizeof(cctx.master_key) >= attr->u.crypto.master_key.len); assert(sizeof(cctx.master_salt) >= attr->u.crypto.salt.len); memcpy(cctx.master_key, attr->u.crypto.master_key.s, attr->u.crypto.master_key.len); @@ -1301,6 +1306,9 @@ static int generate_crypto(struct sdp_media *media, struct sdp_ng_flags *flags, random_string((unsigned char *) c->master_salt, c->crypto_suite->master_salt_len / 8); /* mki = mki_len = 0 */ + c->tag = rtp->crypto.in.tag; + if (!c->tag) + c->tag++; } mutex_unlock(&rtp->up->up->lock); @@ -1319,16 +1327,20 @@ static int generate_crypto(struct sdp_media *media, struct sdp_ng_flags *flags, mutex_lock(&rtcp->up->up->lock); + src = c; c = &rtcp->crypto.out; - c->crypto_suite = rtp->crypto.out.crypto_suite; - memcpy(c->master_key, rtp->crypto.out.master_key, + + c->crypto_suite = src->crypto_suite; + c->tag = src->tag; + memcpy(c->master_key, src->master_key, c->crypto_suite->master_key_len / 8); - memcpy(c->master_salt, rtp->crypto.out.master_salt, + memcpy(c->master_salt, src->master_salt, c->crypto_suite->master_salt_len / 8); mutex_unlock(&rtcp->up->up->lock); - chopper_append_c(chop, "a=crypto:1 "); + chopper_append_c(chop, "a=crypto:"); + chopper_append_printf(chop, "%u ", c->tag); chopper_append_c(chop, c->crypto_suite->name); chopper_append_c(chop, " inline:"); chopper_append_dup(chop, b64_buf, p - b64_buf);