]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Send empty SAS during enrollment and other improvements
authorViktor Krikun <v.krikun@zfoneproject.com>
Tue, 6 Dec 2011 22:16:39 +0000 (22:16 +0000)
committerTravis Cross <tc@traviscross.com>
Sat, 31 Mar 2012 22:56:22 +0000 (22:56 +0000)
(refs #25)

src/zrtp.c
src/zrtp_iface_cache.c
src/zrtp_pbx.c

index d5a228150d774bf687cdc0ca3e33fb0b9e18f6bc..d0002a7d3d9ef9dbfb95023c56d772c779ec204d 100644 (file)
@@ -831,6 +831,10 @@ zrtp_status_t zrtp_profile_check(const zrtp_profile_t* profile, zrtp_global_t* z
 {
     uint8_t i = 0;
        
+       if (!profile || !zrtp) {
+               return zrtp_status_bad_param;
+       }
+       
     /*
      * Fail if the required base components are not present in the profile.
      */
index b3e1500f3d983a9f6b1a5681533da168ca268968..ae1b454666982e72d337d5c423d7ff3d727c245a 100644 (file)
@@ -912,8 +912,8 @@ void zrtp_def_cache_foreach( zrtp_global_t *global,
                if (delete) {
                        {
                        char idstr[24*2+1];
-                       ZRTP_LOG(3,(_ZTU_,"\zrtp_def_cache_foreach() Delete element id=%s index=%u\n",
-                                       hex2str(elem->id, sizeof(elem->id), idstr, sizeof(idstr)),
+                       ZRTP_LOG(3,(_ZTU_,"\trtp_def_cache_foreach() Delete element id=%s index=%u\n",
+                                       hex2str((const char*)elem->id, sizeof(elem->id), idstr, sizeof(idstr)),
                                        elem->_index));
                        }
                        
index f0fff569bf2e51095f78a3fd2ddeacda975947d0..f4f5a906c4d7528e7b1b3edd2b4d2b86a99b74ef 100644 (file)
@@ -299,6 +299,10 @@ zrtp_status_t _zrtp_machine_process_while_in_sasrelaying( zrtp_stream_t* stream,
 /*---------------------------------------------------------------------------*/
 zrtp_status_t zrtp_stream_registration_start(zrtp_stream_t* stream, uint32_t ssrc)
 {
+       if (!stream) {
+               return zrtp_status_bad_param;
+       }
+       
        ZRTP_LOG(3,(_ZTU_,"START REGISTRATION STREAM ID=%u mode=%s state=%s.\n",
                                stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state)));
                                
@@ -313,6 +317,10 @@ zrtp_status_t zrtp_stream_registration_start(zrtp_stream_t* stream, uint32_t ssr
 
 zrtp_status_t zrtp_stream_registration_secure(zrtp_stream_t* stream)
 {
+       if (!stream) {
+               return zrtp_status_bad_param;
+       }
+       
        ZRTP_LOG(3,(_ZTU_,"SECURE REGISTRATION STREAM ID=%u mode=%s state=%s.\n",
                                stream->id, zrtp_log_mode2str(stream->mode), zrtp_log_state2str(stream->state)));
        
@@ -331,6 +339,10 @@ zrtp_status_t zrtp_register_with_trusted_mitm(zrtp_stream_t* stream)
        zrtp_session_t *session = stream->session;
        zrtp_status_t s = zrtp_status_bad_param;
        
+       if (!stream) {
+               return zrtp_status_bad_param;
+       }
+       
        ZRTP_LOG(3,(_ZTU_,"MARKING this call as REGISTRATION ID=%u\n", stream->id));
        
        if (NULL == stream->zrtp->cb.cache_cb.on_get_mitm) {
@@ -399,7 +411,11 @@ zrtp_status_t zrtp_register_with_trusted_mitm(zrtp_stream_t* stream)
 /*---------------------------------------------------------------------------*/
 zrtp_status_t zrtp_link_mitm_calls(zrtp_stream_t *stream1, zrtp_stream_t *stream2)
 {
-       ZRTP_LOG(3,(_ZTU_,"Link to MiTM call together stream1=%u stream2=%u.\n", stream1->id, stream2->id));
+       if (!stream1 || !stream2) {
+               return zrtp_status_bad_param;
+       }
+       
+       ZRTP_LOG(3,(_ZTU_,"Link to MiTM call together stream1=%u stream2=%u.\n", stream1->id, stream2->id));            
        
        /* This APi is for MiTM endpoints only. */
        if (stream1->zrtp->is_mitm) {
@@ -452,6 +468,10 @@ zrtp_status_t zrtp_update_remote_options( zrtp_stream_t* stream,
        zrtp_status_t s = zrtp_status_ok;
        char buff[256];
        
+       if (!stream) {
+               return zrtp_status_bad_param;
+       }
+       
        ZRTP_LOG(3,(_ZTU_,"UPDATE REMOTE SAS OPTIONS mode. ID=%u\n", stream->id));
        ZRTP_LOG(3,(_ZTU_,"transf_sas=%s scheme=%d.\n", transf_sas_value ?
                                hex2str((const char*)transf_sas_value->buffer, transf_sas_value->length, (char*)buff, sizeof(buff)) : "NULL",
@@ -515,6 +535,10 @@ zrtp_status_t zrtp_resolve_mitm_call( zrtp_stream_t* stream1,
        zrtp_stream_t* non_enrolled = NULL;
        zrtp_sas_id_t mitm_sas_scheme = ZRTP_COMP_UNKN;
        zrtp_status_t s = zrtp_status_ok;
+       
+       if (!stream1 || !stream2) {
+               return zrtp_status_bad_param;
+       }
 
        ZRTP_LOG(3,(_ZTU_,"RESOLVE MITM CALL s1=%u, s2=%u...\n", stream1->id, stream2->id));
 
@@ -605,8 +629,9 @@ zrtp_status_t zrtp_resolve_mitm_call( zrtp_stream_t* stream1,
                return s;
        }
 
+       /* NOTE: new request from Philip Zimmermann - always send SASRelay to BOTH parties. */
        /* If non-enrolled party has SAS scheme different from chosen one - update */
-       if (non_enrolled->session->sasscheme->base.id != mitm_sas_scheme) {
+       /*if (non_enrolled->session->sasscheme->base.id != mitm_sas_scheme) { */
                s = zrtp_update_remote_options( non_enrolled,
                                                                                mitm_sas_scheme,
                                                                                NULL,
@@ -615,7 +640,7 @@ zrtp_status_t zrtp_resolve_mitm_call( zrtp_stream_t* stream1,
                if (zrtp_status_ok != s) {
                        return s;
                }
-       }
+       /*}*/
 
        return s;
 }
@@ -623,12 +648,20 @@ zrtp_status_t zrtp_resolve_mitm_call( zrtp_stream_t* stream1,
 /*---------------------------------------------------------------------------*/
 uint8_t zrtp_is_user_enrolled(zrtp_stream_t* stream)
 {
+       if (!stream) {
+               return zrtp_status_bad_param;
+       }
+       
        return ( (stream->session->secrets.cached & ZRTP_BIT_PBX) &&
                     (stream->session->secrets.matches & ZRTP_BIT_PBX) );
 }
 
 zrtp_stream_t* zrtp_choose_one_enrolled(zrtp_stream_t* stream1, zrtp_stream_t* stream2)
 {
+       if (!stream1 || !stream2) {
+               return NULL;
+       }
+       
        if (zrtp_memcmp( stream1->session->zid.buffer,
                                         stream2->session->zid.buffer,
                                         stream1->session->zid.length) > 0) {