⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srtp.h

📁 mediastreamer2是开源的网络传输媒体流的库
💻 H
📖 第 1 页 / 共 3 页
字号:
 *  * The function call crypto_policy_set_rtp_default(&policy, profile) * sets the crypto_policy_t at location policy to the policy for RTP * protection, as defined by the srtp_profile_t profile. *  * This function is a convenience that helps to avoid dealing directly * with the policy data structure.  You are encouraged to initialize * policy elements with this function call.  Doing so may allow your * code to be forward compatible with later versions of libSRTP that * include more elements in the crypto_policy_t datatype. *  * @return values *     - err_status_ok         no problems were encountered *     - err_status_bad_param  the profile is not supported  *  */err_status_tcrypto_policy_set_from_profile_for_rtp(crypto_policy_t *policy, 				       srtp_profile_t profile);/** * @brief crypto_policy_set_from_profile_for_rtcp() sets a crypto policy * structure to the appropriate value for RTCP based on an srtp_profile_t * * @param p is a pointer to the policy structure to be set  *  * The function call crypto_policy_set_rtcp_default(&policy, profile) * sets the crypto_policy_t at location policy to the policy for RTCP * protection, as defined by the srtp_profile_t profile. *  * This function is a convenience that helps to avoid dealing directly * with the policy data structure.  You are encouraged to initialize * policy elements with this function call.  Doing so may allow your * code to be forward compatible with later versions of libSRTP that * include more elements in the crypto_policy_t datatype. *  * @return values *     - err_status_ok         no problems were encountered *     - err_status_bad_param  the profile is not supported  *  */err_status_tcrypto_policy_set_from_profile_for_rtcp(crypto_policy_t *policy, 				       srtp_profile_t profile);/** * @brief returns the master key length for a given SRTP profile */unsigned intsrtp_profile_get_master_key_length(srtp_profile_t profile);/** * @brief returns the master salt length for a given SRTP profile */unsigned intsrtp_profile_get_master_salt_length(srtp_profile_t profile);/** * @brief appends the salt to the key * * The function call append_salt_to_key(k, klen, s, slen)  * copies the string s to the location at klen bytes following * the location k.   * * @warning There must be at least bytes_in_salt + bytes_in_key bytes *          available at the location pointed to by key. *  */voidappend_salt_to_key(unsigned char *key, unsigned int bytes_in_key,		   unsigned char *salt, unsigned int bytes_in_salt);/** * @} *//** * @defgroup SRTCP Secure RTCP * @ingroup  SRTP  * * @brief Secure RTCP functions are used to protect RTCP traffic. * * RTCP is the control protocol for RTP.  libSRTP protects RTCP * traffic in much the same way as it does RTP traffic.  The function * srtp_protect_rtcp() applies cryptographic protections to outbound * RTCP packets, and srtp_unprotect_rtcp() verifies the protections on * inbound RTCP packets.   * * A note on the naming convention: srtp_protect_rtcp() has an srtp_t * as its first argument, and thus has `srtp_' as its prefix.  The * trailing `_rtcp' indicates the protocol on which it acts.   *  * @{ *//** * @brief srtp_protect_rtcp() is the Secure RTCP sender-side packet * processing function. *  * The function call srtp_protect_rtcp(ctx, rtp_hdr, len_ptr) applies * SRTCP protection to the RTCP packet rtcp_hdr (which has length * *len_ptr) using the SRTP session context ctx.  If err_status_ok is * returned, then rtp_hdr points to the resulting SRTCP packet and * *len_ptr is the number of octets in that packet; otherwise, no * assumptions should be made about the value of either data elements. *  * @warning This function assumes that it can write the authentication * tag into the location in memory immediately following the RTCP * packet, and assumes that the RTCP packet is aligned on a 32-bit * boundary. * * @param ctx is the SRTP context to use in processing the packet. * * @param rtcp_hdr is a pointer to the RTCP packet (before the call); after * the function returns, it points to the srtp packet. * * @param pkt_octet_len is a pointer to the length in octets of the * complete RTCP packet (header and body) before the function call, * and of the complete SRTCP packet after the call, if err_status_ok * was returned.  Otherwise, the value of the data to which it points * is undefined. * * @return  *    - err_status_ok            if there were no problems. *    - [other]                  if there was a failure in  *                               the cryptographic mechanisms. */	     err_status_t srtp_protect_rtcp(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len);/** * @brief srtp_unprotect_rtcp() is the Secure RTCP receiver-side packet * processing function. * * The function call srtp_unprotect_rtcp(ctx, srtp_hdr, len_ptr) * verifies the Secure RTCP protection of the SRTCP packet pointed to * by srtcp_hdr (which has length *len_ptr), using the SRTP session * context ctx.  If err_status_ok is returned, then srtcp_hdr points * to the resulting RTCP packet and *len_ptr is the number of octets * in that packet; otherwise, no assumptions should be made about the * value of either data elements. *  * @warning This function assumes that the SRTCP packet is aligned on a * 32-bit boundary. * * @param ctx is a pointer to the srtp_t which applies to the * particular packet. * * @param srtcp_hdr is a pointer to the header of the SRTCP packet * (before the call).  After the function returns, it points to the * rtp packet if err_status_ok was returned; otherwise, the value of * the data to which it points is undefined. * * @param pkt_octet_len is a pointer to the length in octets of the * complete SRTCP packet (header and body) before the function call, * and of the complete rtp packet after the call, if err_status_ok was * returned.  Otherwise, the value of the data to which it points is * undefined. * * @return  *    - err_status_ok          if the RTCP packet is valid. *    - err_status_auth_fail   if the SRTCP packet failed the message  *                             authentication check. *    - err_status_replay_fail if the SRTCP packet is a replay (e.g. has *                             already been processed and accepted). *    - [other]  if there has been an error in the cryptographic mechanisms. * */err_status_t srtp_unprotect_rtcp(srtp_t ctx, void *srtcp_hdr, int *pkt_octet_len);/** * @} *//** * @defgroup SRTPevents SRTP events and callbacks * @ingroup  SRTP * * @brief libSRTP can use a user-provided callback function to  * handle events. * *  * libSRTP allows a user to provide a callback function to handle * events that need to be dealt with outside of the data plane (see * the enum srtp_event_t for a description of these events).  Dealing * with these events is not a strict necessity; they are not * security-critical, but the application may suffer if they are not * handled.  The function srtp_set_event_handler() is used to provide * the callback function. * * A default event handler that merely reports on the events as they * happen is included.  It is also possible to set the event handler * function to NULL, in which case all events will just be silently * ignored. * * @{ *//** * @brief srtp_event_t defines events that need to be handled * * The enum srtp_event_t defines events that need to be handled * outside the `data plane', such as SSRC collisions and  * key expirations.   * * When a key expires or the maximum number of packets has been * reached, an SRTP stream will enter an `expired' state in which no * more packets can be protected or unprotected.  When this happens, * it is likely that you will want to either deallocate the stream * (using srtp_stream_dealloc()), and possibly allocate a new one. * * When an SRTP stream expires, the other streams in the same session * are unaffected, unless key sharing is used by that stream.  In the * latter case, all of the streams in the session will expire. */typedef enum {   event_ssrc_collision,    /**<			    * An SSRC collision occured.             			    */  event_key_soft_limit,    /**< An SRTP stream reached the soft key			    *   usage limit and will expire soon.	   			    */  event_key_hard_limit,    /**< An SRTP stream reached the hard 			    *   key usage limit and has expired.			    */  event_packet_index_limit /**< An SRTP stream reached the hard 			    * packet limit (2^48 packets).             			    */} srtp_event_t;/** * @brief srtp_event_data_t is the structure passed as a callback to  * the event handler function * * The struct srtp_event_data_t holds the data passed to the event * handler function.   */typedef struct srtp_event_data_t {  srtp_t        session;  /**< The session in which the event happend. */  srtp_stream_t stream;   /**< The stream in which the event happend.  */  srtp_event_t  event;    /**< An enum indicating the type of event.   */} srtp_event_data_t;/** * @brief srtp_event_handler_func_t is the function prototype for * the event handler. * * The typedef srtp_event_handler_func_t is the prototype for the * event handler function.  It has as its only argument an * srtp_event_data_t which describes the event that needs to be handled. * There can only be a single, global handler for all events in * libSRTP. */typedef void (srtp_event_handler_func_t)(srtp_event_data_t *data);/** * @brief sets the event handler to the function supplied by the caller. *  * The function call srtp_install_event_handler(func) sets the event * handler function to the value func.  The value NULL is acceptable * as an argument; in this case, events will be ignored rather than * handled. * * @param func is a pointer to a fuction that takes an srtp_event_data_t *             pointer as an argument and returns void.  This function *             will be used by libSRTP to handle events. */err_status_tsrtp_install_event_handler(srtp_event_handler_func_t func);/** * @} *//* in host order, so outside the #if */#define SRTCP_E_BIT      0x80000000/* for byte-access */#define SRTCP_E_BYTE_BIT 0x80#define SRTCP_INDEX_MASK 0x7fffffff#ifdef _MSC_VER#pragma pack()#endif#ifdef __cplusplus}#endif#endif /* SRTP_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -