Use SRTP attribute specified on SDP when starting SRTP-SDES transport (#2609)
* - use SRTP attribute specified on SDP when starting SRTP-SDES transport. * Check for only key changes on SDP and compare it to the SRTP settings. * check and change the crypto key on sdes_media_start(). * Move check for the answerer side to the original place.
This commit is contained in:
parent
974cb47351
commit
6e62517a4e
|
@ -647,11 +647,39 @@ static pj_status_t sdes_media_start( pjmedia_transport *tp,
|
|||
srtp->peer_use = PJMEDIA_SRTP_OPTIONAL;
|
||||
}
|
||||
|
||||
/* For answerer side, this function will just have to start SRTP as
|
||||
* SRTP crypto policies have been populated in media_encode_sdp().
|
||||
/* For answerer side, SRTP crypto policies have been populated in
|
||||
* media_encode_sdp(). Check if the key changes on the local SDP.
|
||||
*/
|
||||
if (!srtp->offerer_side)
|
||||
return PJ_SUCCESS;
|
||||
if (!srtp->offerer_side) {
|
||||
if (srtp->tx_policy_neg.name.slen == 0)
|
||||
return PJ_SUCCESS;
|
||||
|
||||
/* Get the local crypto. */
|
||||
fill_local_crypto(srtp->pool, m_loc, loc_crypto, &loc_cryto_cnt);
|
||||
|
||||
if (loc_cryto_cnt == 0)
|
||||
return PJ_SUCCESS;
|
||||
|
||||
if ((pj_stricmp(&srtp->tx_policy_neg.name,
|
||||
&loc_crypto[0].name) == 0) &&
|
||||
(pj_stricmp(&srtp->tx_policy_neg.key,
|
||||
&loc_crypto[0].key) != 0))
|
||||
{
|
||||
srtp->tx_policy_neg = loc_crypto[0];
|
||||
for (i = 0; i<srtp->setting.crypto_count ;++i) {
|
||||
if ((pj_stricmp(&srtp->setting.crypto[i].name,
|
||||
&loc_crypto[0].name) == 0) &&
|
||||
(pj_stricmp(&srtp->setting.crypto[i].key,
|
||||
&loc_crypto[0].key) != 0))
|
||||
{
|
||||
pj_strdup(pool, &srtp->setting.crypto[i].key,
|
||||
&loc_crypto[0].key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PJ_SUCCESS;
|
||||
}
|
||||
|
||||
/* Check remote media transport & set local media transport
|
||||
* based on SRTP usage option.
|
||||
|
@ -717,14 +745,14 @@ static pj_status_t sdes_media_start( pjmedia_transport *tp,
|
|||
return PJMEDIA_SRTP_ECRYPTONOTMATCH;
|
||||
}
|
||||
|
||||
/* Find the crypto from the setting. */
|
||||
for (j = 0; j < (int)srtp->setting.crypto_count; ++j) {
|
||||
if (pj_stricmp(&tmp_tx_crypto.name,
|
||||
&srtp->setting.crypto[j].name) == 0)
|
||||
/* Find the crypto from the local crypto. */
|
||||
for (j = 0; j < (int)loc_cryto_cnt; ++j) {
|
||||
if (pj_stricmp(&tmp_tx_crypto.name,
|
||||
&loc_crypto[j].name) == 0)
|
||||
{
|
||||
srtp->tx_policy_neg = srtp->setting.crypto[j];
|
||||
srtp->tx_policy_neg = loc_crypto[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
srtp->rx_policy_neg = tmp_tx_crypto;
|
||||
|
|
Loading…
Reference in New Issue