Commit 2abbb7ae authored by johan's avatar johan

Zrtp manages zrtp-hash attribute

parent 64c7fbaa
......@@ -724,6 +724,8 @@ MS2_PUBLIC float audio_stream_get_average_lq_quality_rating(AudioStream *stream)
/* enable ZRTP on the audio stream */
MS2_PUBLIC void audio_stream_enable_zrtp(AudioStream *stream, MSZrtpParams *params);
MS2_PUBLIC void audio_stream_start_zrtp(AudioStream *stream);
/**
* return TRUE if zrtp is enabled, it does not mean that stream is encrypted, but only that zrtp is configured to know encryption status, uses #
* */
......@@ -1038,7 +1040,8 @@ MS2_PUBLIC void video_stream_recv_only_stop(VideoStream *vs);
MS2_PUBLIC void video_stream_send_only_stop(VideoStream *vs);
/* enable ZRTP on the video stream using information from the audio stream */
MS2_PUBLIC void video_stream_enable_zrtp(VideoStream *vstream, AudioStream *astream, MSZrtpParams *param);
MS2_PUBLIC void video_stream_enable_zrtp(VideoStream *vstream, AudioStream *astream);
MS2_PUBLIC void video_stream_start_zrtp(VideoStream *stream);
/* enable SRTP on the video stream */
static MS2_INLINE bool_t video_stream_enable_strp(VideoStream* stream, MSCryptoSuite suite, const char* snd_key, const char* rcv_key) {
......
......@@ -31,6 +31,9 @@ extern "C"{
struct _MSMediaStreamSessions;
/* Error codes */
#define MSZRTP_ERROR_CHANNEL_ALREADY_STARTED -0x0001
#define MS_MAX_ZRTP_CRYPTO_TYPES 7
typedef uint8_t MsZrtpCryptoTypesCount;
......@@ -113,10 +116,16 @@ MS2_PUBLIC MSZrtpContext* ms_zrtp_context_new(struct _MSMediaStreamSessions *str
* Create an initialise a ZRTP context on a channel when a ZRTP exchange was already performed on an other one
* @param[in] stream_sessions A link to the stream sessions structures, used to get rtp session to add transport modifier and needed to set SRTP sessions when keys are ready
* @param[in] activeContext The MSZRTP context of the already active session, used to pass to lib bzrtp its own context which shall remain unique.
* @param[in] params ZID cache filename and peer sip uri
* @return a pointer to the opaque context structure needed by MSZRTP
*/
MS2_PUBLIC MSZrtpContext* ms_zrtp_multistream_new(struct _MSMediaStreamSessions *stream_sessions, MSZrtpContext* activeContext, MSZrtpParams *params);
MS2_PUBLIC MSZrtpContext* ms_zrtp_multistream_new(struct _MSMediaStreamSessions *stream_sessions, MSZrtpContext* activeContext);
/***
* Start a previously created ZRTP channel, ZRTP engine will start sending Hello packets
* @param[in] ctx Context previously created using ms_zrtp_context_new or ms_zrtp_multistream_new
* @return 0 on success
*/
MS2_PUBLIC int ms_zrtp_channel_start(MSZrtpContext *ctx);
/**
* Free ressources used by ZRTP context
......@@ -143,6 +152,23 @@ MS2_PUBLIC void ms_zrtp_sas_verified(MSZrtpContext* ctx);
*/
MS2_PUBLIC void ms_zrtp_sas_reset_verified(MSZrtpContext* ctx);
/**
* Get the ZRTP Hello Hash from the given context
* @param[in] ctx MSZRTP context
* @param[out] The Zrtp Hello Hash as defined in RFC6189 section 8
*/
MS2_PUBLIC int ms_zrtp_getHelloHash(MSZrtpContext* ctx, uint8_t *output, size_t outputLength);
/**
* Set the peer ZRTP Hello Hash to the given context
* @param[in] ctx MSZRTP context
* @param[in] The Zrtp Hello Hash as defined in RFC6189 section 8
* @param[in] The Zrtp Hello Hash length
*
* @return 0 on succes, Error code otherwise
*/
MS2_PUBLIC int ms_zrtp_setPeerHelloHash(MSZrtpContext *ctx, uint8_t *peerHelloHashHexString, size_t peerHelloHashHexStringLength);
/**
* from_string and to_string for enums: MSZrtpHash, MSZrtpCipher, MSZrtpAuthTag, MSZrtpKeyAgreement, MSZrtpSasType
*/
......
This diff is collapsed.
......@@ -1746,6 +1746,16 @@ void audio_stream_enable_zrtp(AudioStream *stream, MSZrtpParams *params){
ms_zrtp_reset_transmition_timer(stream->ms.sessions.zrtp_context);
}
void audio_stream_start_zrtp(AudioStream *stream) {
if (stream->ms.sessions.zrtp_context!=NULL) {
if (ms_zrtp_channel_start(stream->ms.sessions.zrtp_context) == MSZRTP_ERROR_CHANNEL_ALREADY_STARTED) {
ms_zrtp_reset_transmition_timer(stream->ms.sessions.zrtp_context);
}
} else {
ms_warning("Trying to start a ZRTP channel on audiostream, but none was enabled");
}
}
bool_t audio_stream_zrtp_enabled(const AudioStream *stream) {
return stream->ms.sessions.zrtp_context!=NULL;
}
......
......@@ -1652,13 +1652,23 @@ void video_stream_send_only_stop(VideoStream *vs){
}
/* enable ZRTP on the video stream using information from the audio stream */
void video_stream_enable_zrtp(VideoStream *vstream, AudioStream *astream, MSZrtpParams *param){
void video_stream_enable_zrtp(VideoStream *vstream, AudioStream *astream){
if (astream->ms.sessions.zrtp_context != NULL && vstream->ms.sessions.zrtp_context == NULL) {
vstream->ms.sessions.zrtp_context=ms_zrtp_multistream_new(&(vstream->ms.sessions), astream->ms.sessions.zrtp_context, param);
vstream->ms.sessions.zrtp_context=ms_zrtp_multistream_new(&(vstream->ms.sessions), astream->ms.sessions.zrtp_context);
} else if (vstream->ms.sessions.zrtp_context && !media_stream_secured(&vstream->ms))
ms_zrtp_reset_transmition_timer(vstream->ms.sessions.zrtp_context);
}
void video_stream_start_zrtp(VideoStream *stream) {
if (stream->ms.sessions.zrtp_context!=NULL) {
if (ms_zrtp_channel_start(stream->ms.sessions.zrtp_context) == MSZRTP_ERROR_CHANNEL_ALREADY_STARTED) {
ms_zrtp_reset_transmition_timer(stream->ms.sessions.zrtp_context);
}
} else {
ms_warning("Trying to start a ZRTP channel on videotream, but none was enabled");
}
}
void video_stream_enable_display_filter_auto_rotate(VideoStream* stream, bool_t enable) {
stream->display_filter_auto_rotate_enabled = enable;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment