📄 srtp.h
字号:
* otherwise, no assumptions should be made about the value of either * data elements. * * The sequence numbers of the RTP packets presented to this function * need not be consecutive, but they @b must be out of order by less * than 2^15 = 32,768 packets. * * @warning This function assumes that the SRTP packet is aligned on a * 32-bit boundary. * * @param ctx is a pointer to the srtp_t which applies to the * particular packet. * * @param srtp_hdr is a pointer to the header of the SRTP 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 len_ptr is a pointer to the length in octets of the complete * srtp 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 RTP packet is valid. * - err_status_auth_fail if the SRTP packet failed the message * authentication check. * - err_status_replay_fail if the SRTP packet is a replay (e.g. packet has * already been processed and accepted). * - [other] if there has been an error in the cryptographic mechanisms. * */err_status_tsrtp_unprotect(srtp_t ctx, void *srtp_hdr, int *len_ptr);/** * @brief srtp_create() allocates and initializes an SRTP session. * The function call srtp_create(session, policy, key) allocates and * initializes an SRTP session context, applying the given policy and * key. * * @param session is the SRTP session to which the policy is to be added. * * @param policy is the srtp_policy_t struct that describes the policy * for the session. The struct may be a single element, or it may be * the head of a list, in which case each element of the list is * processed. It may also be NULL, in which case streams should be added * later using srtp_add_stream(). The final element of the list @b must * have its `next' field set to NULL. * * @return * - err_status_ok if creation succeded. * - err_status_alloc_fail if allocation failed. * - err_status_init_fail if initialization failed. */err_status_tsrtp_create(srtp_t *session, const srtp_policy_t *policy);/** * @brief srtp_add_stream() allocates and initializes an SRTP stream * within a given SRTP session. * * The function call srtp_add_stream(session, policy) allocates and * initializes a new SRTP stream within a given, previously created * session, applying the policy given as the other argument to that * stream. * * @return values: * - err_status_ok if stream creation succeded. * - err_status_alloc_fail if stream allocation failed * - err_status_init_fail if stream initialization failed. */err_status_tsrtp_add_stream(srtp_t session, const srtp_policy_t *policy);/** * @brief srtp_remove_stream() deallocates an SRTP stream. * * The function call srtp_remove_stream(session, ssrc) removes * the SRTP stream with the SSRC value ssrc from the SRTP session * context given by the argument session. * * @param session is the SRTP session from which the stream * will be removed. * * @param ssrc is the SSRC value of the stream to be removed. * * @warning Wildcard SSRC values cannot be removed from a * session. * * @return * - err_status_ok if the stream deallocation succeded. * - [other] otherwise. * */err_status_tsrtp_remove_stream(srtp_t session, unsigned int ssrc);/** * @brief crypto_policy_set_rtp_default() sets a crypto policy * structure to the SRTP default policy for RTP protection. * * @param p is a pointer to the policy structure to be set * * The function call crypto_policy_set_rtp_default(&p) sets the * crypto_policy_t at location p to the SRTP default policy for RTP * protection, as defined in the specification. 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 void. * */voidcrypto_policy_set_rtp_default(crypto_policy_t *p);/** * @brief crypto_policy_set_rtcp_default() sets a crypto policy * structure to the SRTP default policy for RTCP protection. * * @param p is a pointer to the policy structure to be set * * The function call crypto_policy_set_rtcp_default(&p) sets the * crypto_policy_t at location p to the SRTP default policy for RTCP * protection, as defined in the specification. 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 void. * */voidcrypto_policy_set_rtcp_default(crypto_policy_t *p);/** * @brief crypto_policy_set_aes_cm_128_hmac_sha1_80() sets a crypto * policy structure to the SRTP default policy for RTP protection. * * @param p is a pointer to the policy structure to be set * * The function crypto_policy_set_aes_cm_128_hmac_sha1_80() is a * synonym for crypto_policy_set_rtp_default(). It conforms to the * naming convention used in * http://www.ietf.org/internet-drafts/draft-ietf-mmusic-sdescriptions-12.txt * * @return void. * */#define crypto_policy_set_aes_cm_128_hmac_sha1_80(p) crypto_policy_set_rtp_default(p)/** * @brief crypto_policy_set_aes_cm_128_hmac_sha1_32() sets a crypto * policy structure to a short-authentication tag policy * * @param p is a pointer to the policy structure to be set * * The function call crypto_policy_set_aes_cm_128_hmac_sha1_32(&p) * sets the crypto_policy_t at location p to use policy * AES_CM_128_HMAC_SHA1_32 as defined in * draft-ietf-mmusic-sdescriptions-12.txt. This policy uses AES-128 * Counter Mode encryption and HMAC-SHA1 authentication, with an * authentication tag that is only 32 bits long. This length is * considered adequate only for protecting audio and video media that * use a stateless playback function. See Section 7.5 of RFC 3711 * (http://www.ietf.org/rfc/rfc3711.txt). * * 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. * * @warning This crypto policy is intended for use in SRTP, but not in * SRTCP. It is recommended that a policy that uses longer * authentication tags be used for SRTCP. See Section 7.5 of RFC 3711 * (http://www.ietf.org/rfc/rfc3711.txt). * * @return void. * */voidcrypto_policy_set_aes_cm_128_hmac_sha1_32(crypto_policy_t *p);/** * @brief crypto_policy_set_aes_cm_128_null_auth() sets a crypto * policy structure to an encryption-only policy * * @param p is a pointer to the policy structure to be set * * The function call crypto_policy_set_aes_cm_128_null_auth(&p) sets * the crypto_policy_t at location p to use the SRTP default cipher * (AES-128 Counter Mode), but to use no authentication method. This * policy is NOT RECOMMENDED unless it is unavoidable; see Section 7.5 * of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). * * 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. * * @warning This policy is NOT RECOMMENDED for SRTP unless it is * unavoidable, and it is NOT RECOMMENDED at all for SRTCP; see * Section 7.5 of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). * * @return void. * */voidcrypto_policy_set_aes_cm_128_null_auth(crypto_policy_t *p);/** * @brief crypto_policy_set_null_cipher_hmac_sha1_80() sets a crypto * policy structure to an authentication-only policy * * @param p is a pointer to the policy structure to be set * * The function call crypto_policy_set_null_cipher_hmac_sha1_80(&p) * sets the crypto_policy_t at location p to use HMAC-SHA1 with an 80 * bit authentication tag to provide message authentication, but to * use no encryption. This policy is NOT RECOMMENDED for SRTP unless * there is a requirement to forego encryption. * * 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. * * @warning This policy is NOT RECOMMENDED for SRTP unless there is a * requirement to forego encryption. * * @return void. * */voidcrypto_policy_set_null_cipher_hmac_sha1_80(crypto_policy_t *p);/** * @brief srtp_dealloc() deallocates storage for an SRTP session * context. * * The function call srtp_dealloc(s) deallocates storage for the * SRTP session context s. This function should be called no more * than one time for each of the contexts allocated by the function * srtp_create(). * * @param s is the srtp_t for the session to be deallocated. * * @return * - err_status_ok if there no problems. * - err_status_dealloc_fail a memory deallocation failure occured. */err_status_tsrtp_dealloc(srtp_t s);/* * @brief identifies a particular SRTP profile * * An srtp_profile_t enumeration is used to identify a particular SRTP * profile (that is, a set of algorithms and parameters). These * profiles are defined in the DTLS-SRTP draft. */typedef enum { srtp_profile_reserved = 0, srtp_profile_aes128_cm_sha1_80 = 1, srtp_profile_aes128_cm_sha1_32 = 2, srtp_profile_aes256_cm_sha1_80 = 3, srtp_profile_aes256_cm_sha1_32 = 4, srtp_profile_null_sha1_80 = 5, srtp_profile_null_sha1_32 = 6,} srtp_profile_t;/** * @brief crypto_policy_set_from_profile_for_rtp() sets a crypto policy * structure to the appropriate value for RTP based on an srtp_profile_t * * @param p is a pointer to the policy structure to be set
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -