/*----------------------------------------------------------------------------*/ zrtp_status_t zrtp_down(zrtp_global_t* zrtp) { ZRTP_LOG(3, (_ZTU_,"DESTROYING LIBZRTP...\n")); if (!zrtp) { return zrtp_status_bad_param; } zrtp_comp_done(ZRTP_CC_HASH, zrtp); zrtp_comp_done(ZRTP_CC_SAS, zrtp); zrtp_comp_done(ZRTP_CC_CIPHER, zrtp); zrtp_comp_done(ZRTP_CC_PKT, zrtp); zrtp_comp_done(ZRTP_CC_ATL, zrtp); zrtp_done_pkt(zrtp); zrtp_mutex_destroy(zrtp->sessions_protector); zrtp_srtp_down(zrtp); if (zrtp->cb.cache_cb.on_down) { zrtp->cb.cache_cb.on_down(); } if (zrtp->cb.sched_cb.on_down) { zrtp->cb.sched_cb.on_down(); } zrtp_down_rng(zrtp); zrtp_sys_free(zrtp); ZRTP_LOG(3, (_ZTU_,"DESTROYING LIBZRTP - DONE\n")); return zrtp_status_ok; }
void zrtp_down_rng(zrtp_global_t* zrtp) { if (zrtp->rand_initialized) { zrtp_mutex_destroy(zrtp->rng_protector); #if (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN64) || (ZRTP_PLATFORM == ZP_WINCE) NtLmCleanupRNG(); #endif zrtp->rand_initialized = 0; } }
/*----------------------------------------------------------------------------*/ void zrtp_session_down(zrtp_session_t *session) { int i =0; if (!session) { return; } /* Stop ZRTP engine and clear all crypto sources for every stream in the session. */ zrtp_mutex_lock(session->streams_protector); for(i=0; i<ZRTP_MAX_STREAMS_PER_SESSION; i++) { zrtp_stream_t *the_stream = &session->streams[i]; zrtp_stream_stop(the_stream); } zrtp_mutex_unlock(session->streams_protector); /* Release memory allocated on initialization */ if (session->secrets.rs1) { zrtp_sys_free(session->secrets.rs1); } if (session->secrets.rs2) { zrtp_sys_free(session->secrets.rs2); } if (session->secrets.auxs) { zrtp_sys_free(session->secrets.auxs); } if (session->secrets.pbxs) { zrtp_sys_free(session->secrets.pbxs); } /* We don't need the session key anymore - clear it */ zrtp_wipe_zstring(ZSTR_GV(session->zrtpsess)); /* Removing session from the global list */ zrtp_mutex_lock(session->zrtp->sessions_protector); mlist_del(&session->_mlist); zrtp_mutex_unlock(session->zrtp->sessions_protector); zrtp_mutex_destroy(session->streams_protector); zrtp_mutex_destroy(session->init_protector); zrtp_sys_free(session); }