Пример #1
0
static void ortp_zrtp_configure(ZrtpContext *context){
	zrtp_InitializeConfig(context);
	zrtp_setMandatoryOnly(context);
	zrtp_setTrustedMitM(context,FALSE);//because it is uninitialized in zrtpcpp.
	zrtp_setSasSignature(context,FALSE);//because it is uninitialized in zrtpcpp.
}
Пример #2
0
/* Initialize the ZRTP transport and the user callbacks */
pjmedia_transport* on_zrtp_transport_created(pjsua_call_id call_id,
	unsigned media_idx,
	pjmedia_transport *base_tp,
	unsigned flags) {
        pjsua_call *call;
		pjmedia_transport *zrtp_tp = NULL;
		pj_status_t status;
		pjmedia_endpt* endpt = pjsua_get_pjmedia_endpt();

		// For now, do zrtp only on audio stream
        call = &pjsua_var.calls[call_id];
        if (media_idx < call->med_prov_cnt) {
            pjsua_call_media *call_med = &call->media_prov[media_idx];
            if (call_med->tp && call_med->type != PJMEDIA_TYPE_AUDIO) {
                PJ_LOG(2, (THIS_FILE, "ZRTP transport not yet supported for : %d", call_med->type));
                return base_tp;
            }
        }

	    // Create zrtp transport adapter
		status = pjmedia_transport_zrtp_create(endpt, NULL, base_tp,
											   &zrtp_tp, (flags & PJSUA_MED_TP_CLOSE_MEMBER));

		if(status == PJ_SUCCESS){
			PJ_LOG(4,(THIS_FILE, "ZRTP transport created"));
			// TODO : we should use our own pool
			// Build callback data ponter
			zrtp_cb_user_data* zrtp_cb_data = PJ_POOL_ZALLOC_T(css_var.pool, zrtp_cb_user_data);
			zrtp_cb_data->zrtp_tp = zrtp_tp;
			zrtp_cb_data->call_id = call_id;
			zrtp_cb_data->cipher = pj_str("");
			zrtp_cb_data->sas = pj_str("");
			zrtp_cb_data->sas_verified = PJ_FALSE;


			// Build callback struct
			zrtp_UserCallbacks* zrtp_cbs = PJ_POOL_ZALLOC_T(css_var.pool, zrtp_UserCallbacks);
			zrtp_cbs->zrtp_secureOn = &zrtpSecureOn;
			zrtp_cbs->zrtp_secureOff = &zrtpSecureOff;
			zrtp_cbs->zrtp_showSAS = &zrtpShowSas;
			zrtp_cbs->zrtp_confirmGoClear = &confirmGoClear;
			zrtp_cbs->zrtp_showMessage = &showMessage;
			zrtp_cbs->zrtp_zrtpNegotiationFailed = &zrtpNegotiationFailed;
			zrtp_cbs->zrtp_zrtpNotSuppOther = &zrtpNotSuppOther;
			zrtp_cbs->zrtp_zrtpAskEnrollment = &zrtpAskEnrollment;
			zrtp_cbs->zrtp_zrtpInformEnrollment = &zrtpInformEnrollment;
			zrtp_cbs->zrtp_signSAS = &signSAS;
			zrtp_cbs->zrtp_checkSASSignature = &checkSASSignature;
			zrtp_cbs->userData = zrtp_cb_data;

			pjmedia_transport_zrtp_setUserCallback(zrtp_tp, zrtp_cbs);


			/*
			* Initialize the transport. Just the filename of the ZID file that holds
			* our partners ZID, shared data etc. If the files does not exists it will
			* be created an initialized. The ZRTP configuration is not yet implemented
			* thus the parameter is NULL.
			*/
			pjmedia_transport_zrtp_initialize(zrtp_tp, css_var.zid_file, PJ_TRUE);
#if 0
			// This is a crappy hack for buggy versions of sip servers that does not correctly manage hello
			ZrtpContext* zrtpContext = pjmedia_transport_zrtp_getZrtpContext(zrtp_tp);
			zrtp_setMandatoryOnly(zrtpContext);
#endif

			return zrtp_tp;
		} else {
			PJ_LOG(1, (THIS_FILE, "ZRTP transport problem : %d", status));
			return base_tp;
		}
}