Ticket #61: transport_srtp.patch

File transport_srtp.patch, 2.6 KB (added by nanang, 16 years ago)
  • pjmedia/src/pjmedia/transport_srtp.c

     
    296296    PJ_ASSERT_RETURN(endpt && p_tp, PJ_EINVAL); 
    297297 
    298298    /* Check crypto availability */ 
    299     if (opt->crypto_count == 0 &&  
     299    if (opt && opt->crypto_count == 0 &&  
    300300        opt->use == PJMEDIA_SRTP_MANDATORY) 
    301301        return PJMEDIA_SRTP_ESDPREQCRYPTO; 
    302302 
    303303    /* Check crypto */ 
    304     if (opt->use != PJMEDIA_SRTP_DISABLED) { 
     304    if (opt && opt->use != PJMEDIA_SRTP_DISABLED) { 
    305305        for (i=0; i < opt->crypto_count; ++i) { 
    306306            int cs_idx = get_crypto_idx(&opt->crypto[i].name); 
    307307 
     
    969969                DEACTIVATE_MEDIA(pool, m_loc); 
    970970                return PJMEDIA_SRTP_ESDPINTRANSPORT; 
    971971            } 
     972            goto BYPASS_SRTP; 
    972973        } else if (srtp->setting.use == PJMEDIA_SRTP_OPTIONAL) { 
    973974                m_loc->desc.transport = m_rem->desc.transport; 
    974975        } else if (srtp->setting.use == PJMEDIA_SRTP_MANDATORY) { 
     
    10131014            if (pj_stricmp(&m_rem->attr[i]->name, &ID_CRYPTO) != 0) 
    10141015                continue; 
    10151016 
    1016             /* SRTP is disabled but there is crypto attr in remote media */ 
    1017             /* Put the checking here to save a bit memory for parsing */ 
    1018             if (srtp->setting.use == PJMEDIA_SRTP_DISABLED) { 
    1019                 DEACTIVATE_MEDIA(pool, m_loc); 
    1020                 return PJMEDIA_SRTP_ESDPINTRANSPORT; 
    1021             } 
    1022  
    10231017            has_crypto_attr = PJ_TRUE; 
    10241018 
    10251019            status = parse_attr_crypto(srtp->pool, m_rem->attr[i],  
     
    10441038                        int cs_idx = get_crypto_idx(&tmp_rx_crypto.name); 
    10451039 
    10461040                        /* Force to use test key */ 
     1041                        /* bad keys for snom: */ 
    10471042                        //char *hex_test_key = "58b29c5c8f42308120ce857e439f2d" 
    10481043                        //                   "7810a8b10ad0b1446be5470faea496"; 
    1049                         //pj_str_t* test_key = &srtp->setting.crypto[j].key; 
     1044                        //char *hex_test_key = "20a26aac7ba062d356ff52b61e3993" 
     1045                        //                   "ccb78078f12c64db94b9c294927fd0"; 
     1046                        //pj_str_t *test_key = &srtp->setting.crypto[j].key; 
    10501047                        //char  *raw_test_key = pj_pool_zalloc(srtp->pool, 64); 
    10511048                        //hex_string_to_octet_string( 
    10521049                        //              raw_test_key, 
     
    10541051                        //              strlen(hex_test_key)); 
    10551052                        //pj_strset(test_key, raw_test_key,  
    10561053                        //        crypto_suites[cs_idx].cipher_key_len); 
     1054                        /* EO Force to use test key */ 
    10571055 
    10581056                        if (tmp_rx_crypto.key.slen !=  
    10591057                            (int)crypto_suites[cs_idx].cipher_key_len) 
     
    10701068        } 
    10711069 
    10721070        if (srtp->setting.use == PJMEDIA_SRTP_DISABLED) { 
    1073             /* At this point, it is ensured remote has no crypto attr */ 
     1071            /* Should never reach here */ 
    10741072            goto BYPASS_SRTP; 
    10751073        } else if (srtp->setting.use == PJMEDIA_SRTP_OPTIONAL) { 
    10761074            /* bypass SRTP when no crypto-attr but remote uses RTP/AVP */