zrtp.h File Reference

#include "zrtp_config.h"
#include "zrtp_base.h"
#include "zrtp_error.h"
#include "zrtp_types.h"
#include "zrtp_protocol.h"
#include "zrtp_engine.h"
#include "zrtp_crypto.h"
#include "zrtp_iface.h"
#include "zrtp_iface_system.h"
#include "zrtp_list.h"
#include "zrtp_legal.h"
#include "zrtp_log.h"
#include "zrtp_srtp.h"
#include "zrtp_srtp_builtin.h"
#include "zrtp_string.h"
#include "zrtp_pbx.h"

Go to the source code of this file.

Data Structures

struct  zrtp_config
 ZRTP global configuration options. More...
struct  zrtp_profile
 ZRTP stream profile As described in section 6.2 Session configuration, streams are configured with a profile scheme. Each profile is defined by a structure of the given type and contains a set of preferences for crypto components and other parameters. The values in the profile may be filled either by libzrtp zrtp_profile_autoload () or by the user manually. The profile is applied to the stream context on allocation by zrtp_attach_stream(). More...
struct  zrtp_sas_values
 SAS values storage In addition to string base32/base256 values, binary representation is available. Depending on the SAS scheme used during negotiation, str1 and str2 fields contain 4-character or string values. SAS strings, like all other zrtp-strings, are not null-terminated. More...
struct  zrtp_stream_ctx
 ZRTP stream context. More...
struct  zrtp_conn_ctx
 ZRTP session context Describes the state of the ZRTP session. Stores data necessary and sufficient for processing ZRTP sessions. Encapsulates ZRTP streams and all crypto-data. More...

Defines

#define ZRTP_BIT_RS1   0x02
#define ZRTP_BIT_RS2   0x04
#define ZRTP_BIT_AUX   0x10
#define ZRTP_BIT_PBX   0x20

Typedefs

typedef unsigned char zrtp_zid_t [12]
typedef char zrtp_client_id_t [16]
typedef zrtp_config zrtp_config_t
 ZRTP global configuration options.

Enumerations

enum  zrtp_license_mode_t { ZRTP_LICENSE_MODE_PASSIVE = 0, ZRTP_LICENSE_MODE_ACTIVE, ZRTP_LICENSE_MODE_UNLIMITED }
 Enumeration for ZRTP Licensing modes A ZRTP endpoint that is Passive will never send a Commit message, which means that it cannot be the initiator in the ZRTP exchange. Since at least one of the two parties must be the initiator, two Passive endpoints cannot make a secure connection. However, a non-Passive ZRTP endpoint can send a Commit message, enabling it to act as the initiator in a ZRTP exchange. This allows it to make a secure connection to a Passive endpoint, or to another non-Passive endpoint. More...

Functions

void zrtp_config_defaults (zrtp_config_t *config)
 Initializes libzrtp global config zrtp_config_defaults prepares all fields of zrtp_config_t for further usage. If the developer uses "enterprise" version of the libzrtp - zrtp_config_t::cb will be initialized with built-in realizations.
zrtp_global_ctx_t * zrtp_init (zrtp_config_t *config)
 Initializing libzrtp This function initializes the library and all its components. libzrtp will upload all available crypto-components implementations:
  • hash type calculation scheme (ZRTP_HASH_SHA256)
  • encryption schemes (ZRTP_CIPHER_AES128, ZRTP_CIPHER_AES256);
  • public key exchange scheme (ZRTP_PKTYPE_PRESH, ZRTP_PKTYPE_DH3072, ZRTP_PKTYPE_DH4096);
  • SAS schemes (ZRTP_SAS_BASE32, ZRTP_SAS_BASE256);
  • authentication schemes (ZRTP_ATL_HS32, ZRTP_ATL_HS80). zrtp_init() initialize global data for all sessions and streams. Fields of the global context are initialized automatically and shouldn't be modified. For correct memory management, global context should be released by calling zrtp_down().

zrtp_status_t zrtp_down (zrtp_global_ctx_t *zrtp_global)
 Shutting down the ZRTP library Frees all allocated structures and resources. This function must be called at the end of use to stop libzrtp correctly. zrtp_down() doesn't stop in-progress ZRTP streams. To avoid mistakes, close all sessions before library deinitialization.
zrtp_status_t zrtp_init_session_ctx (zrtp_conn_ctx_t *session_ctx, zrtp_global_ctx_t *zrtp_global, zrtp_profile_t *profile, zrtp_zid_t zid, uint8_t is_initiator)
 ZRTP Session context initialization. As explained in 3. Data structures, the session context is created in two steps: memory allocation for the external structure and internal data initialization. This function allocates and initializes the internal session context data. The given context is associated with the specified ZRTP identifier. Only after initialization does the session contain ZRTP_MAX_STREAMS_PER_SESSION streams ready to be used.
After successfully initialization, configuration will be done according to the relevant profile profile. Profile will be applyed to every stream allocated within this session. Profile must contain lists of the crypto-components and other required information. Applying the profile entails:
  • filling of all necessary structures;
  • HELLO packet construction;
  • priority range specification in the crypto components usage. Before the applying the profile, call zrtp_check_profile() function to make sure that the profile you are applying correct.

void zrtp_done_session_ctx (zrtp_conn_ctx_t *ctx)
 ZRTP Session context deinitialization Session context deinitialization also requires two steps: deinitializing internal context data and releasing upper-level structure memory. This function releases all resources allocated for internal context operations. The upper-level structure can be destroyed only after calling this function.
zrtp_stream_ctx_t * zrtp_attach_stream (zrtp_conn_ctx_t *session_ctx, uint32_t rtp_ssrc)
 Attaching a new stream to the session This function call initializes a ZRTP stream and prepares it for use within the specified session. The maximum number of streams for one session is defined by the types::ZRTP_MAX_STREAMS_PER_SESSION variable. All newly created streams are equivalent and have ZRTP_STREAM_MODE_CLEAR type mode. Only after attaching a stream can the ZRTP protocol be initiated.
zrtp_status_t zrtp_set_signaling_hash (zrtp_stream_ctx_t *stream_ctx, const char *hash_buff, uint32_t hash_buff_length)
 Specifies the hash of the peer Hello message for verification. In accordance with the ZRTP ID sec. 9.1, this protocol can prevent DOS attacks by verification of the Hello message hash sent through the signaling protocol. This function allows the user to specify the Hello hash for verification. If after the discovering phase the Hello hashes don't match, libzrtp raises the zrtp_event_t::ZRTP_EVENT_WRONG_SIGNALING_HASH event. This function should only be called before starting the protocol from the ZRTP_STATE_ACTIVE state.
zrtp_status_t zrtp_get_signaling_hash (zrtp_stream_ctx_t *stream_ctx, char *hash_buff, uint32_t hash_buff_length)
 Returns the hash of the Hello message to be transferred in signaling. To prevent DOS attacks, the hash of the Hello message may be sent through signaling. zrtp_get_signaling_hash() may be called after attaching the stream to receive the value of this hash.
void zrtp_start_stream (zrtp_stream_ctx_t *stream_ctx)
 Starting a ZRTP stream ZRTP stream setup is initiated by calling this function. Exchange of command packets begins immediately according to protocol. If the option "autosecure" is on, calling this function is the only requirement for setting up the first ZRTP connection within a stream. If "autosecure" mode is not available, calling this function activates only ZRTP stream. A connection can be activated manually by calling zrtp_secure_stream(). Within one stream several ZRTP connections can be setup and interrupted consecutively by calling zrtp_secure_stream() and zrtp_clear_stream(). Setup of the stream/connection takes a certain interval of time. This function just initiates this process. The system of callbacks informs the user about the progress of libzrtp protocol. Stream and connection initialization are described in section 7 Connection life-cycle and management in detail.
void zrtp_stop_stream (zrtp_stream_ctx_t *stream_ctx)
 ZRTP protocol stopping This function stops all protocol operations for the specified stream, releases resources allocated on the zrtp_start_stream() and prepares the stream structure for the next use. This function will stop the protocol at any stage: all delayed tasks are canceled, and the protocol packet exchange and encryption is stopped. After this function call it is necessary to stop processing traffic using the zrtp_process_xxx() function.
zrtp_status_t zrtp_clear_stream (zrtp_stream_ctx_t *stream_ctx)
 Initiating an interruption of the secure connection This function initiates the shutting down of the ZRTP connection within a stream. In other words, after successfully switching to secure mode (SECURE state, fig. 1.5), calling this function begins the exchange of packets switching to insecure (CLEAR) mode. This function can only be implemented from the SECURE state. Attempt to call this function from any other state will end in failure. The client application is informed about protocol progress through a system of callbacks.
zrtp_status_t zrtp_secure_stream (zrtp_stream_ctx_t *stream_ctx)
 Initiating a secure connection setup The function initiates a ZRTP connection setup within a stream. In other words, after the protocol has started and HELLO packets are successfully exchanged, calling this function will begin the exchange of packets for switching to SECURE mode. This function can be successfully performed only from the CLEAR state (Figure 1.6). Attempting to call this function from any other state will result in failure. The client application is informed about protocol progress through a system of callbacks.
zrtp_status_t zrtp_process_rtp (zrtp_stream_ctx_t *stream_ctx, char *packet, unsigned int *length)
 Processing outgoing RTP packets This is the main function for processing outgoing RTP packets. As soon as the protocol is started, each outgoing RTP packet (not encrypted) has to go through this function. It performs different actions depending on the connection state and packet type:
  • In setup ZRTP connection mode, it encrypts outgoing RTP packets. The packet is encrypted right in the transferred buffer;
  • Protects codec and data privacy by deleting certain packets from the stream. In this case the body and the length of the packet remain unchanged.

zrtp_status_t zrtp_process_srtp (zrtp_stream_ctx_t *stream_ctx, char *packet, unsigned int *length)
 Processing incoming RTP packets This is the main function for incoming RTP packets processing. It is an analogue of zrtp_process_rtp() but for an incoming stream. After the protocol is started, each (encrypted) incoming RTP packet has to go through this function. It performs different actions depending on the connection state and packet type:
  • during setup/interruption of ZRTP connection, processes incoming protocol packets. The body and length of the packet remain unchanged;
  • in setup ZRTP connection mode, decrypts incoming RTP packet. The packet is decrypted right in the transferred buffer;
  • protects codec and data privacy by deleting certain packets from the stream. In this case the body and the length of the packet remain unchanged.
    .

zrtp_status_t zrtp_process_rtcp (zrtp_stream_ctx_t *stream_ctx, char *packet, unsigned int *length)
 Processing outgoing RTCP packets This is the main function for processing outgoing RTCP packets. The function behavior is similar to that of zrtp_process_rtp():
  • In SECURE mode, encrypts outgoing RTCP packets. The packet is encrypted right in the transferred buffer. The length of encrypted packet is returned in the length variable;
  • protects codec and data privacy by deleting certain packets from the stream. In this case the body and the length of the packet remain unchanged.

zrtp_status_t zrtp_process_srtcp (zrtp_stream_ctx_t *stream_ctx, char *packet, unsigned int *length)
 Processing incoming RTCP packets This is the main function for processing incoming RTCP packets. The function behavior is similar to that of zrtp_process_srtp():
  • In SECURE mode, decrypts incoming RTCP packets. The packet is decrypted right in the transferred buffer. The length of the encrypted packet is returned in the length variable;
  • In transition states, drops all incoming RTCP traffic. In this case the body and the length of the packet remain unchanged.

zrtp_status_t zrtp_set_verified (zrtp_global_ctx_t *zrtp, zrtp_string16_t *zid1, zrtp_string16_t *zid2, uint8_t verified)
 Changing the value of the secret's verification flag This function is used to change (set, unset) the secret's verification flag. zrtp_set_verified() changes the relevant internal data and stores a flag in the cache. Special synchronization mechanisms are provided to protect the cache from race conditions. Don't change the verified flag directly in the cache - use this function.
zrtp_status_t zrtp_check_profile (const zrtp_profile_t *profile, zrtp_global_ctx_t *zrtp_global)
 Verifying the ZRTP profile zrtp_check_profile() checks the correctness of the values in the profile. This function is called automatically when zrtp_apply_profile() is called.
The following checks are performed:
  • the number of components in each group does not exceed ZRTP_MAX_COMP_COUNT;
  • the components declared are supported by the library kernel.
  • presence of the set of obligatory components defined by ZRTP Internet Draft.

void zrtp_profile_autoload (zrtp_profile_t *profile, zrtp_global_ctx_t *zrtp_global)
 Configure the default ZRTP profile These options are used:.
int zrtp_find_in_profile (const zrtp_profile_t *profile, zrtp_crypto_comp_t type, uint8_t id)
 Search for a component in the profile by ID The utility function returning the position of an element of the specified type in the profile. Used by libZRTP kernel and for external use.
int zrtp_add_entropy (zrtp_global_ctx_t *zrtp_global, const unsigned char *buffer, uint32_t length)
 Entropy accumulation The random number generation scheme is described in detail in chapter 5 Random number generation. This function gets length bytes of entropy from buffer and hashes it into the special storage. This function should be called periodically from the user's space to increase entropy quality.
int zrtp_randstr (zrtp_global_ctx_t *zrtp_global, unsigned char *buffer, uint32_t length)
 Random string generation zrtp_randstr() generates length bytes of "random" data. We say "random" because the "randomness" of the generated sequence depends on the quality of the entropy passed to zrtp_add_entropy(). If the user provides "good" entropy, zrtp_randstr() generates sufficiently "random" data.


This file is part of the documentation for Zfone.
Copyright ©  2006-2008 Philip R. Zimmermann. All rights reserved.
Generated on Mon November 10 2008 by doxygen 1.5.7-20060202. Written by Viktor Krikun, © 2006-2008