Skip to content

Commit

Permalink
srtp: rework formating
Browse files Browse the repository at this point in the history
  • Loading branch information
cHuberCoffee committed Mar 25, 2024
1 parent 7f78d3e commit 6c481c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
19 changes: 8 additions & 11 deletions modules/srtp/srtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,15 @@ static int start_crypto(struct menc_st *st, const struct pl *key_info)
}

/* receiving key-info changed -> reset srtp_rx */
if (st->srtp_rx && memcmp(st->key_rx, new_key,
if (st->srtp_rx && mem_seccmp(st->key_rx, new_key,
sizeof(st->key_rx) > olen ? olen : sizeof(st->key_rx))) {
info("srtp: %s: re-keying in progress\n",
stream_name(st->strm));
st->srtp_rx = mem_deref(st->srtp_rx);
}

memcpy(st->key_rx, new_key, olen);
mem_secclean(new_key, olen);
new_key = mem_deref(new_key);

err = start_srtp(st, st->crypto_suite);
Expand Down Expand Up @@ -492,17 +493,17 @@ static int media_alloc(struct menc_media **stp, struct menc_sess *sess,
}


static int cmd_tx_rekey(struct re_printf *pf, void *arg) {
static int cmd_tx_rekey(struct re_printf *pf, void *arg)
{
const struct cmd_arg *carg = arg;
struct call *selcall = NULL;
int err = 0;

if (!str_isset(carg->prm)) {
re_hprintf(pf, "usage: /srtprekey <call id>");
return EINVAL;
}

selcall = uag_call_find(carg->prm);
struct call *selcall = uag_call_find(carg->prm);
if (!selcall) {
re_hprintf(pf, "srtprekey: call id \"%s\" not found\n",
carg->prm);
Expand All @@ -512,13 +513,9 @@ static int cmd_tx_rekey(struct re_printf *pf, void *arg) {
re_hprintf(pf, "srtprekey: rekey srtp transmission keys of"
" call \"%s\"\n", carg->prm);

struct stream *astrm = audio_strm(call_audio(selcall));
struct stream *vstrm = video_strm(call_video(selcall));

if (astrm)
stream_remove_menc_media(astrm);
if (vstrm)
stream_remove_menc_media(vstrm);
struct le *le;
for (le = call_streaml(selcall)->head; le; le = le->next)
stream_remove_menc_media(le->data);

err = call_update_media(selcall);
err |= call_modify(selcall);
Expand Down
7 changes: 6 additions & 1 deletion test/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -3089,7 +3089,7 @@ static bool sdp_crypto_handler(const char *name, const char *value, void*arg)
if (err)
return false;

return pl_strdup(key, &key_info) ? false : true;
return 0 == pl_strdup(key, &key_info);
}


Expand All @@ -3115,6 +3115,11 @@ int test_call_srtp_tx_rekey(void)
char *b_rx_key_new = NULL, *b_tx_key_new = NULL;
int err = 0;

if (!cmd_resp)
err = ENOMEM;

TEST_ERR(err);

err = module_load(".", "srtp");
err |= module_load(".", "ausine");
TEST_ERR(err);
Expand Down

0 comments on commit 6c481c3

Please sign in to comment.