00001
00002
00003
00004
00005
00006
00007
00008
00009
00015 #ifndef __ZRTP_H__
00016 #define __ZRTP_H__
00017
00018 #include "zrtp_config.h"
00019 #include "zrtp_base.h"
00020 #include "zrtp_error.h"
00021 #include "zrtp_types.h"
00022 #include "zrtp_protocol.h"
00023 #include "zrtp_engine.h"
00024 #include "zrtp_crypto.h"
00025 #include "zrtp_iface.h"
00026 #include "zrtp_iface_system.h"
00027 #include "zrtp_iface_scheduler.h"
00028 #include "zrtp_list.h"
00029 #include "zrtp_legal.h"
00030 #include "zrtp_log.h"
00031 #include "zrtp_srtp.h"
00032 #include "zrtp_srtp_builtin.h"
00033 #include "zrtp_string.h"
00034 #include "zrtp_pbx.h"
00035 #include "zrtp_legal.h"
00036 #include "zrtp_version.h"
00037 #include "zrtp_iface_cache.h"
00038 #if (defined(ZRTP_ENABLE_EC) && (ZRTP_ENABLE_EC == 1))
00039 #include "zrtp_ec.h"
00040 #endif
00041
00042
00043
00067
00068
00069
00070
00071
00108 typedef enum zrtp_license_mode_t
00109 {
00111 ZRTP_LICENSE_MODE_PASSIVE = 0,
00113 ZRTP_LICENSE_MODE_ACTIVE,
00115 ZRTP_LICENSE_MODE_UNLIMITED
00116 } zrtp_license_mode_t;
00117
00118
00120 typedef unsigned char zrtp_zid_t[12];
00121
00123 typedef char zrtp_client_id_t[16];
00124
00130 typedef struct zrtp_config_t
00131 {
00133 zrtp_client_id_t client_id;
00134
00136 zrtp_license_mode_t lic_mode;
00137
00139 uint8_t is_mitm;
00140
00142 zrtp_callback_t cb;
00143
00145 zrtp_string128_t def_cache_path;
00146 } zrtp_config_t;
00147
00157 struct zrtp_stream_info_t
00158 {
00160 zrtp_id_t id;
00161
00163 zrtp_session_t* session;
00164
00166 zrtp_stream_mode_t mode;
00167
00169 zrtp_mitm_mode_t mitm_mode;
00170
00172 zrtp_state_t state;
00173
00179 zrtp_protocol_error_t last_error;
00180
00187 uint8_t peer_passive;
00188
00195 uint8_t res_allowclear;
00196
00204 uint8_t peer_disclose;
00205
00212 uint8_t peer_mitm;
00213 };
00214
00223 struct zrtp_session_info_t
00224 {
00226 zrtp_id_t id;
00227
00234 zrtp_string16_t zid;
00235
00242 zrtp_string16_t peer_zid;
00243
00245 zrtp_string16_t peer_clientid;
00246
00248 zrtp_string16_t peer_version;
00249
00256 uint8_t sas_is_ready;
00257
00259 zrtp_string16_t sas1;
00260
00267 zrtp_string16_t sas2;
00268
00270 zrtp_string32_t sasbin;
00271
00281 uint32_t cached_flags;
00282
00293 uint32_t matches_flags;
00294
00304 uint32_t wrongs_flags;
00305
00316 uint32_t sas_is_verified;
00317
00319 uint8_t sas_is_base256;
00320
00328 uint32_t secrets_ttl;
00329
00331 zrtp_string32_t hash_name;
00332
00334 zrtp_string32_t cipher_name;
00335
00337 zrtp_string32_t auth_name;
00338
00340 zrtp_string32_t sas_name;
00341
00343 zrtp_string32_t pk_name;
00344 };
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 #if defined(__cplusplus)
00355 extern "C"
00356 {
00357 #endif
00358
00375 void zrtp_config_defaults(zrtp_config_t* config);
00376
00392 zrtp_status_t zrtp_init(zrtp_config_t* config, zrtp_global_t** zrtp);
00393
00407 zrtp_status_t zrtp_down(zrtp_global_t* zrtp);
00408
00409
00410
00444 zrtp_status_t zrtp_session_init( zrtp_global_t* zrtp,
00445 zrtp_profile_t* profile,
00446 zrtp_zid_t zid,
00447 uint8_t is_initiator,
00448 zrtp_session_t **session);
00458 void zrtp_session_down(zrtp_session_t *session);
00459
00460
00473 zrtp_status_t zrtp_session_get(zrtp_session_t *session, zrtp_session_info_t *info);
00474
00481 void zrtp_session_set_userdata(zrtp_session_t *session, void* udata);
00482
00491 void* zrtp_session_get_userdata(zrtp_session_t *session);
00492
00509 zrtp_status_t zrtp_stream_attach(zrtp_session_t *session, zrtp_stream_t** stream);
00510
00533 zrtp_status_t zrtp_stream_start(zrtp_stream_t* stream, uint32_t ssrc);
00534
00553 zrtp_status_t zrtp_stream_stop(zrtp_stream_t* stream);
00554
00574 zrtp_status_t zrtp_stream_clear(zrtp_stream_t *stream);
00575
00595 zrtp_status_t zrtp_stream_secure(zrtp_stream_t *stream);
00596
00609 zrtp_status_t zrtp_stream_get(zrtp_stream_t *stream, zrtp_stream_info_t *info);
00610
00617 void zrtp_stream_set_userdata(zrtp_stream_t *stream, void* udata);
00618
00626 void* zrtp_stream_get_userdata(const zrtp_stream_t *stream);
00627
00628
00629
00630
00631
00632
00633
00667 zrtp_status_t zrtp_process_rtp( zrtp_stream_t *stream,
00668 char* packet,
00669 unsigned int* length);
00670
00699 zrtp_status_t zrtp_process_srtp( zrtp_stream_t *stream,
00700 char* packet,
00701 unsigned int* length);
00702
00723 zrtp_status_t zrtp_process_rtcp( zrtp_stream_t *stream,
00724 char* packet,
00725 unsigned int* length);
00726
00747 zrtp_status_t zrtp_process_srtcp( zrtp_stream_t *stream,
00748 char* packet,
00749 unsigned int* length);
00750
00751
00752
00780 zrtp_status_t zrtp_signaling_hash_set( zrtp_stream_t* stream,
00781 const char *hash_buff,
00782 uint32_t hash_buff_length);
00783
00802 zrtp_status_t zrtp_signaling_hash_get( zrtp_stream_t* stream,
00803 char* hash_buff,
00804 uint32_t hash_buff_length);
00805
00823 zrtp_status_t zrtp_verified_set( zrtp_global_t *zrtp,
00824 zrtp_string16_t *zid1,
00825 zrtp_string16_t *zid2,
00826 uint8_t verified);
00827
00844 zrtp_status_t zrtp_profile_check(const zrtp_profile_t* profile, zrtp_global_t* zrtp);
00845
00867 void zrtp_profile_defaults(zrtp_profile_t* profile, zrtp_global_t* zrtp);
00868
00882 int zrtp_profile_find(const zrtp_profile_t* profile, zrtp_crypto_comp_t type, uint8_t id);
00883
00884
00885
00911 int zrtp_entropy_add(zrtp_global_t* zrtp, const unsigned char *buffer, uint32_t length);
00912
00928 int zrtp_randstr(zrtp_global_t* zrtp, unsigned char *buffer, uint32_t length);
00929
00930
00931
00932 #if defined(__cplusplus)
00933 }
00934 #endif
00935
00936 #endif