11 #ifndef __ZRTP_TYPES_H__
12 #define __ZRTP_TYPES_H__
14 #include "zrtp_config.h"
16 #include "zrtp_base.h"
18 #include "zrtp_list.h"
19 #include "zrtp_legal.h"
20 #include "zrtp_string.h"
21 #include "zrtp_protocol.h"
22 #include "zrtp_cache.h"
56 #if (defined(ZRTP_BUILD_FOR_CSD) && (ZRTP_BUILD_FOR_CSD == 1))
57 ZRTP_STATE_DRIVEN_INITIATOR,
58 ZRTP_STATE_DRIVEN_RESPONDER,
59 ZRTP_STATE_DRIVEN_PENDING,
71 ZRTP_STREAM_MODE_UNKN = 0,
190 typedef enum zrtp_mitm_mode_t
193 ZRTP_MITM_MODE_UNKN = 0,
201 ZRTP_MITM_MODE_CLIENT,
208 ZRTP_MITM_MODE_RECONFIRM_SERVER,
214 ZRTP_MITM_MODE_RECONFIRM_CLIENT,
221 ZRTP_MITM_MODE_REG_SERVER,
228 ZRTP_MITM_MODE_REG_CLIENT
263 ZRTP_CONFIRM2ACK = 8,
265 ZRTP_GOCLEARACK = 10,
272 ZRTP_ZFONEPINGACK = 17,
273 ZRTP_MSG_TYPE_COUNT = 18
282 typedef enum zrtp_statemachine_type_t
284 ZRTP_STATEMACHINE_NONE = 0,
285 ZRTP_STATEMACHINE_INITIATOR = 1,
286 ZRTP_STATEMACHINE_RESPONDER = 2
287 } zrtp_statemachine_type_t;
289 #define ZRTP_BIT_RS1 0x02
290 #define ZRTP_BIT_RS2 0x04
291 #define ZRTP_BIT_AUX 0x10
292 #define ZRTP_BIT_PBX 0x20
319 uint8_t rand_initialized;
321 zrtp_mutex_t* rng_protector;
324 struct BigNum P_2048;
325 struct BigNum P_2048_1;
326 struct BigNum P_3072;
327 struct BigNum P_3072_1;
328 uint8_t P_2048_data[256];
329 uint8_t P_3072_data[384];
336 mlist_t sessions_head;
337 uint32_t sessions_count;
338 uint32_t streams_count;
339 zrtp_mutex_t* sessions_protector;
350 typedef struct zrtp_rtp_info_t
362 zrtp_msg_type_t type;
380 typedef struct zrtp_secrets_t
383 zrtp_shared_secret_t *rs1;
386 zrtp_shared_secret_t *rs2;
389 zrtp_shared_secret_t *auxs;
392 zrtp_shared_secret_t *pbxs;
396 uint32_t cached_curr;
400 uint32_t matches_curr;
404 uint32_t wrongs_curr;
416 typedef struct zrtp_proto_secret_t
425 zrtp_shared_secret_t *secret;
426 } zrtp_proto_secret_t;
436 typedef struct zrtp_stream_mescache_t
438 zrtp_packet_Hello_t peer_hello;
439 zrtp_packet_Hello_t hello;
440 zrtp_packet_GoClear_t goclear;
441 zrtp_packet_Commit_t peer_commit;
442 zrtp_packet_Commit_t commit;
443 zrtp_packet_DHPart_t peer_dhpart;
444 zrtp_packet_DHPart_t dhpart;
445 zrtp_packet_Confirm_t confirm;
447 zrtp_packet_Confirm_t peer_confirm;
448 zrtp_packet_Error_t error;
449 zrtp_packet_SASRelay_t sasrelay;
467 } zrtp_stream_mescache_t;
475 typedef struct zrtp_dh_crypto_context_t
484 struct BigNum peer_pv;
489 unsigned int initialized_with;
490 } zrtp_dh_crypto_context_t;
498 typedef struct zrtp_dsa_crypto_context_t
502 struct BigNum peer_pv;
503 } zrtp_dsa_crypto_context_t;
512 typedef struct zrtp_proto_crypto_t
530 zrtp_proto_secret_t rs1;
533 zrtp_proto_secret_t rs2;
536 zrtp_proto_secret_t auxs;
539 zrtp_proto_secret_t pbxs;
540 } zrtp_proto_crypto_t;
548 struct zrtp_protocol_t
551 zrtp_statemachine_type_t type;
554 zrtp_proto_crypto_t* cc;
557 zrtp_srtp_ctx_t* _srtp;
560 zrtp_stream_t *context;
568 typedef struct zrtp_stream_crypto_t
581 } zrtp_stream_crypto_t;
587 typedef struct zrtp_media_context_t
590 uint32_t high_in_zrtp_seq;
593 uint32_t high_out_zrtp_seq;
596 uint32_t high_in_media_seq;
599 uint32_t high_out_media_seq;
603 } zrtp_media_context_t;
629 zrtp_mitm_mode_t mitm_mode;
639 uint8_t is_hello_received;
649 zrtp_stream_crypto_t cc;
652 zrtp_dh_crypto_context_t dh_cc;
660 zrtp_protocol_t *protocol;
663 zrtp_media_context_t media_ctx;
666 zrtp_stream_mescache_t messages;
678 uint8_t peer_passive;
697 uint8_t peer_disclose_bit;
711 uint8_t peer_mitm_flag;
716 uint8_t peer_super_flag;
729 zrtp_stream_t *concurrent;
735 zrtp_session_t *session;
738 zrtp_pk_scheme_t *pubkeyscheme;
750 zrtp_stream_t *linked_mitm;
758 zrtp_mutex_t* stream_protector;
767 struct zrtp_session_t
787 unsigned signaling_role;
794 zrtp_secrets_t secrets;
818 zrtp_cipher_t *blockcipher;
821 zrtp_auth_tag_length_t *authtaglength;
824 zrtp_sas_scheme_t *sasscheme;
830 zrtp_mutex_t* streams_protector;
833 zrtp_mutex_t* init_protector;
838 uint8_t mitm_alert_detected;
850 #if ZRTP_BYTE_ORDER == ZBO_LITTLE_ENDIAN
877 unsigned char version:2;
885 unsigned int index:31;
889 } zrtp_rtcp_trailer_t;
916 unsigned char version:2;
927 unsigned int index:31;
928 } zrtp_rtcp_trailer_t;
938 uint16_t profile_specific;
940 } zrtp_rtp_hdr_xtnd_t;