Ticket #61: transport_srtp.patch
File transport_srtp.patch, 2.6 KB (added by nanang, 16 years ago) |
---|
-
pjmedia/src/pjmedia/transport_srtp.c
296 296 PJ_ASSERT_RETURN(endpt && p_tp, PJ_EINVAL); 297 297 298 298 /* Check crypto availability */ 299 if (opt ->crypto_count == 0 &&299 if (opt && opt->crypto_count == 0 && 300 300 opt->use == PJMEDIA_SRTP_MANDATORY) 301 301 return PJMEDIA_SRTP_ESDPREQCRYPTO; 302 302 303 303 /* Check crypto */ 304 if (opt ->use != PJMEDIA_SRTP_DISABLED) {304 if (opt && opt->use != PJMEDIA_SRTP_DISABLED) { 305 305 for (i=0; i < opt->crypto_count; ++i) { 306 306 int cs_idx = get_crypto_idx(&opt->crypto[i].name); 307 307 … … 969 969 DEACTIVATE_MEDIA(pool, m_loc); 970 970 return PJMEDIA_SRTP_ESDPINTRANSPORT; 971 971 } 972 goto BYPASS_SRTP; 972 973 } else if (srtp->setting.use == PJMEDIA_SRTP_OPTIONAL) { 973 974 m_loc->desc.transport = m_rem->desc.transport; 974 975 } else if (srtp->setting.use == PJMEDIA_SRTP_MANDATORY) { … … 1013 1014 if (pj_stricmp(&m_rem->attr[i]->name, &ID_CRYPTO) != 0) 1014 1015 continue; 1015 1016 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 1023 1017 has_crypto_attr = PJ_TRUE; 1024 1018 1025 1019 status = parse_attr_crypto(srtp->pool, m_rem->attr[i], … … 1044 1038 int cs_idx = get_crypto_idx(&tmp_rx_crypto.name); 1045 1039 1046 1040 /* Force to use test key */ 1041 /* bad keys for snom: */ 1047 1042 //char *hex_test_key = "58b29c5c8f42308120ce857e439f2d" 1048 1043 // "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; 1050 1047 //char *raw_test_key = pj_pool_zalloc(srtp->pool, 64); 1051 1048 //hex_string_to_octet_string( 1052 1049 // raw_test_key, … … 1054 1051 // strlen(hex_test_key)); 1055 1052 //pj_strset(test_key, raw_test_key, 1056 1053 // crypto_suites[cs_idx].cipher_key_len); 1054 /* EO Force to use test key */ 1057 1055 1058 1056 if (tmp_rx_crypto.key.slen != 1059 1057 (int)crypto_suites[cs_idx].cipher_key_len) … … 1070 1068 } 1071 1069 1072 1070 if (srtp->setting.use == PJMEDIA_SRTP_DISABLED) { 1073 /* At this point, it is ensured remote has no crypto attr*/1071 /* Should never reach here */ 1074 1072 goto BYPASS_SRTP; 1075 1073 } else if (srtp->setting.use == PJMEDIA_SRTP_OPTIONAL) { 1076 1074 /* bypass SRTP when no crypto-attr but remote uses RTP/AVP */