From e7006959893cce749857178ae722f352c13048c1 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 3 Oct 2011 14:44:40 +0200 Subject: [PATCH 01/10] srtp: add SRTP support to Linphone --- coreapi/callbacks.c | 14 ++++++ coreapi/linphonecall.c | 80 ++++++++++++++++++++++++++++++++-- coreapi/linphonecore.c | 44 ++++++++++++++++++- coreapi/linphonecore.h | 12 +++++- coreapi/offeranswer.c | 53 +++++++++++++++++++++-- coreapi/private.h | 2 +- coreapi/sal.h | 11 +++++ coreapi/sal_eXosip2.c | 8 ++++ coreapi/sal_eXosip2_sdp.c | 90 +++++++++++++++++++++++++++++++++++++-- mediastreamer2 | 2 +- oRTP | 2 +- 11 files changed, 302 insertions(+), 16 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index a307a1c5f..59bf3a2f6 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -491,6 +491,20 @@ static void call_failure(SalOp *op, SalError error, SalReason sr, const char *de lc->vtable.display_status(lc,msg600); break; case SalReasonMedia: + //media_encryption_mandatory + if (call->params.media_encryption == LinphoneMediaEncryptionSRTP && + !linphone_core_is_media_encryption_mandatory(lc)) { + int i; + ms_message("Outgoing call failed with SRTP (SAVP) enabled - retrying with AVP"); + /* clear SRTP local params */ + call->params.media_encryption = LinphoneMediaEncryptionNone; + for(i=0; ilocaldesc->nstreams; i++) { + call->localdesc->streams[i].proto = SalProtoRtpAvp; + memset(call->localdesc->streams[i].crypto, 0, sizeof(call->localdesc->streams[i].crypto)); + } + linphone_core_start_invite(lc, call, NULL); + return; + } msg=_("No common codecs"); if (lc->vtable.display_status) lc->vtable.display_status(lc,msg); diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 8ab925cf4..9998c02d3 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "lpconfig.h" #include "private.h" #include +#include #include "mediastreamer2/mediastream.h" @@ -41,6 +42,27 @@ static MSWebCam *get_nowebcam_device(){ } #endif +static bool_t generate_b64_crypto_key(int key_length, char* key_out) { + int b64_size; + uint8_t* tmp = (uint8_t*) malloc(key_length); + if (crypto_get_random(tmp, key_length)) { + ms_error("Failed to generate random key"); + free(tmp); + return FALSE; + } + + b64_size = b64_encode((const char*)tmp, key_length, NULL, 0); + if (b64_size == 0) { + ms_error("Failed to b64 encode key"); + free(tmp); + return FALSE; + } + key_out[b64_size] = '\0'; + b64_encode((const char*)tmp, key_length, key_out, 40); + free(tmp); + return TRUE; +} + LinphoneCore *linphone_call_get_core(const LinphoneCall *call){ return call->core; } @@ -165,6 +187,7 @@ static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, int bandw static SalMediaDescription *_create_local_media_description(LinphoneCore *lc, LinphoneCall *call, unsigned int session_id, unsigned int session_ver){ MSList *l; PayloadType *pt; + int i; const char *me=linphone_core_get_identity(lc); LinphoneAddress *addr=linphone_address_new(me); const char *username=linphone_address_get_username (addr); @@ -180,7 +203,8 @@ static SalMediaDescription *_create_local_media_description(LinphoneCore *lc, Li /*set audio capabilities */ strncpy(md->streams[0].addr,call->localip,sizeof(md->streams[0].addr)); md->streams[0].port=call->audio_port; - md->streams[0].proto=SalProtoRtpAvp; + md->streams[0].proto=(call->params.media_encryption == LinphoneMediaEncryptionSRTP) ? + SalProtoRtpSavp : SalProtoRtpAvp; md->streams[0].type=SalAudio; md->streams[0].ptime=lc->net_conf.down_ptime; l=make_codec_list(lc,lc->codecs_conf.audio_codecs,call->params.audio_bw); @@ -192,11 +216,26 @@ static SalMediaDescription *_create_local_media_description(LinphoneCore *lc, Li if (call->params.has_video){ md->nstreams++; md->streams[1].port=call->video_port; - md->streams[1].proto=SalProtoRtpAvp; + md->streams[1].proto=md->streams[0].proto; md->streams[1].type=SalVideo; l=make_codec_list(lc,lc->codecs_conf.video_codecs,0); md->streams[1].payloads=l; } + + for(i=0; instreams; i++) { + if (md->streams[i].proto == SalProtoRtpSavp) { + md->streams[i].crypto[0].tag = 1; + md->streams[i].crypto[0].algo = AES_128_SHA1_80; + if (!generate_b64_crypto_key(30, md->streams[i].crypto[0].master_key)) + md->streams[i].crypto[0].algo = 0; + md->streams[i].crypto[1].tag = 2; + md->streams[i].crypto[1].algo = AES_128_SHA1_32; + if (!generate_b64_crypto_key(30, md->streams[i].crypto[1].master_key)) + md->streams[i].crypto[1].algo = 0; + md->streams[i].crypto[2].algo = 0; + } + } + linphone_address_destroy(addr); return md; } @@ -315,6 +354,7 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip); linphone_call_init_common(call, from, to); call->params.has_video=linphone_core_video_enabled(lc); + call->params.media_encryption=linphone_core_get_media_encryption(lc); call->localdesc=create_local_media_description (lc,call); call->camera_active=call->params.has_video; if (linphone_core_get_firewall_policy(call->core)==LinphonePolicyUseStun) @@ -973,7 +1013,12 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna LinphoneCore *lc=call->core; int jitt_comp=lc->rtp_conf.audio_jitt_comp; int used_pt=-1; + /* look for savp stream first */ const SalStreamDescription *stream=sal_media_description_find_stream(call->resultdesc, + SalProtoRtpSavp,SalAudio); + /* no savp audio stream, use avp */ + if (!stream) + stream=sal_media_description_find_stream(call->resultdesc, SalProtoRtpAvp,SalAudio); if (stream && stream->dir!=SalStreamInactive && stream->port!=0){ @@ -1050,6 +1095,17 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna /*transform the graph to connect it to the conference filter */ linphone_call_add_to_conf(call); } + + if (stream->proto == SalProtoRtpSavp) { + const SalStreamDescription *local_st_desc=sal_media_description_find_stream(call->localdesc, + SalProtoRtpSavp,SalAudio); + + audio_stream_enable_strp( + call->audiostream, + stream->crypto[0].algo, + local_st_desc->crypto[0].master_key, + stream->crypto[0].master_key); + } }else ms_warning("No audio stream accepted ?"); } } @@ -1058,8 +1114,14 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna #ifdef VIDEO_ENABLED LinphoneCore *lc=call->core; int used_pt=-1; + /* look for savp stream first */ const SalStreamDescription *vstream=sal_media_description_find_stream(call->resultdesc, - SalProtoRtpAvp,SalVideo); + SalProtoRtpSavp,SalVideo); + /* no savp audio stream, use avp */ + if (!vstream) + vstream=sal_media_description_find_stream(call->resultdesc, + SalProtoRtpAvp,SalVideo); + /* shutdown preview */ if (lc->previewstream!=NULL) { video_preview_stop(lc->previewstream); @@ -1114,6 +1176,18 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna used_pt, lc->rtp_conf.audio_jitt_comp, cam); video_stream_set_rtcp_information(call->videostream, cname,LINPHONE_RTCP_SDES_TOOL); } + + if (vstream->proto == SalProtoRtpSavp) { + const SalStreamDescription *local_st_desc=sal_media_description_find_stream(call->localdesc, + SalProtoRtpSavp,SalVideo); + + video_stream_enable_strp( + call->videostream, + vstream->crypto[0].algo, + local_st_desc->crypto[0].master_key, + vstream->crypto[0].master_key + ); + } }else ms_warning("No video stream accepted."); }else{ ms_warning("No valid video stream defined."); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index cce64048e..db4088153 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -35,6 +35,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #endif +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + /*#define UNSTANDART_GSM_11K 1*/ static const char *liblinphone_version=LIBLINPHONE_VERSION; @@ -515,7 +519,7 @@ static void sip_config_read(LinphoneCore *lc) } sal_root_ca(lc->sal, lp_config_get_string(lc->config,"sip","root_ca", "/etc/ssl/certs")); - + tmp=lp_config_get_int(lc->config,"sip","guess_hostname",1); linphone_core_set_guess_hostname(lc,tmp); @@ -4231,7 +4235,9 @@ LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc){ LinphoneCallParams *linphone_core_create_default_call_parameters(LinphoneCore *lc){ LinphoneCallParams *p=ms_new0(LinphoneCallParams,1); - p->has_video=linphone_core_video_enabled(lc); + p->has_video=linphone_core_video_enabled(lc); + p->media_encryption=linphone_core_get_media_encryption(lc); + ms_message("%s : %d", __FUNCTION__, p->media_encryption); return p; } @@ -4347,3 +4353,37 @@ const LinphoneCall* linphone_core_find_call_from_uri(LinphoneCore *lc, const cha } return NULL; } + +void linphone_core_set_srtp_enabled(LinphoneCore *lc, bool_t enabled) { + lp_config_set_int(lc->config,"sip","srtp",(int)enabled); +} + +void linphone_core_set_media_encryption_enabled(LinphoneCore *lc, enum LinphoneMediaEncryption menc) { + if (menc == LinphoneMediaEncryptionSRTP) + lp_config_set_string(lc->config,"sip","media_encryption","srtp"); + else if (menc == LinphoneMediaEncryptionZRTP) + lp_config_set_string(lc->config,"sip","media_encryption","zrtp"); + else + lp_config_set_string(lc->config,"sip","media_encryption","none"); +} + +enum LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc) { + const char* menc = lp_config_get_string(lc->config, "sip", "media_encryption", NULL); + + if (menc == NULL) + return LinphoneMediaEncryptionNone; + else if (strcmp(menc, "srtp")==0) + return LinphoneMediaEncryptionSRTP; + else if (strcmp(menc, "zrtp")==0) + return LinphoneMediaEncryptionZRTP; + else + return LinphoneMediaEncryptionNone; +} + +bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc) { + return (bool_t)lp_config_get_int(lc->config, "sip", "media_encryption_mandatory", 0); +} + +void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m) { + lp_config_set_int(lc->config, "sip", "media_encryption_mandatory", (int)m); +} diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 368746cda..c2c02f0e5 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -156,7 +156,11 @@ typedef struct _LinphoneCallLog{ struct _LinphoneCore *lc; } LinphoneCallLog; - +enum LinphoneMediaEncryption { + LinphoneMediaEncryptionNone, + LinphoneMediaEncryptionSRTP, + LinphoneMediaEncryptionZRTP +}; /*public: */ void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up); @@ -1029,6 +1033,12 @@ int linphone_core_leave_conference(LinphoneCore *lc); int linphone_core_terminate_conference(LinphoneCore *lc); int linphone_core_get_conference_size(LinphoneCore *lc); +void linphone_core_set_media_encryption_enabled(LinphoneCore *lc, enum LinphoneMediaEncryption menc); +enum LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc); + +bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc); +void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m); + #ifdef __cplusplus } #endif diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index 3e054508b..ab213a239 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -128,6 +128,31 @@ static MSList *match_payloads(const MSList *local, const MSList *remote, bool_t return res; } +static bool_t match_crypto_algo(const SalSrtpCryptoAlgo* local, const SalSrtpCryptoAlgo* remote, + SalSrtpCryptoAlgo* result, bool_t use_local_key) { + int i,j; + for(i=0; ialgo = remote[i].algo; + if (use_local_key) { + strncpy(result->master_key, local[j].master_key, 41); + result->tag = local[j].tag; + } else { + strncpy(result->master_key, remote[j].master_key, 41); + result->tag = remote[j].tag; + } + result->master_key[40] = '\0'; + return TRUE; + } + } + } + return FALSE; +} + static SalStreamDir compute_dir_outgoing(SalStreamDir local, SalStreamDir answered){ @@ -174,7 +199,7 @@ static void initiate_outgoing(const SalStreamDescription *local_offer, SalStreamDescription *result){ if (remote_answer->port!=0) result->payloads=match_payloads(local_offer->payloads,remote_answer->payloads,TRUE,FALSE); - result->proto=local_offer->proto; + result->proto=remote_answer->proto; result->type=local_offer->type; result->dir=compute_dir_outgoing(local_offer->dir,remote_answer->dir); @@ -186,6 +211,12 @@ static void initiate_outgoing(const SalStreamDescription *local_offer, }else{ result->port=0; } + if (result->proto == SalProtoRtpSavp) { + /* verify crypto algo */ + memset(result->crypto, 0, sizeof(result->crypto)); + if (!match_crypto_algo(local_offer->crypto, remote_answer->crypto, &result->crypto[0], FALSE)) + result->port = 0; + } } @@ -193,7 +224,7 @@ static void initiate_incoming(const SalStreamDescription *local_cap, const SalStreamDescription *remote_offer, SalStreamDescription *result, bool_t one_matching_codec){ result->payloads=match_payloads(local_cap->payloads,remote_offer->payloads, FALSE, one_matching_codec); - result->proto=local_cap->proto; + result->proto=remote_offer->proto; result->type=local_cap->type; result->dir=compute_dir_incoming(local_cap->dir,remote_offer->dir); if (result->payloads && !only_telephone_event(result->payloads)){ @@ -205,6 +236,13 @@ static void initiate_incoming(const SalStreamDescription *local_cap, }else{ result->port=0; } + if (result->proto == SalProtoRtpSavp) { + /* select crypto algo */ + memset(result->crypto, 0, sizeof(result->crypto)); + if (!match_crypto_algo(local_cap->crypto, remote_offer->crypto, &result->crypto[0], TRUE)) + result->port = 0; + + } } /** @@ -215,6 +253,7 @@ int offer_answer_initiate_outgoing(const SalMediaDescription *local_offer, const SalMediaDescription *remote_answer, SalMediaDescription *result){ int i,j; + const SalStreamDescription *ls,*rs; for(i=0,j=0;instreams;++i){ ms_message("Processing for stream %i",i); @@ -246,10 +285,18 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities for(i=0;instreams;++i){ rs=&remote_offer->streams[i]; ms_message("Processing for stream %i",i); + ls=sal_media_description_find_stream((SalMediaDescription*)local_capabilities,rs->proto,rs->type); + ms_message("remote proto: %s => %p", (rs->proto == SalProtoRtpAvp)?"AVP":"SAVP", ls); + /* if matching failed, and remote proposes Avp only, ask for local Savp streams */ + if (!ls && rs->proto == SalProtoRtpAvp) { + ls=sal_media_description_find_stream((SalMediaDescription*)local_capabilities,SalProtoRtpSavp,rs->type); + ms_message("retry with AVP => %p", ls); + } if (ls){ initiate_incoming(ls,rs,&result->streams[i],one_matching_codec); - } else { + } + else { /* create an inactive stream for the answer, as there where no matching stream a local capability */ result->streams[i].dir=SalStreamInactive; result->streams[i].port=0; diff --git a/coreapi/private.h b/coreapi/private.h index b8aba9d1f..1dfeda65d 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -57,7 +57,6 @@ #endif #endif - struct _LinphoneCallParams{ LinphoneCall *referer; /*in case this call creation is consecutive to an incoming transfer, this points to the original call */ int audio_bw; /* bandwidth limit for audio stream */ @@ -65,6 +64,7 @@ struct _LinphoneCallParams{ bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/ bool_t in_conference; /*in conference mode */ bool_t pad; + enum LinphoneMediaEncryption media_encryption; }; struct _LinphoneCall diff --git a/coreapi/sal.h b/coreapi/sal.h index 140c14d04..e4d10fe86 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define sal_h #include "mediastreamer2/mscommon.h" +#include "ortp/srtp.h" /*Dirty hack, keep in sync with mediastreamer2/include/mediastream.h */ #ifndef PAYLOAD_TYPE_FLAG_CAN_RECV @@ -111,6 +112,15 @@ typedef struct SalEndpointCandidate{ #define SAL_ENDPOINT_CANDIDATE_MAX 2 +typedef struct SalSrtpCryptoAlgo { + unsigned int tag; + enum ortp_srtp_crypto_suite_t algo; + /* 41= 40 max(key_length for all algo) + '\0' */ + char master_key[41]; +} SalSrtpCryptoAlgo; + +#define SAL_CRYPTO_ALGO_MAX 4 + typedef struct SalStreamDescription{ SalMediaProto proto; SalStreamType type; @@ -122,6 +132,7 @@ typedef struct SalStreamDescription{ int ptime; SalEndpointCandidate candidates[SAL_ENDPOINT_CANDIDATE_MAX]; SalStreamDir dir; + SalSrtpCryptoAlgo crypto[SAL_CRYPTO_ALGO_MAX]; } SalStreamDescription; #define SAL_MEDIA_DESCRIPTION_MAX_STREAMS 4 diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 5b9500509..e4f4547ac 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -514,12 +514,18 @@ static void sdp_process(SalOp *h){ It should contains media parameters constraint from the remote offer, not our response*/ strcpy(h->result->addr,h->base.remote_media->addr); h->result->bandwidth=h->base.remote_media->bandwidth; + + //remplacer la cle for(i=0;iresult->nstreams;++i){ if (h->result->streams[i].port>0){ strcpy(h->result->streams[i].addr,h->base.remote_media->streams[i].addr); h->result->streams[i].ptime=h->base.remote_media->streams[i].ptime; h->result->streams[i].bandwidth=h->base.remote_media->streams[i].bandwidth; h->result->streams[i].port=h->base.remote_media->streams[i].port; + + if (h->result->streams[i].proto == SalProtoRtpSavp) { + h->result->streams[i].crypto[0] = h->base.remote_media->streams[i].crypto[0]; + } } } } @@ -545,6 +551,8 @@ int sal_call(SalOp *h, const char *from, const char *to){ sal_op_set_from(h,from); sal_op_set_to(h,to); sal_exosip_fix_route(h); + + h->terminated = FALSE; err=eXosip_call_build_initial_invite(&invite,to,from,sal_op_get_route(h),"Phone call"); if (err!=0){ ms_error("Could not create call."); diff --git a/coreapi/sal_eXosip2_sdp.c b/coreapi/sal_eXosip2_sdp.c index 3993e66f8..813e9da1a 100644 --- a/coreapi/sal_eXosip2_sdp.c +++ b/coreapi/sal_eXosip2_sdp.c @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "ortp/b64.h" +#include "ortp/srtp.h" #include "sal.h" #include @@ -233,9 +234,47 @@ static void add_line(sdp_message_t *msg, int lineno, const SalStreamDescription osip_strdup ("IN"), inet6 ? osip_strdup ("IP6") : osip_strdup ("IP4"), osip_strdup (addr), NULL, NULL); } - sdp_message_m_media_add (msg, osip_strdup (mt), - int_2char (port), NULL, - osip_strdup ("RTP/AVP")); + + if (desc->proto == SalProtoRtpSavp) { + int i; + + sdp_message_m_media_add (msg, osip_strdup (mt), + int_2char (port), NULL, + osip_strdup ("RTP/SAVP")); + + /* add crypto lines */ + for(i=0; icrypto[i].algo) { + case AES_128_SHA1_80: + snprintf(buffer, 1024, "%d %s inline:%s", + desc->crypto[i].tag, "AES_CM_128_HMAC_SHA1_80", desc->crypto[i].master_key); + sdp_message_a_attribute_add(msg, lineno, osip_strdup("crypto"), + osip_strdup(buffer)); + break; + case AES_128_SHA1_32: + snprintf(buffer, 1024, "%d %s inline:%s", + desc->crypto[i].tag, "AES_CM_128_HMAC_SHA1_32", desc->crypto[i].master_key); + sdp_message_a_attribute_add(msg, lineno, osip_strdup("crypto"), + osip_strdup(buffer)); + break; + case AES_128_NO_AUTH: + ms_warning("Unsupported crypto suite: AES_128_NO_AUTH"); + break; + case NO_CIPHER_SHA1_80: + ms_warning("Unsupported crypto suite: NO_CIPHER_SHA1_80"); + break; + default: + i = SAL_CRYPTO_ALGO_MAX; + } + } + + } else { + sdp_message_m_media_add (msg, osip_strdup (mt), + int_2char (port), NULL, + osip_strdup ("RTP/AVP")); + + } if (desc->bandwidth>0) sdp_message_b_bandwidth_add (msg, lineno, osip_strdup ("AS"), int_2char(desc->bandwidth)); if (desc->ptime>0) sdp_message_a_attribute_add(msg,lineno,osip_strdup("ptime"), @@ -355,7 +394,7 @@ int sdp_to_media_description(sdp_message_t *msg, SalMediaDescription *desc){ for(j=0;(sbw=sdp_message_bandwidth_get(msg,i,j))!=NULL;++j){ if (strcasecmp(sbw->b_bwtype,"AS")==0) stream->bandwidth=atoi(sbw->b_bandwidth); } - stream->dir=_sdp_message_get_mline_dir(msg,i); + stream->dir=_sdp_message_get_mline_dir(msg,i); /* for each payload type */ for (j=0;((number=sdp_message_m_payload_get (msg, i,j)) != NULL); j++){ const char *rtpmap,*fmtp; @@ -373,6 +412,49 @@ int sdp_to_media_description(sdp_message_t *msg, SalMediaDescription *desc){ pt->send_fmtp ? pt->send_fmtp : ""); } } + + /* read crypto lines if any */ + if (stream->proto == SalProtoRtpSavp) { + int k, valid_count = 0; + sdp_attribute_t *attr; + + memset(&stream->crypto, 0, sizeof(stream->crypto)); + for (k=0;valid_count < SAL_CRYPTO_ALGO_MAX && (attr=sdp_message_attribute_get(msg,i,k))!=NULL;k++){ + char tmp[256], tmp2[256]; + if (keywordcmp("crypto",attr->a_att_field)==0 && attr->a_att_value!=NULL){ + int nb = sscanf(attr->a_att_value, "%d %256s inline:%256s", + &stream->crypto[valid_count].tag, + tmp, + tmp2); + ms_message("Found valid crypto line (tag:%d algo:'%s' key:'%s'", + stream->crypto[valid_count].tag, + tmp, + tmp2); + if (nb == 3) { + if (strcmp(tmp, "AES_CM_128_HMAC_SHA1_80") == 0) + stream->crypto[valid_count].algo = AES_128_SHA1_80; + else if (strcmp(tmp, "AES_CM_128_HMAC_SHA1_32") == 0) + stream->crypto[valid_count].algo = AES_128_SHA1_32; + else { + ms_warning("Failed to parse crypto-algo: '%s'", tmp); + stream->crypto[valid_count].algo = 0; + } + if (stream->crypto[valid_count].algo) { + strncpy(stream->crypto[valid_count].master_key, tmp2, 41); + stream->crypto[valid_count].master_key[40] = '\0'; + ms_message("Found valid crypto line (tag:%d algo:'%s' key:'%s'", + stream->crypto[valid_count].tag, + tmp, + stream->crypto[valid_count].master_key); + valid_count++; + } + } else { + ms_warning("sdp has a strange a= line (%s) nb=%i",attr->a_att_value,nb); + } + } + } + ms_message("Found: %d valid crypto lines", valid_count); + } } desc->nstreams=i; return 0; diff --git a/mediastreamer2 b/mediastreamer2 index 28a643d20..aadeaaa8b 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 28a643d20f6d6384d96590ab6e988928597878cf +Subproject commit aadeaaa8b2de3b1e0cb9ffd5a0a22a85335e7951 diff --git a/oRTP b/oRTP index 845e0cf4e..3e3ba3f49 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 845e0cf4e33cc9964c48aa9191005d4108dfebbd +Subproject commit 3e3ba3f4922a9f2eaddd782b571abf3968aa41b9 From dcafb75f869aee37e9df281e8b67ddada015f849 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 4 Oct 2011 21:05:26 +0200 Subject: [PATCH 02/10] fix function call names --- coreapi/linphonecore.c | 3 +-- coreapi/linphonecore.h | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index db4088153..e55235eff 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -4237,7 +4237,6 @@ LinphoneCallParams *linphone_core_create_default_call_parameters(LinphoneCore *l LinphoneCallParams *p=ms_new0(LinphoneCallParams,1); p->has_video=linphone_core_video_enabled(lc); p->media_encryption=linphone_core_get_media_encryption(lc); - ms_message("%s : %d", __FUNCTION__, p->media_encryption); return p; } @@ -4358,7 +4357,7 @@ void linphone_core_set_srtp_enabled(LinphoneCore *lc, bool_t enabled) { lp_config_set_int(lc->config,"sip","srtp",(int)enabled); } -void linphone_core_set_media_encryption_enabled(LinphoneCore *lc, enum LinphoneMediaEncryption menc) { +void linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc) { if (menc == LinphoneMediaEncryptionSRTP) lp_config_set_string(lc->config,"sip","media_encryption","srtp"); else if (menc == LinphoneMediaEncryptionZRTP) diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index c2c02f0e5..d849933cb 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -263,6 +263,10 @@ float linphone_call_get_play_volume(LinphoneCall *call); float linphone_call_get_record_volume(LinphoneCall *call); float linphone_call_get_current_quality(LinphoneCall *call); float linphone_call_get_average_quality(LinphoneCall *call); +bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call); +const char* linphone_call_get_authentication_token(LinphoneCall *call); +bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call); +void linphone_call_send_vfu_request(LinphoneCall *call); void *linphone_call_get_user_pointer(LinphoneCall *call); void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer); /** @@ -1011,15 +1015,9 @@ LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc); */ void linphone_core_refresh_registers(LinphoneCore* lc); - -void linphone_call_send_vfu_request(LinphoneCall *call); - /* Path to the file storing secrets cache */ void linphone_core_set_zrtp_secrets_file(LinphoneCore *lc, const char* file); -bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call); -const char* linphone_call_get_authentication_token(LinphoneCall *call); -bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call); const LinphoneCall* linphone_core_find_call_from_uri(LinphoneCore *lc, const char *uri); @@ -1033,7 +1031,7 @@ int linphone_core_leave_conference(LinphoneCore *lc); int linphone_core_terminate_conference(LinphoneCore *lc); int linphone_core_get_conference_size(LinphoneCore *lc); -void linphone_core_set_media_encryption_enabled(LinphoneCore *lc, enum LinphoneMediaEncryption menc); +void linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc); enum LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc); bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc); From 19caf123a33db6553089cdf0f6426e70ac897e59 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 5 Oct 2011 09:11:51 +0200 Subject: [PATCH 03/10] srtp: use srtp branch of ms2 and ortp --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index aadeaaa8b..f12d0e725 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit aadeaaa8b2de3b1e0cb9ffd5a0a22a85335e7951 +Subproject commit f12d0e725229865004d8276ae307aab240f7392c diff --git a/oRTP b/oRTP index 3e3ba3f49..22b2d1e2c 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 3e3ba3f4922a9f2eaddd782b571abf3968aa41b9 +Subproject commit 22b2d1e2c3a694d6adca219ffe229d8783416cd6 From 9d3acfbb4ae4f85067dc36f796a6d5e46c22e4b8 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 5 Oct 2011 09:40:22 +0200 Subject: [PATCH 04/10] Use private ortp/ms2 repository --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 0655d8e56..5cd2e5b50 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "oRTP"] path = oRTP - url = git://git.linphone.org/ortp.git + url = gitosis@git.linphone.org:ortp-private [submodule "mediastreamer2"] path = mediastreamer2 - url = git://git.linphone.org/mediastreamer2.git + url = gitosis@git.linphone.org:mediastreamer2-private From 3cb22b69375f1bd759bc0bd365fecad0b553cced Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 5 Oct 2011 11:20:27 +0200 Subject: [PATCH 05/10] srtp: add documentation, get/set functions --- coreapi/conference.c | 1 + coreapi/linphonecall.c | 12 ++++++++++-- coreapi/linphonecore.c | 9 +++++++-- coreapi/linphonecore.h | 14 ++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/coreapi/conference.c b/coreapi/conference.c index 53abfab81..3714ded9a 100644 --- a/coreapi/conference.c +++ b/coreapi/conference.c @@ -109,6 +109,7 @@ int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call){ conference_check_init(&lc->conf_ctx); call->params.in_conference=TRUE; call->params.has_video=FALSE; + call->params.media_encryption=LinphoneMediaEncryptionNone; params=call->params; if (call->state==LinphoneCallPaused) linphone_core_resume_call(lc,call); diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 9998c02d3..4bda4d750 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -353,8 +353,7 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro linphone_address_clean(from); linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip); linphone_call_init_common(call, from, to); - call->params.has_video=linphone_core_video_enabled(lc); - call->params.media_encryption=linphone_core_get_media_encryption(lc); + linphone_core_init_default_params(lc, &call->params); call->localdesc=create_local_media_description (lc,call); call->camera_active=call->params.has_video; if (linphone_core_get_firewall_policy(call->core)==LinphonePolicyUseStun) @@ -713,6 +712,15 @@ bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp){ return cp->has_video; } +enum LinphoneMediaEncryption linphone_call_get_media_encryption(LinphoneCallParams *cp) { + return cp->media_encryption; +} + +void linphone_call_params_set_media_encryption(LinphoneCallParams *cp, enum LinphoneMediaEncryption e) { + cp->media_encryption = e; +} + + /** * Enable sending of real early media (during outgoing calls). **/ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e55235eff..715d0f2c7 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -4235,8 +4235,7 @@ LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc){ LinphoneCallParams *linphone_core_create_default_call_parameters(LinphoneCore *lc){ LinphoneCallParams *p=ms_new0(LinphoneCallParams,1); - p->has_video=linphone_core_video_enabled(lc); - p->media_encryption=linphone_core_get_media_encryption(lc); + linphone_core_init_default_params(lc, p); return p; } @@ -4386,3 +4385,9 @@ bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc) { void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m) { lp_config_set_int(lc->config, "sip", "media_encryption_mandatory", (int)m); } + +void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params) { + params->has_video=linphone_core_video_enabled(lc); + params->media_encryption=linphone_core_get_media_encryption(lc); + params->in_conference=FALSE; +} diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index d849933cb..412138e71 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -183,6 +183,8 @@ typedef struct _LinphoneCallParams LinphoneCallParams; LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp); void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp); +enum LinphoneMediaEncryption linphone_call_get_media_encryption(LinphoneCallParams *cp); +void linphone_call_params_set_media_encryption(LinphoneCallParams *cp, enum LinphoneMediaEncryption e); void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams *cp); bool_t linphone_call_params_local_conference_mode(const LinphoneCallParams *cp); @@ -1031,12 +1033,24 @@ int linphone_core_leave_conference(LinphoneCore *lc); int linphone_core_terminate_conference(LinphoneCore *lc); int linphone_core_get_conference_size(LinphoneCore *lc); +/** + * Choose media encryption policy to be used for RTP packets + */ void linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc); enum LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc); bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc); +/** + * Defines Linphone behaviour when encryption parameters negociation fails on outoing call. + * If set to TRUE call will fail; if set to FALSE will resend an INVITE with encryption disabled + */ void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m); +/** + * Init call params using LinphoneCore's current configuration + */ +void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params); + #ifdef __cplusplus } #endif From 4ff98fde111083f1cab984d50e56811b03cd7922 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 6 Oct 2011 09:29:42 +0200 Subject: [PATCH 06/10] srtp: take into account that ortp' srtp.h has been renamed ortp_srtp.h --- coreapi/sal.h | 2 +- coreapi/sal_eXosip2_sdp.c | 2 +- mediastreamer2 | 2 +- oRTP | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coreapi/sal.h b/coreapi/sal.h index e4d10fe86..86a0fb86b 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define sal_h #include "mediastreamer2/mscommon.h" -#include "ortp/srtp.h" +#include "ortp/ortp_srtp.h" /*Dirty hack, keep in sync with mediastreamer2/include/mediastream.h */ #ifndef PAYLOAD_TYPE_FLAG_CAN_RECV diff --git a/coreapi/sal_eXosip2_sdp.c b/coreapi/sal_eXosip2_sdp.c index 813e9da1a..f67fb9cfd 100644 --- a/coreapi/sal_eXosip2_sdp.c +++ b/coreapi/sal_eXosip2_sdp.c @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "ortp/b64.h" -#include "ortp/srtp.h" +#include "ortp/ortp_srtp.h" #include "sal.h" #include diff --git a/mediastreamer2 b/mediastreamer2 index f12d0e725..481d921f3 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit f12d0e725229865004d8276ae307aab240f7392c +Subproject commit 481d921f343086a8e634cd5b7241363c4f07b5fa diff --git a/oRTP b/oRTP index 22b2d1e2c..13450079c 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 22b2d1e2c3a694d6adca219ffe229d8783416cd6 +Subproject commit 13450079c956cac404f9c8f19bc1132f73cfca79 From e835601158351ce465d0c401f83c82e595c63c1a Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 6 Oct 2011 14:48:24 +0200 Subject: [PATCH 07/10] android: enable srtp --- build/android/Android.mk | 3 +++ mediastreamer2 | 2 +- oRTP | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build/android/Android.mk b/build/android/Android.mk index 299442e28..a7b9e024b 100755 --- a/build/android/Android.mk +++ b/build/android/Android.mk @@ -119,6 +119,9 @@ endif LOCAL_STATIC_LIBRARIES += libspeex +ifeq ($(BUILD_SRTP), 1) + LOCAL_C_INCLUDES += $(SRTP_C_INCLUDE) +endif ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) LOCAL_CFLAGS += -DHAVE_ILBC=1 diff --git a/mediastreamer2 b/mediastreamer2 index 481d921f3..be3a6f4e3 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 481d921f343086a8e634cd5b7241363c4f07b5fa +Subproject commit be3a6f4e357fbf664bcb44f954d8b9f76a069d1c diff --git a/oRTP b/oRTP index 13450079c..f78246fcc 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 13450079c956cac404f9c8f19bc1132f73cfca79 +Subproject commit f78246fcce4faa1865d005a3532f878b1bf264cc From fe3eaf6f2d05322a3ca0b082e1277143ccdf91fe Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 10 Oct 2011 09:00:15 +0200 Subject: [PATCH 08/10] srtp: add Java API --- coreapi/linphonecall.c | 2 +- coreapi/linphonecore.h | 2 +- java/common/org/linphone/core/LinphoneCallParams.java | 3 +++ java/common/org/linphone/core/LinphoneCore.java | 6 ++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 4bda4d750..aa121a057 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -712,7 +712,7 @@ bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp){ return cp->has_video; } -enum LinphoneMediaEncryption linphone_call_get_media_encryption(LinphoneCallParams *cp) { +enum LinphoneMediaEncryption linphone_call_params_get_media_encryption(LinphoneCallParams *cp) { return cp->media_encryption; } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 412138e71..1697ea87c 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -183,7 +183,7 @@ typedef struct _LinphoneCallParams LinphoneCallParams; LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp); void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp); -enum LinphoneMediaEncryption linphone_call_get_media_encryption(LinphoneCallParams *cp); +enum LinphoneMediaEncryption linphone_call_params_get_media_encryption(LinphoneCallParams *cp); void linphone_call_params_set_media_encryption(LinphoneCallParams *cp, enum LinphoneMediaEncryption e); void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled); bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams *cp); diff --git a/java/common/org/linphone/core/LinphoneCallParams.java b/java/common/org/linphone/core/LinphoneCallParams.java index 78a63d3fa..c00a8cb34 100644 --- a/java/common/org/linphone/core/LinphoneCallParams.java +++ b/java/common/org/linphone/core/LinphoneCallParams.java @@ -35,4 +35,7 @@ public interface LinphoneCallParams { */ void setAudioBandwidth(int value); + String getMediaEncryption(); + void setMediaEnctyption(String menc); + } diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index aef993ea0..42947a012 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -621,4 +621,10 @@ public interface LinphoneCore { void transferCallToAnother(LinphoneCall callToTransfer, LinphoneCall destination); LinphoneCall findCallFromUri(String uri); + + void setMediaEncryption(String menc); + String getMediaEncryption(); + + void setMediaEncryptionMandatory(boolean yesno); + boolean isMediaEncryptionMandatory(); } From 2c2f4cb921761d606fd8fd74c70daf650abb52c4 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 10 Oct 2011 10:30:44 +0200 Subject: [PATCH 09/10] Add media_encryption API JNI implementation --- coreapi/linphonecore_jni.cc | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index b6c7ca47c..1ec1c4a5f 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -769,7 +769,82 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNI } +static enum LinphoneMediaEncryption media_encryption_string_to_enum(const char* menc) { + if (menc==NULL) + return LinphoneMediaEncryptionNone; + else if (strcasecmp(menc, "none")==0) + return LinphoneMediaEncryptionNone; + else if (strcasecmp(menc, "srtp")==0) + return LinphoneMediaEncryptionSRTP; + else if (strcasecmp(menc, "zrtp")==0) + return LinphoneMediaEncryptionZRTP; + else + return LinphoneMediaEncryptionNone; +} +static jstring media_encryption_enum_to_jstring(JNIEnv* env, enum LinphoneMediaEncryption enc) { + switch (enc) { + case LinphoneMediaEncryptionSRTP: + return env->NewStringUTF("srtp"); + case LinphoneMediaEncryptionZRTP: + return env->NewStringUTF("zrtp"); + case LinphoneMediaEncryptionNone: + return env->NewStringUTF("none"); + default: + return NULL; + } +} + +extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env + ,jobject thiz + ,jlong lc + ) { + return media_encryption_enum_to_jstring(env, + linphone_core_get_media_encryption((LinphoneCore*)lc)); +} +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env + ,jobject thiz + ,jlong lc + ,jstring jmenc) { + const char* menc = jmenc?env->GetStringUTFChars(jmenc, NULL):NULL; + + linphone_core_set_media_encryption((LinphoneCore*)lc, + media_encryption_string_to_enum(menc)); + + if (menc) env->ReleaseStringUTFChars(jmenc, menc); +} + +extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env + ,jobject thiz + ,jlong lc + ) { + return media_encryption_enum_to_jstring(env, + linphone_call_params_get_media_encryption((LinphoneCallParams*)lc)); +} +extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env + ,jobject thiz + ,jlong lc + ,jstring jmenc) { + const char* menc = jmenc?env->GetStringUTFChars(jmenc, NULL):NULL; + linphone_call_params_set_media_encryption((LinphoneCallParams*)lc, + media_encryption_string_to_enum(menc)); + if (menc) env->ReleaseStringUTFChars(jmenc, menc); +} + +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env + ,jobject thiz + ,jlong lc + ) { + return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env + ,jobject thiz + ,jlong lc + , jboolean yesno + ) { + linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno); +} //ProxyConfig From 5becaaee299415ce648e78482dca295ee57e169e Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 10 Oct 2011 10:58:29 +0200 Subject: [PATCH 10/10] srtp: add Javadoc for new API functions --- .../org/linphone/core/LinphoneCallParams.java | 8 ++++++++ java/common/org/linphone/core/LinphoneCore.java | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/java/common/org/linphone/core/LinphoneCallParams.java b/java/common/org/linphone/core/LinphoneCallParams.java index c00a8cb34..c3bdc43ec 100644 --- a/java/common/org/linphone/core/LinphoneCallParams.java +++ b/java/common/org/linphone/core/LinphoneCallParams.java @@ -35,7 +35,15 @@ public interface LinphoneCallParams { */ void setAudioBandwidth(int value); + /** + * return selected media encryption + * @return 'none', 'srtp' or 'zrtp' + */ String getMediaEncryption(); + /** + * set media encryption (rtp) to use + * @params menc: 'none', 'srtp' or 'zrtp' + */ void setMediaEnctyption(String menc); } diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 42947a012..3e30414db 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -622,9 +622,23 @@ public interface LinphoneCore { LinphoneCall findCallFromUri(String uri); + /** + * set media encryption (rtp) to use + * @params menc: 'none', 'srtp' or 'zrtp' + */ void setMediaEncryption(String menc); + /** + * return selected media encryption + * @return 'none', 'srtp' or 'zrtp' + */ String getMediaEncryption(); + /** + * Set media encryption required for outgoing calls + */ void setMediaEncryptionMandatory(boolean yesno); + /** + * @return if media encryption is required for ougtoing calls + */ boolean isMediaEncryptionMandatory(); }