fix lime to make sure zrtp trust is indexed by scheme, username and domain only instead of full sip uri

This commit is contained in:
Jehan Monnier 2018-03-06 16:12:53 +01:00
parent 5f26bc70ae
commit 8ef84da0a0
2 changed files with 24 additions and 8 deletions

View file

@ -765,8 +765,9 @@ bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) {
if (zrtp_cache_db != NULL) {
bool_t res;
limeURIKeys_t associatedKeys;
char *peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
char *peer = ms_strdup_printf("%s:%s@%s" , linphone_address_get_scheme(linphone_chat_room_get_peer_address(cr))
, linphone_address_get_username(linphone_chat_room_get_peer_address(cr))
, linphone_address_get_domain(linphone_chat_room_get_peer_address(cr)));
/* retrieve keys associated to the peer URI */
associatedKeys.peerURI = bctbx_strdup(peer);
associatedKeys.selfURI = NULL; /* TODO : there is no sender associated to chatroom so check for any local URI available, shall we add sender to chatroom? */
@ -806,8 +807,13 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn
errcode = 500;
return errcode;
}
peerUri = linphone_address_as_string_uri_only(msg->from);
selfUri = linphone_address_as_string_uri_only(msg->to);
peerUri = ms_strdup_printf("%s:%s@%s" , linphone_address_get_scheme(msg->from)
, linphone_address_get_username(msg->from)
, linphone_address_get_domain(msg->from));
selfUri = ms_strdup_printf("%s:%s@%s" , linphone_address_get_scheme(msg->to)
, linphone_address_get_username(msg->to)
, linphone_address_get_domain(msg->to));
retval = lime_decryptMultipartMessage(zrtp_cache_db, (uint8_t *)msg->message, selfUri, peerUri, &decrypted_body, &decrypted_content_type,
bctbx_time_string_to_sec(lp_config_get_string(lc->config, "sip", "lime_key_validity", "0")));
ms_free(peerUri);
@ -871,8 +877,12 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn
} else {
int retval;
uint8_t *crypted_body = NULL;
char *selfUri = linphone_address_as_string_uri_only(msg->from);
char *peerUri = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(room));
char *peerUri = ms_strdup_printf("%s:%s@%s" , linphone_address_get_scheme(linphone_chat_room_get_peer_address(room))
, linphone_address_get_username(linphone_chat_room_get_peer_address(room))
, linphone_address_get_domain(linphone_chat_room_get_peer_address(room)));
char *selfUri = ms_strdup_printf("%s:%s@%s" , linphone_address_get_scheme(msg->from)
, linphone_address_get_username(msg->from)
, linphone_address_get_domain(msg->from));
retval = lime_createMultipartMessage(zrtp_cache_db, msg->content_type, (uint8_t *)msg->message, selfUri, peerUri, &crypted_body);
if (retval != 0) { /* fail to encrypt */

View file

@ -2760,8 +2760,14 @@ void linphone_call_init_audio_stream(LinphoneCall *call){
/* init zrtp even if we didn't explicitely set it, just in case peer offers it */
if (linphone_core_media_encryption_supported(lc, LinphoneMediaEncryptionZRTP)) {
char *peerUri = linphone_address_as_string_uri_only((call->dir==LinphoneCallIncoming) ? call->log->from : call->log->to);
char *selfUri = linphone_address_as_string_uri_only((call->dir==LinphoneCallIncoming) ? call->log->to : call->log->from);
LinphoneAddress *peerAddr = (call->dir==LinphoneCallIncoming) ? call->log->from : call->log->to;
LinphoneAddress *selfAddr = (call->dir==LinphoneCallIncoming) ? call->log->to : call->log->from;
char *peerUri = ms_strdup_printf("%s:%s@%s" , linphone_address_get_scheme(peerAddr)
, linphone_address_get_username(peerAddr)
, linphone_address_get_domain(peerAddr));
char *selfUri = ms_strdup_printf("%s:%s@%s" , linphone_address_get_scheme(selfAddr)
, linphone_address_get_username(selfAddr)
, linphone_address_get_domain(selfAddr));
MSZrtpParams params;
memset(&params,0,sizeof(MSZrtpParams));
/*call->current_params.media_encryption will be set later when zrtp is activated*/