Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * srtp.h |
| 3 | * |
| 4 | * interface to libsrtp |
| 5 | * |
| 6 | * David A. McGrew |
| 7 | * Cisco Systems, Inc. |
| 8 | */ |
| 9 | /* |
| 10 | * |
David McGrew | 7629bf2 | 2006-06-08 17:00:25 +0000 | [diff] [blame] | 11 | * Copyright (c) 2001-2006, Cisco Systems, Inc. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 12 | * All rights reserved. |
| 13 | * |
| 14 | * Redistribution and use in source and binary forms, with or without |
| 15 | * modification, are permitted provided that the following conditions |
| 16 | * are met: |
| 17 | * |
| 18 | * Redistributions of source code must retain the above copyright |
| 19 | * notice, this list of conditions and the following disclaimer. |
| 20 | * |
| 21 | * Redistributions in binary form must reproduce the above |
| 22 | * copyright notice, this list of conditions and the following |
| 23 | * disclaimer in the documentation and/or other materials provided |
| 24 | * with the distribution. |
| 25 | * |
| 26 | * Neither the name of the Cisco Systems, Inc. nor the names of its |
| 27 | * contributors may be used to endorse or promote products derived |
| 28 | * from this software without specific prior written permission. |
| 29 | * |
| 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 31 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 32 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 33 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 34 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 35 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 36 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 37 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 41 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 42 | * |
| 43 | */ |
| 44 | |
| 45 | |
Pascal Bühler | c3655db | 2017-02-01 09:11:27 +0100 | [diff] [blame] | 46 | #ifndef SRTP_SRTP_H |
| 47 | #define SRTP_SRTP_H |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 48 | |
David Benjamin | 5f1b982 | 2016-07-26 18:18:01 -0400 | [diff] [blame] | 49 | #include <stdint.h> |
| 50 | |
Marcus Sundberg | cb60bf8 | 2005-10-17 17:23:05 +0000 | [diff] [blame] | 51 | #ifdef __cplusplus |
| 52 | extern "C" { |
| 53 | #endif |
| 54 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 55 | /** |
| 56 | * @defgroup SRTP Secure RTP |
| 57 | * |
| 58 | * @brief libSRTP provides functions for protecting RTP and RTCP. See |
| 59 | * Section @ref Overview for an introduction to the use of the library. |
| 60 | * |
| 61 | * @{ |
| 62 | */ |
| 63 | |
| 64 | /* |
| 65 | * SRTP_MASTER_KEY_LEN is the nominal master key length supported by libSRTP |
| 66 | */ |
| 67 | |
| 68 | #define SRTP_MASTER_KEY_LEN 30 |
| 69 | |
| 70 | /* |
| 71 | * SRTP_MAX_KEY_LEN is the maximum key length supported by libSRTP |
| 72 | */ |
| 73 | #define SRTP_MAX_KEY_LEN 64 |
| 74 | |
| 75 | /* |
| 76 | * SRTP_MAX_TAG_LEN is the maximum tag length supported by libSRTP |
| 77 | */ |
| 78 | |
jfigus | ed22129 | 2015-05-15 13:39:08 -0400 | [diff] [blame] | 79 | #define SRTP_MAX_TAG_LEN 16 |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 80 | |
| 81 | /** |
Ryan Hooper | ab0345b | 2017-02-07 16:07:59 -0500 | [diff] [blame] | 82 | * SRTP_MAX_MKI_LEN is the maximum size the MKI could be which is |
| 83 | * 128 bytes |
| 84 | */ |
| 85 | #define SRTP_MAX_MKI_LEN 128 |
| 86 | |
| 87 | |
| 88 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 89 | * SRTP_MAX_TRAILER_LEN is the maximum length of the SRTP trailer |
| 90 | * (authentication tag and MKI) supported by libSRTP. This value is |
Ryan Hooper | ab0345b | 2017-02-07 16:07:59 -0500 | [diff] [blame] | 91 | * the maixmum number of octets that will be added to an RTP packet by |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 92 | * srtp_protect(). |
| 93 | * |
| 94 | * @brief the maximum number of octets added by srtp_protect(). |
| 95 | */ |
Ryan Hooper | ab0345b | 2017-02-07 16:07:59 -0500 | [diff] [blame] | 96 | #define SRTP_MAX_TRAILER_LEN SRTP_MAX_TAG_LEN + SRTP_MAX_MKI_LEN |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 97 | |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 98 | /** |
| 99 | * SRTP_MAX_NUM_MASTER_KEYS is the maximum number of Master keys for |
Ryan Hooper | 89a288b | 2016-12-22 16:22:47 -0500 | [diff] [blame] | 100 | * MKI supported by libSRTP. |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 101 | * |
| 102 | */ |
Ryan Hooper | 89a288b | 2016-12-22 16:22:47 -0500 | [diff] [blame] | 103 | #define SRTP_MAX_NUM_MASTER_KEYS 16 |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 104 | |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 105 | /* |
| 106 | * SRTP_AEAD_SALT_LEN is the length of the SALT values used with |
| 107 | * GCM mode. GCM mode requires an IV. The SALT value is used |
| 108 | * as part of the IV formation logic applied to each RTP packet. |
| 109 | */ |
| 110 | #define SRTP_AEAD_SALT_LEN 12 |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 111 | #define SRTP_AES_128_GCM_KEYSIZE_WSALT SRTP_AEAD_SALT_LEN + 16 |
| 112 | #define SRTP_AES_192_GCM_KEYSIZE_WSALT SRTP_AEAD_SALT_LEN + 24 |
| 113 | #define SRTP_AES_256_GCM_KEYSIZE_WSALT SRTP_AEAD_SALT_LEN + 32 |
jfigus | 8719f95 | 2014-04-08 09:15:49 -0400 | [diff] [blame] | 114 | |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 115 | /* |
| 116 | * an srtp_hdr_t represents the srtp header |
| 117 | * |
| 118 | * in this implementation, an srtp_hdr_t is assumed to be 32-bit aligned |
| 119 | * |
| 120 | * (note that this definition follows that of RFC 1889 Appendix A, but |
| 121 | * is not identical) |
| 122 | */ |
| 123 | |
| 124 | #ifndef WORDS_BIGENDIAN |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 125 | |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 126 | /* |
| 127 | * srtp_hdr_t represents an RTP or SRTP header. The bit-fields in |
| 128 | * this structure should be declared "unsigned int" instead of |
| 129 | * "unsigned char", but doing so causes the MS compiler to not |
| 130 | * fully pack the bit fields. |
| 131 | */ |
| 132 | |
| 133 | typedef struct { |
| 134 | unsigned char cc:4; /* CSRC count */ |
| 135 | unsigned char x:1; /* header extension flag */ |
| 136 | unsigned char p:1; /* padding flag */ |
| 137 | unsigned char version:2; /* protocol version */ |
| 138 | unsigned char pt:7; /* payload type */ |
| 139 | unsigned char m:1; /* marker bit */ |
| 140 | uint16_t seq; /* sequence number */ |
| 141 | uint32_t ts; /* timestamp */ |
| 142 | uint32_t ssrc; /* synchronization source */ |
| 143 | } srtp_hdr_t; |
| 144 | |
| 145 | #else /* BIG_ENDIAN */ |
| 146 | |
| 147 | typedef struct { |
| 148 | unsigned char version:2; /* protocol version */ |
| 149 | unsigned char p:1; /* padding flag */ |
| 150 | unsigned char x:1; /* header extension flag */ |
| 151 | unsigned char cc:4; /* CSRC count */ |
| 152 | unsigned char m:1; /* marker bit */ |
| 153 | unsigned char pt:7; /* payload type */ |
| 154 | uint16_t seq; /* sequence number */ |
| 155 | uint32_t ts; /* timestamp */ |
| 156 | uint32_t ssrc; /* synchronization source */ |
| 157 | } srtp_hdr_t; |
| 158 | |
| 159 | #endif |
| 160 | |
| 161 | typedef struct { |
| 162 | uint16_t profile_specific; /* profile-specific info */ |
| 163 | uint16_t length; /* number of 32-bit words in extension */ |
| 164 | } srtp_hdr_xtnd_t; |
| 165 | |
| 166 | |
| 167 | /* |
| 168 | * srtcp_hdr_t represents a secure rtcp header |
| 169 | * |
| 170 | * in this implementation, an srtcp header is assumed to be 32-bit |
| 171 | * alinged |
| 172 | */ |
| 173 | |
| 174 | #ifndef WORDS_BIGENDIAN |
| 175 | |
| 176 | typedef struct { |
| 177 | unsigned char rc:5; /* reception report count */ |
| 178 | unsigned char p:1; /* padding flag */ |
| 179 | unsigned char version:2; /* protocol version */ |
| 180 | unsigned char pt:8; /* payload type */ |
| 181 | uint16_t len; /* length */ |
| 182 | uint32_t ssrc; /* synchronization source */ |
| 183 | } srtcp_hdr_t; |
| 184 | |
| 185 | typedef struct { |
| 186 | unsigned int index:31; /* srtcp packet index in network order! */ |
| 187 | unsigned int e:1; /* encrypted? 1=yes */ |
| 188 | /* optional mikey/etc go here */ |
| 189 | /* and then the variable-length auth tag */ |
| 190 | } srtcp_trailer_t; |
| 191 | |
| 192 | |
| 193 | #else /* BIG_ENDIAN */ |
| 194 | |
| 195 | typedef struct { |
| 196 | unsigned char version:2; /* protocol version */ |
| 197 | unsigned char p:1; /* padding flag */ |
| 198 | unsigned char rc:5; /* reception report count */ |
| 199 | unsigned char pt:8; /* payload type */ |
| 200 | uint16_t len; /* length */ |
| 201 | uint32_t ssrc; /* synchronization source */ |
| 202 | } srtcp_hdr_t; |
| 203 | |
| 204 | typedef struct { |
| 205 | unsigned int version:2; /* protocol version */ |
| 206 | unsigned int p:1; /* padding flag */ |
| 207 | unsigned int count:5; /* varies by packet type */ |
| 208 | unsigned int pt:8; /* payload type */ |
| 209 | uint16_t length; /* len of uint32s of packet less header */ |
| 210 | } rtcp_common_t; |
| 211 | |
| 212 | typedef struct { |
| 213 | unsigned int e:1; /* encrypted? 1=yes */ |
| 214 | unsigned int index:31; /* srtcp packet index */ |
| 215 | /* optional mikey/etc go here */ |
| 216 | /* and then the variable-length auth tag */ |
| 217 | } srtcp_trailer_t; |
| 218 | |
| 219 | #endif |
| 220 | |
| 221 | |
| 222 | |
| 223 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 224 | * @brief A srtp_cipher_type_id_t is an identifier for a particular cipher |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 225 | * type. |
| 226 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 227 | * A srtp_cipher_type_id_t is an integer that represents a particular |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 228 | * cipher type, e.g. the Advanced Encryption Standard (AES). A |
jfigus | 67b9c73 | 2014-11-20 10:17:21 -0500 | [diff] [blame] | 229 | * SRTP_NULL_CIPHER is avaliable; this cipher leaves the data unchanged, |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 230 | * and can be selected to indicate that no encryption is to take |
| 231 | * place. |
| 232 | * |
| 233 | * @ingroup Ciphers |
| 234 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 235 | typedef uint32_t srtp_cipher_type_id_t; |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 236 | |
| 237 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 238 | * @brief An srtp_auth_type_id_t is an identifier for a particular authentication |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 239 | * function. |
| 240 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 241 | * An srtp_auth_type_id_t is an integer that represents a particular |
jfigus | 67b9c73 | 2014-11-20 10:17:21 -0500 | [diff] [blame] | 242 | * authentication function type, e.g. HMAC-SHA1. A SRTP_NULL_AUTH is |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 243 | * avaliable; this authentication function performs no computation, |
| 244 | * and can be selected to indicate that no authentication is to take |
| 245 | * place. |
| 246 | * |
| 247 | * @ingroup Authentication |
| 248 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 249 | typedef uint32_t srtp_auth_type_id_t; |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 250 | |
| 251 | /* |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 252 | * @brief srtp_err_status_t defines error codes. |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 253 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 254 | * The enumeration srtp_err_status_t defines error codes. Note that the |
| 255 | * value of srtp_err_status_ok is equal to zero, which can simplify error |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 256 | * checking somewhat. |
| 257 | * |
| 258 | */ |
| 259 | typedef enum { |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 260 | srtp_err_status_ok = 0, /**< nothing to report */ |
| 261 | srtp_err_status_fail = 1, /**< unspecified failure */ |
| 262 | srtp_err_status_bad_param = 2, /**< unsupported parameter */ |
| 263 | srtp_err_status_alloc_fail = 3, /**< couldn't allocate memory */ |
| 264 | srtp_err_status_dealloc_fail = 4, /**< couldn't deallocate properly */ |
| 265 | srtp_err_status_init_fail = 5, /**< couldn't initialize */ |
| 266 | srtp_err_status_terminus = 6, /**< can't process as much data as requested */ |
| 267 | srtp_err_status_auth_fail = 7, /**< authentication failure */ |
| 268 | srtp_err_status_cipher_fail = 8, /**< cipher failure */ |
| 269 | srtp_err_status_replay_fail = 9, /**< replay check failed (bad index) */ |
| 270 | srtp_err_status_replay_old = 10, /**< replay check failed (index too old) */ |
| 271 | srtp_err_status_algo_fail = 11, /**< algorithm failed test routine */ |
| 272 | srtp_err_status_no_such_op = 12, /**< unsupported operation */ |
| 273 | srtp_err_status_no_ctx = 13, /**< no appropriate context found */ |
| 274 | srtp_err_status_cant_check = 14, /**< unable to perform desired validation */ |
| 275 | srtp_err_status_key_expired = 15, /**< can't use key any more */ |
| 276 | srtp_err_status_socket_err = 16, /**< error in use of socket */ |
| 277 | srtp_err_status_signal_err = 17, /**< error in use POSIX signals */ |
| 278 | srtp_err_status_nonce_bad = 18, /**< nonce check failed */ |
| 279 | srtp_err_status_read_fail = 19, /**< couldn't read data */ |
| 280 | srtp_err_status_write_fail = 20, /**< couldn't write data */ |
| 281 | srtp_err_status_parse_err = 21, /**< error parsing data */ |
| 282 | srtp_err_status_encode_err = 22, /**< error encoding data */ |
| 283 | srtp_err_status_semaphore_err = 23,/**< error while using semaphores */ |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 284 | srtp_err_status_pfkey_err = 24, /**< error while using pfkey */ |
| 285 | srtp_err_status_bad_mki = 25 /**< error MKI present in packet is invalid */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 286 | } srtp_err_status_t; |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 287 | |
Pascal Bühler | f15c7e0 | 2017-01-25 13:15:21 +0100 | [diff] [blame] | 288 | |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 289 | typedef struct srtp_ctx_t_ srtp_ctx_t; |
jfigus | 4494760 | 2014-10-08 13:08:52 -0400 | [diff] [blame] | 290 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 291 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 292 | * @brief srtp_sec_serv_t describes a set of security services. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 293 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 294 | * A srtp_sec_serv_t enumeration is used to describe the particular |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 295 | * security services that will be applied by a particular crypto |
| 296 | * policy (or other mechanism). |
| 297 | */ |
| 298 | |
| 299 | typedef enum { |
| 300 | sec_serv_none = 0, /**< no services */ |
| 301 | sec_serv_conf = 1, /**< confidentiality */ |
| 302 | sec_serv_auth = 2, /**< authentication */ |
| 303 | sec_serv_conf_and_auth = 3 /**< confidentiality and authentication */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 304 | } srtp_sec_serv_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 305 | |
| 306 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 307 | * @brief srtp_crypto_policy_t describes a particular crypto policy that |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 308 | * can be applied to an SRTP stream. |
| 309 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 310 | * A srtp_crypto_policy_t describes a particular cryptographic policy that |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 311 | * can be applied to an SRTP or SRTCP stream. An SRTP session policy |
| 312 | * consists of a list of these policies, one for each SRTP stream |
| 313 | * in the session. |
| 314 | */ |
| 315 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 316 | typedef struct srtp_crypto_policy_t { |
| 317 | srtp_cipher_type_id_t cipher_type; /**< An integer representing |
| 318 | * the type of cipher. */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 319 | int cipher_key_len; /**< The length of the cipher key |
| 320 | * in octets. */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 321 | srtp_auth_type_id_t auth_type; /**< An integer representing the |
| 322 | * authentication function. */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 323 | int auth_key_len; /**< The length of the authentication |
| 324 | * function key in octets. */ |
| 325 | int auth_tag_len; /**< The length of the authentication |
| 326 | * tag in octets. */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 327 | srtp_sec_serv_t sec_serv; /**< The flag indicating the security |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 328 | * services to be applied. */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 329 | } srtp_crypto_policy_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 330 | |
| 331 | |
| 332 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 333 | * @brief srtp_ssrc_type_t describes the type of an SSRC. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 334 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 335 | * An srtp_ssrc_type_t enumeration is used to indicate a type of SSRC. See |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 336 | * @ref srtp_policy_t for more informataion. |
| 337 | */ |
| 338 | |
| 339 | typedef enum { |
| 340 | ssrc_undefined = 0, /**< Indicates an undefined SSRC type. */ |
| 341 | ssrc_specific = 1, /**< Indicates a specific SSRC value */ |
| 342 | ssrc_any_inbound = 2, /**< Indicates any inbound SSRC value |
| 343 | (i.e. a value that is used in the |
| 344 | function srtp_unprotect()) */ |
| 345 | ssrc_any_outbound = 3 /**< Indicates any outbound SSRC value |
| 346 | (i.e. a value that is used in the |
| 347 | function srtp_protect()) */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 348 | } srtp_ssrc_type_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 349 | |
| 350 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 351 | * @brief An srtp_ssrc_t represents a particular SSRC value, or a `wildcard' SSRC. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 352 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 353 | * An srtp_ssrc_t represents a particular SSRC value (if its type is |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 354 | * ssrc_specific), or a wildcard SSRC value that will match all |
| 355 | * outbound SSRCs (if its type is ssrc_any_outbound) or all inbound |
| 356 | * SSRCs (if its type is ssrc_any_inbound). |
| 357 | * |
| 358 | */ |
| 359 | |
| 360 | typedef struct { |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 361 | srtp_ssrc_type_t type; /**< The type of this particular SSRC */ |
| 362 | unsigned int value; /**< The value of this SSRC, if it is not a wildcard */ |
| 363 | } srtp_ssrc_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 364 | |
| 365 | |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 366 | /** |
| 367 | * @brief points to an EKT policy |
| 368 | */ |
jfigus | c5887e7 | 2014-11-06 09:46:18 -0500 | [diff] [blame] | 369 | typedef struct srtp_ekt_policy_ctx_t *srtp_ekt_policy_t; |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 370 | |
| 371 | |
| 372 | /** |
| 373 | * @brief points to EKT stream data |
| 374 | */ |
jfigus | c5887e7 | 2014-11-06 09:46:18 -0500 | [diff] [blame] | 375 | typedef struct srtp_ekt_stream_ctx_t *srtp_ekt_stream_t; |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 376 | |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 377 | /** |
| 378 | * @brief srtp_master_key_t represents a master key. There will |
| 379 | * be a Master Key Index and the Master Key associated with the |
| 380 | * Master Key Index. Need to also keep track of the Master Key |
| 381 | * Index Size to correctly read it from a packet. |
| 382 | */ |
| 383 | typedef struct srtp_master_key_t { |
| 384 | unsigned char *key; |
| 385 | unsigned char *mki_id; |
| 386 | unsigned int mki_size; |
| 387 | } srtp_master_key_t; |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 388 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 389 | /** |
| 390 | * @brief represents the policy for an SRTP session. |
| 391 | * |
| 392 | * A single srtp_policy_t struct represents the policy for a single |
| 393 | * SRTP stream, and a linked list of these elements represents the |
| 394 | * policy for an entire SRTP session. Each element contains the SRTP |
| 395 | * and SRTCP crypto policies for that stream, a pointer to the SRTP |
| 396 | * master key for that stream, the SSRC describing that stream, or a |
| 397 | * flag indicating a `wildcard' SSRC value, and a `next' field that |
| 398 | * holds a pointer to the next element in the list of policy elements, |
| 399 | * or NULL if it is the last element. |
| 400 | * |
| 401 | * The wildcard value SSRC_ANY_INBOUND matches any SSRC from an |
| 402 | * inbound stream that for which there is no explicit SSRC entry in |
| 403 | * another policy element. Similarly, the value SSRC_ANY_OUTBOUND |
| 404 | * will matches any SSRC from an outbound stream that does not appear |
| 405 | * in another policy element. Note that wildcard SSRCs &b cannot be |
| 406 | * used to match both inbound and outbound traffic. This restriction |
| 407 | * is intentional, and it allows libSRTP to ensure that no security |
| 408 | * lapses result from accidental re-use of SSRC values during key |
| 409 | * sharing. |
| 410 | * |
| 411 | * |
| 412 | * @warning The final element of the list @b must have its `next' pointer |
| 413 | * set to NULL. |
| 414 | */ |
| 415 | |
| 416 | typedef struct srtp_policy_t { |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 417 | srtp_ssrc_t ssrc; /**< The SSRC value of stream, or the |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 418 | * flags SSRC_ANY_INBOUND or |
| 419 | * SSRC_ANY_OUTBOUND if key sharing |
| 420 | * is used for this policy element. |
| 421 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 422 | srtp_crypto_policy_t rtp; /**< SRTP crypto policy. */ |
| 423 | srtp_crypto_policy_t rtcp; /**< SRTCP crypto policy. */ |
David McGrew | 3c45e0c | 2006-07-12 00:50:56 +0000 | [diff] [blame] | 424 | unsigned char *key; /**< Pointer to the SRTP master key for |
Ryan Hooper | 89a288b | 2016-12-22 16:22:47 -0500 | [diff] [blame] | 425 | * this stream. */ |
| 426 | srtp_master_key_t **keys; /** Array of Master Key structures */ |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 427 | unsigned long num_master_keys; /** Number of master keys */ |
jfigus | c5887e7 | 2014-11-06 09:46:18 -0500 | [diff] [blame] | 428 | srtp_ekt_policy_t ekt; /**< Pointer to the EKT policy structure |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 429 | * for this stream (if any) */ |
Jonathan Lennox | a1242f8 | 2010-05-17 21:46:04 +0000 | [diff] [blame] | 430 | unsigned long window_size; /**< The window size to use for replay |
| 431 | * protection. */ |
Jonathan Lennox | dcee5c6 | 2010-05-17 22:08:40 +0000 | [diff] [blame] | 432 | int allow_repeat_tx; /**< Whether retransmissions of |
| 433 | * packets with the same sequence number |
| 434 | * are allowed. (Note that such repeated |
| 435 | * transmissions must have the same RTP |
| 436 | * payload, or a severe security weakness |
| 437 | * is introduced!) */ |
Joachim Bauch | 99a7482 | 2015-11-17 00:08:19 +0100 | [diff] [blame] | 438 | int *enc_xtn_hdr; /**< List of header ids to encrypt. */ |
| 439 | int enc_xtn_hdr_count; /**< Number of entries in list of header ids. */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 440 | struct srtp_policy_t *next; /**< Pointer to next stream policy. */ |
| 441 | } srtp_policy_t; |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | /** |
| 447 | * @brief An srtp_t points to an SRTP session structure. |
| 448 | * |
| 449 | * The typedef srtp_t is a pointer to a structure that represents |
| 450 | * an SRTP session. This datatype is intentially opaque in |
| 451 | * order to separate the interface from the implementation. |
| 452 | * |
| 453 | * An SRTP session consists of all of the traffic sent to the RTP and |
| 454 | * RTCP destination transport addresses, using the RTP/SAVP (Secure |
| 455 | * Audio/Video Profile). A session can be viewed as a set of SRTP |
| 456 | * streams, each of which originates with a different participant. |
| 457 | */ |
| 458 | |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 459 | typedef srtp_ctx_t *srtp_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 460 | |
| 461 | |
| 462 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 463 | * @brief srtp_init() initializes the srtp library. |
| 464 | * |
| 465 | * @warning This function @b must be called before any other srtp |
| 466 | * functions. |
| 467 | */ |
| 468 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 469 | srtp_err_status_t srtp_init(void); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 470 | |
| 471 | /** |
Jonathan Lennox | 5ae7633 | 2010-05-15 04:48:59 +0000 | [diff] [blame] | 472 | * @brief srtp_shutdown() de-initializes the srtp library. |
| 473 | * |
| 474 | * @warning No srtp functions may be called after calling this function. |
| 475 | */ |
| 476 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 477 | srtp_err_status_t srtp_shutdown(void); |
Jonathan Lennox | 5ae7633 | 2010-05-15 04:48:59 +0000 | [diff] [blame] | 478 | |
| 479 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 480 | * @brief srtp_protect() is the Secure RTP sender-side packet processing |
| 481 | * function. |
| 482 | * |
| 483 | * The function call srtp_protect(ctx, rtp_hdr, len_ptr) applies SRTP |
| 484 | * protection to the RTP packet rtp_hdr (which has length *len_ptr) using |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 485 | * the SRTP context ctx. If srtp_err_status_ok is returned, then rtp_hdr |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 486 | * points to the resulting SRTP packet and *len_ptr is the number of |
| 487 | * octets in that packet; otherwise, no assumptions should be made |
| 488 | * about the value of either data elements. |
| 489 | * |
| 490 | * The sequence numbers of the RTP packets presented to this function |
| 491 | * need not be consecutive, but they @b must be out of order by less |
| 492 | * than 2^15 = 32,768 packets. |
| 493 | * |
| 494 | * @warning This function assumes that it can write the authentication |
| 495 | * tag into the location in memory immediately following the RTP |
| 496 | * packet, and assumes that the RTP packet is aligned on a 32-bit |
| 497 | * boundary. |
| 498 | * |
jfigus | dfe68ea | 2013-05-28 09:00:14 -0400 | [diff] [blame] | 499 | * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN |
| 500 | * into the location in memory immediately following the RTP packet. |
| 501 | * Callers MUST ensure that this much writable memory is available in |
| 502 | * the buffer that holds the RTP packet. |
jfigus | 5e33729 | 2013-05-28 13:57:47 -0400 | [diff] [blame] | 503 | * |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 504 | * @param ctx is the SRTP context to use in processing the packet. |
| 505 | * |
| 506 | * @param rtp_hdr is a pointer to the RTP packet (before the call); after |
| 507 | * the function returns, it points to the srtp packet. |
| 508 | * |
| 509 | * @param len_ptr is a pointer to the length in octets of the complete |
| 510 | * RTP packet (header and body) before the function call, and of the |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 511 | * complete SRTP packet after the call, if srtp_err_status_ok was returned. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 512 | * Otherwise, the value of the data to which it points is undefined. |
| 513 | * |
| 514 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 515 | * - srtp_err_status_ok no problems |
| 516 | * - srtp_err_status_replay_fail rtp sequence number was non-increasing |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 517 | * - @e other failure in cryptographic mechanisms |
| 518 | */ |
| 519 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 520 | srtp_err_status_t srtp_protect(srtp_t ctx, void *rtp_hdr, int *len_ptr); |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 521 | |
| 522 | /** |
| 523 | * @brief srtp_protect_mki() is the Secure RTP sender-side packet processing |
| 524 | * function that can utilize MKI. |
| 525 | * |
| 526 | * The function call srtp_protect(ctx, rtp_hdr, len_ptr) applies SRTP |
| 527 | * protection to the RTP packet rtp_hdr (which has length *len_ptr) using |
| 528 | * the SRTP context ctx. If srtp_err_status_ok is returned, then rtp_hdr |
| 529 | * points to the resulting SRTP packet and *len_ptr is the number of |
| 530 | * octets in that packet; otherwise, no assumptions should be made |
| 531 | * about the value of either data elements. |
| 532 | * |
| 533 | * The sequence numbers of the RTP packets presented to this function |
| 534 | * need not be consecutive, but they @b must be out of order by less |
| 535 | * than 2^15 = 32,768 packets. |
| 536 | * |
| 537 | * @warning This function assumes that it can write the authentication |
| 538 | * tag into the location in memory immediately following the RTP |
| 539 | * packet, and assumes that the RTP packet is aligned on a 32-bit |
| 540 | * boundary. |
| 541 | * |
| 542 | * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN |
| 543 | * into the location in memory immediately following the RTP packet. |
| 544 | * Callers MUST ensure that this much writable memory is available in |
| 545 | * the buffer that holds the RTP packet. |
| 546 | * |
| 547 | * @param ctx is the SRTP context to use in processing the packet. |
| 548 | * |
| 549 | * @param rtp_hdr is a pointer to the RTP packet (before the call); after |
| 550 | * the function returns, it points to the srtp packet. |
| 551 | * |
| 552 | * @param len_ptr is a pointer to the length in octets of the complete |
| 553 | * RTP packet (header and body) before the function call, and of the |
| 554 | * complete SRTP packet after the call, if srtp_err_status_ok was returned. |
| 555 | * Otherwise, the value of the data to which it points is undefined. |
| 556 | * |
| 557 | * @param use_mki is a boolean to tell the system if mki is being used. If |
| 558 | * set to false then will use the first set of session keys. If set to true will |
| 559 | * use the session keys identified by the mki_index |
| 560 | * |
| 561 | * @param mki_index integer value specifying which set of session kesy should be |
| 562 | * used if use_mki is set to true. |
| 563 | * |
| 564 | * @return |
| 565 | * - srtp_err_status_ok no problems |
| 566 | * - srtp_err_status_replay_fail rtp sequence number was non-increasing |
| 567 | * - @e other failure in cryptographic mechanisms |
| 568 | */ |
| 569 | |
Geir Istad | 626e9e8 | 2017-02-20 18:15:05 +0100 | [diff] [blame] | 570 | srtp_err_status_t srtp_protect_mki(srtp_ctx_t *ctx, void *rtp_hdr, |
| 571 | int *pkt_octet_len, unsigned int use_mki, |
| 572 | unsigned int mki_index); |
| 573 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 574 | /** |
| 575 | * @brief srtp_unprotect() is the Secure RTP receiver-side packet |
| 576 | * processing function. |
| 577 | * |
| 578 | * The function call srtp_unprotect(ctx, srtp_hdr, len_ptr) verifies |
| 579 | * the Secure RTP protection of the SRTP packet pointed to by srtp_hdr |
| 580 | * (which has length *len_ptr), using the SRTP context ctx. If |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 581 | * srtp_err_status_ok is returned, then srtp_hdr points to the resulting |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 582 | * RTP packet and *len_ptr is the number of octets in that packet; |
| 583 | * otherwise, no assumptions should be made about the value of either |
| 584 | * data elements. |
| 585 | * |
| 586 | * The sequence numbers of the RTP packets presented to this function |
| 587 | * need not be consecutive, but they @b must be out of order by less |
| 588 | * than 2^15 = 32,768 packets. |
| 589 | * |
| 590 | * @warning This function assumes that the SRTP packet is aligned on a |
| 591 | * 32-bit boundary. |
| 592 | * |
Iñaki Baz Castillo | 241fec3 | 2014-08-21 00:51:00 +0200 | [diff] [blame] | 593 | * @param ctx is the SRTP session which applies to the particular packet. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 594 | * |
| 595 | * @param srtp_hdr is a pointer to the header of the SRTP packet |
| 596 | * (before the call). after the function returns, it points to the |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 597 | * rtp packet if srtp_err_status_ok was returned; otherwise, the value of |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 598 | * the data to which it points is undefined. |
| 599 | * |
| 600 | * @param len_ptr is a pointer to the length in octets of the complete |
| 601 | * srtp packet (header and body) before the function call, and of the |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 602 | * complete rtp packet after the call, if srtp_err_status_ok was returned. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 603 | * Otherwise, the value of the data to which it points is undefined. |
| 604 | * |
| 605 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 606 | * - srtp_err_status_ok if the RTP packet is valid. |
| 607 | * - srtp_err_status_auth_fail if the SRTP packet failed the message |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 608 | * authentication check. |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 609 | * - srtp_err_status_replay_fail if the SRTP packet is a replay (e.g. packet has |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 610 | * already been processed and accepted). |
| 611 | * - [other] if there has been an error in the cryptographic mechanisms. |
| 612 | * |
| 613 | */ |
| 614 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 615 | srtp_err_status_t srtp_unprotect(srtp_t ctx, void *srtp_hdr, int *len_ptr); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 616 | |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 617 | /** |
| 618 | * @brief srtp_unprotect_mki() is the Secure RTP receiver-side packet |
| 619 | * processing function that checks for MKI. |
| 620 | * |
| 621 | * The function call srtp_unprotect(ctx, srtp_hdr, len_ptr) verifies |
| 622 | * the Secure RTP protection of the SRTP packet pointed to by srtp_hdr |
| 623 | * (which has length *len_ptr), using the SRTP context ctx. If |
| 624 | * srtp_err_status_ok is returned, then srtp_hdr points to the resulting |
| 625 | * RTP packet and *len_ptr is the number of octets in that packet; |
| 626 | * otherwise, no assumptions should be made about the value of either |
| 627 | * data elements. |
| 628 | * |
| 629 | * The sequence numbers of the RTP packets presented to this function |
| 630 | * need not be consecutive, but they @b must be out of order by less |
| 631 | * than 2^15 = 32,768 packets. |
| 632 | * |
| 633 | * @warning This function assumes that the SRTP packet is aligned on a |
| 634 | * 32-bit boundary. |
| 635 | * |
| 636 | * @param ctx is the SRTP session which applies to the particular packet. |
| 637 | * |
| 638 | * @param srtp_hdr is a pointer to the header of the SRTP packet |
| 639 | * (before the call). after the function returns, it points to the |
| 640 | * rtp packet if srtp_err_status_ok was returned; otherwise, the value of |
| 641 | * the data to which it points is undefined. |
| 642 | * |
| 643 | * @param len_ptr is a pointer to the length in octets of the complete |
| 644 | * srtp packet (header and body) before the function call, and of the |
| 645 | * complete rtp packet after the call, if srtp_err_status_ok was returned. |
| 646 | * Otherwise, the value of the data to which it points is undefined. |
| 647 | * |
| 648 | * @return |
| 649 | * - srtp_err_status_ok if the RTP packet is valid. |
| 650 | * - srtp_err_status_auth_fail if the SRTP packet failed the message |
| 651 | * authentication check. |
| 652 | * - srtp_err_status_replay_fail if the SRTP packet is a replay (e.g. packet has |
| 653 | * already been processed and accepted). |
| 654 | * - srtp_err_status_bad_mki if the MKI in the packet is not a known MKI id |
| 655 | * - [other] if there has been an error in the cryptographic mechanisms. |
| 656 | * |
| 657 | */ |
| 658 | |
Geir Istad | 626e9e8 | 2017-02-20 18:15:05 +0100 | [diff] [blame] | 659 | srtp_err_status_t srtp_unprotect_mki(srtp_t ctx, void *srtp_hdr, int *len_ptr, |
| 660 | unsigned int use_mki); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 661 | |
| 662 | /** |
| 663 | * @brief srtp_create() allocates and initializes an SRTP session. |
| 664 | |
jfigus | 92c3de3 | 2016-02-02 13:44:39 -0500 | [diff] [blame] | 665 | * The function call srtp_create(session, policy) allocates and |
| 666 | * initializes an SRTP session context, applying the given policy. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 667 | * |
Iñaki Baz Castillo | 241fec3 | 2014-08-21 00:51:00 +0200 | [diff] [blame] | 668 | * @param session is a pointer to the SRTP session to which the policy is |
| 669 | * to be added. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 670 | * |
| 671 | * @param policy is the srtp_policy_t struct that describes the policy |
| 672 | * for the session. The struct may be a single element, or it may be |
| 673 | * the head of a list, in which case each element of the list is |
Marcus Sundberg | 75d9212 | 2005-10-05 12:40:31 +0000 | [diff] [blame] | 674 | * processed. It may also be NULL, in which case streams should be added |
| 675 | * later using srtp_add_stream(). The final element of the list @b must |
| 676 | * have its `next' field set to NULL. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 677 | * |
| 678 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 679 | * - srtp_err_status_ok if creation succeded. |
| 680 | * - srtp_err_status_alloc_fail if allocation failed. |
| 681 | * - srtp_err_status_init_fail if initialization failed. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 682 | */ |
| 683 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 684 | srtp_err_status_t srtp_create(srtp_t *session, const srtp_policy_t *policy); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 685 | |
| 686 | |
| 687 | /** |
| 688 | * @brief srtp_add_stream() allocates and initializes an SRTP stream |
| 689 | * within a given SRTP session. |
| 690 | * |
| 691 | * The function call srtp_add_stream(session, policy) allocates and |
| 692 | * initializes a new SRTP stream within a given, previously created |
| 693 | * session, applying the policy given as the other argument to that |
| 694 | * stream. |
| 695 | * |
| 696 | * @return values: |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 697 | * - srtp_err_status_ok if stream creation succeded. |
| 698 | * - srtp_err_status_alloc_fail if stream allocation failed |
| 699 | * - srtp_err_status_init_fail if stream initialization failed. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 700 | */ |
| 701 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 702 | srtp_err_status_t srtp_add_stream(srtp_t session, const srtp_policy_t *policy); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 703 | |
| 704 | |
| 705 | /** |
| 706 | * @brief srtp_remove_stream() deallocates an SRTP stream. |
| 707 | * |
| 708 | * The function call srtp_remove_stream(session, ssrc) removes |
| 709 | * the SRTP stream with the SSRC value ssrc from the SRTP session |
| 710 | * context given by the argument session. |
| 711 | * |
| 712 | * @param session is the SRTP session from which the stream |
| 713 | * will be removed. |
| 714 | * |
jfigus | 68f8a88 | 2016-02-03 12:48:23 -0500 | [diff] [blame] | 715 | * @param ssrc is the SSRC value of the stream to be removed |
| 716 | * in network byte order. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 717 | * |
| 718 | * @warning Wildcard SSRC values cannot be removed from a |
| 719 | * session. |
| 720 | * |
| 721 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 722 | * - srtp_err_status_ok if the stream deallocation succeded. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 723 | * - [other] otherwise. |
| 724 | * |
| 725 | */ |
| 726 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 727 | srtp_err_status_t srtp_remove_stream(srtp_t session, unsigned int ssrc); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 728 | |
| 729 | /** |
Pascal Bühler | bd3112a | 2015-11-06 20:29:15 +0100 | [diff] [blame] | 730 | * @brief srtp_update() udpates all streams in the session. |
| 731 | * |
| 732 | * The function call srtp_update(session, policy) updates |
| 733 | * all the streams in the session applying the given policy |
| 734 | * and key. The exsisting ROC value of all streams will be |
| 735 | * preserved. |
| 736 | * |
| 737 | * @param session is the SRTP session that contains the streams |
| 738 | * to be updated. |
| 739 | * |
| 740 | * @param policy is the srtp_policy_t struct that describes the policy |
| 741 | * for the session. The struct may be a single element, or it may be |
| 742 | * the head of a list, in which case each element of the list is |
| 743 | * processed. The final element of the list @b must |
| 744 | * have its `next' field set to NULL. |
| 745 | * |
| 746 | * @return |
| 747 | * - srtp_err_status_ok if stream creation succeded. |
| 748 | * - srtp_err_status_alloc_fail if stream allocation failed |
| 749 | * - srtp_err_status_init_fail if stream initialization failed. |
| 750 | * - [other] otherwise. |
| 751 | * |
| 752 | */ |
| 753 | |
| 754 | srtp_err_status_t srtp_update(srtp_t session, const srtp_policy_t *policy); |
| 755 | |
| 756 | /** |
| 757 | * @brief srtp_update_stream() udpates a SRTP stream. |
| 758 | * |
| 759 | * The function call srtp_update_stream(session, policy) updates |
| 760 | * the stream(s) in the session that match applying the given |
| 761 | * policy and key. The exsisting ROC value of all stream(s) will |
| 762 | * be preserved. |
| 763 | * |
| 764 | * @param session is the SRTP session that contains the streams |
| 765 | * to be updated. |
| 766 | * |
| 767 | * @param policy is the srtp_policy_t struct that describes the policy |
| 768 | * for the session. |
| 769 | * |
| 770 | * @return |
| 771 | * - srtp_err_status_ok if stream creation succeded. |
| 772 | * - srtp_err_status_alloc_fail if stream allocation failed |
| 773 | * - srtp_err_status_init_fail if stream initialization failed. |
| 774 | * - [other] otherwise. |
| 775 | * |
| 776 | */ |
| 777 | |
| 778 | srtp_err_status_t srtp_update_stream(srtp_t session, const srtp_policy_t *policy); |
| 779 | |
| 780 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 781 | * @brief srtp_crypto_policy_set_rtp_default() sets a crypto policy |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 782 | * structure to the SRTP default policy for RTP protection. |
| 783 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 784 | * @param p is a pointer to the policy structure to be set |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 785 | * |
| 786 | * The function call crypto_policy_set_rtp_default(&p) sets the |
| 787 | * crypto_policy_t at location p to the SRTP default policy for RTP |
| 788 | * protection, as defined in the specification. This function is a |
| 789 | * convenience that helps to avoid dealing directly with the policy |
| 790 | * data structure. You are encouraged to initialize policy elements |
| 791 | * with this function call. Doing so may allow your code to be |
| 792 | * forward compatible with later versions of libSRTP that include more |
| 793 | * elements in the crypto_policy_t datatype. |
| 794 | * |
| 795 | * @return void. |
| 796 | * |
| 797 | */ |
| 798 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 799 | void srtp_crypto_policy_set_rtp_default(srtp_crypto_policy_t *p); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 800 | |
| 801 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 802 | * @brief srtp_crypto_policy_set_rtcp_default() sets a crypto policy |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 803 | * structure to the SRTP default policy for RTCP protection. |
| 804 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 805 | * @param p is a pointer to the policy structure to be set |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 806 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 807 | * The function call srtp_crypto_policy_set_rtcp_default(&p) sets the |
| 808 | * srtp_crypto_policy_t at location p to the SRTP default policy for RTCP |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 809 | * protection, as defined in the specification. This function is a |
| 810 | * convenience that helps to avoid dealing directly with the policy |
| 811 | * data structure. You are encouraged to initialize policy elements |
| 812 | * with this function call. Doing so may allow your code to be |
| 813 | * forward compatible with later versions of libSRTP that include more |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 814 | * elements in the srtp_crypto_policy_t datatype. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 815 | * |
| 816 | * @return void. |
| 817 | * |
| 818 | */ |
| 819 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 820 | void srtp_crypto_policy_set_rtcp_default(srtp_crypto_policy_t *p); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 821 | |
| 822 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 823 | * @brief srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80() sets a crypto |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 824 | * policy structure to the SRTP default policy for RTP protection. |
| 825 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 826 | * @param p is a pointer to the policy structure to be set |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 827 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 828 | * The function srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80() is a |
| 829 | * synonym for srtp_crypto_policy_set_rtp_default(). It conforms to the |
Jonathan Lennox | d8d5cd0 | 2010-05-17 20:08:17 +0000 | [diff] [blame] | 830 | * naming convention used in RFC 4568 (SDP Security Descriptions for |
| 831 | * Media Streams). |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 832 | * |
| 833 | * @return void. |
| 834 | * |
| 835 | */ |
| 836 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 837 | #define srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80(p) srtp_crypto_policy_set_rtp_default(p) |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 838 | |
| 839 | |
| 840 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 841 | * @brief srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32() sets a crypto |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 842 | * policy structure to a short-authentication tag policy |
| 843 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 844 | * @param p is a pointer to the policy structure to be set |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 845 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 846 | * The function call srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32(&p) |
| 847 | * sets the srtp_crypto_policy_t at location p to use policy |
Jonathan Lennox | d8d5cd0 | 2010-05-17 20:08:17 +0000 | [diff] [blame] | 848 | * AES_CM_128_HMAC_SHA1_32 as defined in RFC 4568. |
| 849 | * This policy uses AES-128 |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 850 | * Counter Mode encryption and HMAC-SHA1 authentication, with an |
| 851 | * authentication tag that is only 32 bits long. This length is |
| 852 | * considered adequate only for protecting audio and video media that |
| 853 | * use a stateless playback function. See Section 7.5 of RFC 3711 |
| 854 | * (http://www.ietf.org/rfc/rfc3711.txt). |
| 855 | * |
| 856 | * This function is a convenience that helps to avoid dealing directly |
| 857 | * with the policy data structure. You are encouraged to initialize |
| 858 | * policy elements with this function call. Doing so may allow your |
| 859 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 860 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 861 | * |
| 862 | * @warning This crypto policy is intended for use in SRTP, but not in |
| 863 | * SRTCP. It is recommended that a policy that uses longer |
| 864 | * authentication tags be used for SRTCP. See Section 7.5 of RFC 3711 |
| 865 | * (http://www.ietf.org/rfc/rfc3711.txt). |
| 866 | * |
| 867 | * @return void. |
| 868 | * |
| 869 | */ |
| 870 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 871 | void srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32(srtp_crypto_policy_t *p); |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 872 | |
| 873 | |
| 874 | |
| 875 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 876 | * @brief srtp_crypto_policy_set_aes_cm_128_null_auth() sets a crypto |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 877 | * policy structure to an encryption-only policy |
| 878 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 879 | * @param p is a pointer to the policy structure to be set |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 880 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 881 | * The function call srtp_crypto_policy_set_aes_cm_128_null_auth(&p) sets |
| 882 | * the srtp_crypto_policy_t at location p to use the SRTP default cipher |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 883 | * (AES-128 Counter Mode), but to use no authentication method. This |
| 884 | * policy is NOT RECOMMENDED unless it is unavoidable; see Section 7.5 |
| 885 | * of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). |
| 886 | * |
| 887 | * This function is a convenience that helps to avoid dealing directly |
| 888 | * with the policy data structure. You are encouraged to initialize |
| 889 | * policy elements with this function call. Doing so may allow your |
| 890 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 891 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 892 | * |
| 893 | * @warning This policy is NOT RECOMMENDED for SRTP unless it is |
| 894 | * unavoidable, and it is NOT RECOMMENDED at all for SRTCP; see |
| 895 | * Section 7.5 of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). |
| 896 | * |
| 897 | * @return void. |
| 898 | * |
| 899 | */ |
| 900 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 901 | void srtp_crypto_policy_set_aes_cm_128_null_auth(srtp_crypto_policy_t *p); |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 902 | |
| 903 | |
| 904 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 905 | * @brief srtp_crypto_policy_set_null_cipher_hmac_sha1_80() sets a crypto |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 906 | * policy structure to an authentication-only policy |
| 907 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 908 | * @param p is a pointer to the policy structure to be set |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 909 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 910 | * The function call srtp_crypto_policy_set_null_cipher_hmac_sha1_80(&p) |
| 911 | * sets the srtp_crypto_policy_t at location p to use HMAC-SHA1 with an 80 |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 912 | * bit authentication tag to provide message authentication, but to |
| 913 | * use no encryption. This policy is NOT RECOMMENDED for SRTP unless |
| 914 | * there is a requirement to forego encryption. |
| 915 | * |
| 916 | * This function is a convenience that helps to avoid dealing directly |
| 917 | * with the policy data structure. You are encouraged to initialize |
| 918 | * policy elements with this function call. Doing so may allow your |
| 919 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 920 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 921 | * |
| 922 | * @warning This policy is NOT RECOMMENDED for SRTP unless there is a |
| 923 | * requirement to forego encryption. |
| 924 | * |
| 925 | * @return void. |
| 926 | * |
| 927 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 928 | void srtp_crypto_policy_set_null_cipher_hmac_sha1_80(srtp_crypto_policy_t *p); |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 929 | |
jfigus | 267956d | 2014-11-06 10:49:21 -0500 | [diff] [blame] | 930 | /** |
| 931 | * @brief srtp_crypto_policy_set_null_cipher_hmac_null() sets a crypto |
| 932 | * policy structure to use no encryption or authentication. |
| 933 | * |
| 934 | * @param p is a pointer to the policy structure to be set |
| 935 | * |
| 936 | * The function call srtp_crypto_policy_set_null_cipher_hmac_null(&p) |
| 937 | * sets the srtp_crypto_policy_t at location p to use no encryption and |
| 938 | * no authentication. This policy should only be used for testing and |
| 939 | * troubleshootingl. |
| 940 | * |
| 941 | * This function is a convenience that helps to avoid dealing directly |
| 942 | * with the policy data structure. You are encouraged to initialize |
| 943 | * policy elements with this function call. Doing so may allow your |
| 944 | * code to be forward compatible with later versions of libSRTP that |
| 945 | * include more elements in the srtp_crypto_policy_t datatype. |
| 946 | * |
| 947 | * @warning This policy is NOT RECOMMENDED for SRTP unless there is a |
| 948 | * requirement to forego encryption and authentication. |
| 949 | * |
| 950 | * @return void. |
| 951 | * |
| 952 | */ |
| 953 | void srtp_crypto_policy_set_null_cipher_hmac_null(srtp_crypto_policy_t *p); |
| 954 | |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 955 | |
| 956 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 957 | * @brief srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80() sets a crypto |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 958 | * policy structure to a encryption and authentication policy using AES-256 |
| 959 | * for RTP protection. |
| 960 | * |
| 961 | * @param p is a pointer to the policy structure to be set |
| 962 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 963 | * The function call srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80(&p) |
| 964 | * sets the srtp_crypto_policy_t at location p to use policy |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 965 | * AES_CM_256_HMAC_SHA1_80 as defined in |
| 966 | * draft-ietf-avt-srtp-big-aes-03.txt. This policy uses AES-256 |
| 967 | * Counter Mode encryption and HMAC-SHA1 authentication, with an 80 bit |
| 968 | * authentication tag. |
| 969 | * |
| 970 | * This function is a convenience that helps to avoid dealing directly |
| 971 | * with the policy data structure. You are encouraged to initialize |
| 972 | * policy elements with this function call. Doing so may allow your |
| 973 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 974 | * include more elements in the srtp_crypto_policy_t datatype. |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 975 | * |
| 976 | * @return void. |
| 977 | * |
| 978 | */ |
| 979 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 980 | void srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80(srtp_crypto_policy_t *p); |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 981 | |
| 982 | |
| 983 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 984 | * @brief srtp_crypto_policy_set_aes_cm_256_hmac_sha1_32() sets a crypto |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 985 | * policy structure to a short-authentication tag policy using AES-256 |
| 986 | * encryption. |
| 987 | * |
| 988 | * @param p is a pointer to the policy structure to be set |
| 989 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 990 | * The function call srtp_crypto_policy_set_aes_cm_256_hmac_sha1_32(&p) |
| 991 | * sets the srtp_crypto_policy_t at location p to use policy |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 992 | * AES_CM_256_HMAC_SHA1_32 as defined in |
| 993 | * draft-ietf-avt-srtp-big-aes-03.txt. This policy uses AES-256 |
| 994 | * Counter Mode encryption and HMAC-SHA1 authentication, with an |
| 995 | * authentication tag that is only 32 bits long. This length is |
| 996 | * considered adequate only for protecting audio and video media that |
| 997 | * use a stateless playback function. See Section 7.5 of RFC 3711 |
| 998 | * (http://www.ietf.org/rfc/rfc3711.txt). |
| 999 | * |
| 1000 | * This function is a convenience that helps to avoid dealing directly |
| 1001 | * with the policy data structure. You are encouraged to initialize |
| 1002 | * policy elements with this function call. Doing so may allow your |
| 1003 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1004 | * include more elements in the srtp_crypto_policy_t datatype. |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 1005 | * |
| 1006 | * @warning This crypto policy is intended for use in SRTP, but not in |
| 1007 | * SRTCP. It is recommended that a policy that uses longer |
| 1008 | * authentication tags be used for SRTCP. See Section 7.5 of RFC 3711 |
| 1009 | * (http://www.ietf.org/rfc/rfc3711.txt). |
| 1010 | * |
| 1011 | * @return void. |
| 1012 | * |
| 1013 | */ |
| 1014 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1015 | void srtp_crypto_policy_set_aes_cm_256_hmac_sha1_32(srtp_crypto_policy_t *p); |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 1016 | |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1017 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1018 | * @brief srtp_crypto_policy_set_aes_cm_256_null_auth() sets a crypto |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1019 | * policy structure to an encryption-only policy |
| 1020 | * |
| 1021 | * @param p is a pointer to the policy structure to be set |
| 1022 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1023 | * The function call srtp_crypto_policy_set_aes_cm_256_null_auth(&p) sets |
| 1024 | * the srtp_crypto_policy_t at location p to use the SRTP default cipher |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1025 | * (AES-256 Counter Mode), but to use no authentication method. This |
| 1026 | * policy is NOT RECOMMENDED unless it is unavoidable; see Section 7.5 |
| 1027 | * of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). |
| 1028 | * |
| 1029 | * This function is a convenience that helps to avoid dealing directly |
| 1030 | * with the policy data structure. You are encouraged to initialize |
| 1031 | * policy elements with this function call. Doing so may allow your |
| 1032 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1033 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1034 | * |
| 1035 | * @warning This policy is NOT RECOMMENDED for SRTP unless it is |
| 1036 | * unavoidable, and it is NOT RECOMMENDED at all for SRTCP; see |
| 1037 | * Section 7.5 of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). |
| 1038 | * |
| 1039 | * @return void. |
| 1040 | * |
| 1041 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1042 | void srtp_crypto_policy_set_aes_cm_256_null_auth(srtp_crypto_policy_t *p); |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1043 | |
| 1044 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1045 | * @brief srtp_crypto_policy_set_aes_gcm_128_8_auth() sets a crypto |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1046 | * policy structure to an AEAD encryption policy. |
| 1047 | * |
| 1048 | * @param p is a pointer to the policy structure to be set |
| 1049 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1050 | * The function call srtp_crypto_policy_set_aes_gcm_128_8_auth(&p) sets |
| 1051 | * the srtp_crypto_policy_t at location p to use the SRTP default cipher |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1052 | * (AES-128 Galois Counter Mode) with 8 octet auth tag. This |
| 1053 | * policy applies confidentiality and authentication to both the |
| 1054 | * RTP and RTCP packets. |
| 1055 | * |
| 1056 | * This function is a convenience that helps to avoid dealing directly |
| 1057 | * with the policy data structure. You are encouraged to initialize |
| 1058 | * policy elements with this function call. Doing so may allow your |
| 1059 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1060 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1061 | * |
| 1062 | * @return void. |
| 1063 | * |
| 1064 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1065 | void srtp_crypto_policy_set_aes_gcm_128_8_auth(srtp_crypto_policy_t *p); |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1066 | |
| 1067 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1068 | * @brief srtp_crypto_policy_set_aes_gcm_256_8_auth() sets a crypto |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1069 | * policy structure to an AEAD encryption policy |
| 1070 | * |
| 1071 | * @param p is a pointer to the policy structure to be set |
| 1072 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1073 | * The function call srtp_crypto_policy_set_aes_gcm_256_8_auth(&p) sets |
| 1074 | * the srtp_crypto_policy_t at location p to use the SRTP default cipher |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1075 | * (AES-256 Galois Counter Mode) with 8 octet auth tag. This |
| 1076 | * policy applies confidentiality and authentication to both the |
| 1077 | * RTP and RTCP packets. |
| 1078 | * |
| 1079 | * This function is a convenience that helps to avoid dealing directly |
| 1080 | * with the policy data structure. You are encouraged to initialize |
| 1081 | * policy elements with this function call. Doing so may allow your |
| 1082 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1083 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1084 | * |
| 1085 | * @return void. |
| 1086 | * |
| 1087 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1088 | void srtp_crypto_policy_set_aes_gcm_256_8_auth(srtp_crypto_policy_t *p); |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1089 | |
| 1090 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1091 | * @brief srtp_crypto_policy_set_aes_gcm_128_8_only_auth() sets a crypto |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1092 | * policy structure to an AEAD authentication-only policy |
| 1093 | * |
| 1094 | * @param p is a pointer to the policy structure to be set |
| 1095 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1096 | * The function call srtp_crypto_policy_set_aes_gcm_128_8_only_auth(&p) sets |
| 1097 | * the srtp_crypto_policy_t at location p to use the SRTP default cipher |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1098 | * (AES-128 Galois Counter Mode) with 8 octet auth tag. This policy |
| 1099 | * applies confidentiality and authentication to the RTP packets, |
| 1100 | * but only authentication to the RTCP packets. |
| 1101 | * |
| 1102 | * This function is a convenience that helps to avoid dealing directly |
| 1103 | * with the policy data structure. You are encouraged to initialize |
| 1104 | * policy elements with this function call. Doing so may allow your |
| 1105 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1106 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1107 | * |
| 1108 | * @return void. |
| 1109 | * |
| 1110 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1111 | void srtp_crypto_policy_set_aes_gcm_128_8_only_auth(srtp_crypto_policy_t *p); |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1112 | |
| 1113 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1114 | * @brief srtp_crypto_policy_set_aes_gcm_256_8_only_auth() sets a crypto |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1115 | * policy structure to an AEAD authentication-only policy |
| 1116 | * |
| 1117 | * @param p is a pointer to the policy structure to be set |
| 1118 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1119 | * The function call srtp_crypto_policy_set_aes_gcm_256_8_only_auth(&p) sets |
| 1120 | * the srtp_crypto_policy_t at location p to use the SRTP default cipher |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1121 | * (AES-256 Galois Counter Mode) with 8 octet auth tag. This policy |
| 1122 | * applies confidentiality and authentication to the RTP packets, |
| 1123 | * but only authentication to the RTCP packets. |
| 1124 | * |
| 1125 | * This function is a convenience that helps to avoid dealing directly |
| 1126 | * with the policy data structure. You are encouraged to initialize |
| 1127 | * policy elements with this function call. Doing so may allow your |
| 1128 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1129 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1130 | * |
| 1131 | * @return void. |
| 1132 | * |
| 1133 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1134 | void srtp_crypto_policy_set_aes_gcm_256_8_only_auth(srtp_crypto_policy_t *p); |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1135 | |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1136 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1137 | * @brief srtp_crypto_policy_set_aes_gcm_128_16_auth() sets a crypto |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1138 | * policy structure to an AEAD encryption policy. |
| 1139 | * |
| 1140 | * @param p is a pointer to the policy structure to be set |
| 1141 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1142 | * The function call srtp_crypto_policy_set_aes_gcm_128_16_auth(&p) sets |
| 1143 | * the srtp_crypto_policy_t at location p to use the SRTP default cipher |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1144 | * (AES-128 Galois Counter Mode) with 16 octet auth tag. This |
| 1145 | * policy applies confidentiality and authentication to both the |
| 1146 | * RTP and RTCP packets. |
| 1147 | * |
| 1148 | * This function is a convenience that helps to avoid dealing directly |
| 1149 | * with the policy data structure. You are encouraged to initialize |
| 1150 | * policy elements with this function call. Doing so may allow your |
| 1151 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1152 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1153 | * |
| 1154 | * @return void. |
| 1155 | * |
| 1156 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1157 | void srtp_crypto_policy_set_aes_gcm_128_16_auth(srtp_crypto_policy_t *p); |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1158 | |
| 1159 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1160 | * @brief srtp_crypto_policy_set_aes_gcm_256_16_auth() sets a crypto |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1161 | * policy structure to an AEAD encryption policy |
| 1162 | * |
| 1163 | * @param p is a pointer to the policy structure to be set |
| 1164 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1165 | * The function call srtp_crypto_policy_set_aes_gcm_256_16_auth(&p) sets |
| 1166 | * the srtp_crypto_policy_t at location p to use the SRTP default cipher |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1167 | * (AES-256 Galois Counter Mode) with 16 octet auth tag. This |
| 1168 | * policy applies confidentiality and authentication to both the |
| 1169 | * RTP and RTCP packets. |
| 1170 | * |
| 1171 | * This function is a convenience that helps to avoid dealing directly |
| 1172 | * with the policy data structure. You are encouraged to initialize |
| 1173 | * policy elements with this function call. Doing so may allow your |
| 1174 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1175 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1176 | * |
| 1177 | * @return void. |
| 1178 | * |
| 1179 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1180 | void srtp_crypto_policy_set_aes_gcm_256_16_auth(srtp_crypto_policy_t *p); |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1181 | |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 1182 | |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 1183 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1184 | * @brief srtp_dealloc() deallocates storage for an SRTP session |
| 1185 | * context. |
| 1186 | * |
| 1187 | * The function call srtp_dealloc(s) deallocates storage for the |
| 1188 | * SRTP session context s. This function should be called no more |
| 1189 | * than one time for each of the contexts allocated by the function |
| 1190 | * srtp_create(). |
| 1191 | * |
| 1192 | * @param s is the srtp_t for the session to be deallocated. |
| 1193 | * |
| 1194 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1195 | * - srtp_err_status_ok if there no problems. |
| 1196 | * - srtp_err_status_dealloc_fail a memory deallocation failure occured. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1197 | */ |
| 1198 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1199 | srtp_err_status_t srtp_dealloc(srtp_t s); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1200 | |
| 1201 | |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1202 | /* |
| 1203 | * @brief identifies a particular SRTP profile |
| 1204 | * |
| 1205 | * An srtp_profile_t enumeration is used to identify a particular SRTP |
| 1206 | * profile (that is, a set of algorithms and parameters). These |
| 1207 | * profiles are defined in the DTLS-SRTP draft. |
| 1208 | */ |
| 1209 | |
| 1210 | typedef enum { |
| 1211 | srtp_profile_reserved = 0, |
| 1212 | srtp_profile_aes128_cm_sha1_80 = 1, |
| 1213 | srtp_profile_aes128_cm_sha1_32 = 2, |
| 1214 | srtp_profile_aes256_cm_sha1_80 = 3, |
| 1215 | srtp_profile_aes256_cm_sha1_32 = 4, |
| 1216 | srtp_profile_null_sha1_80 = 5, |
| 1217 | srtp_profile_null_sha1_32 = 6, |
| 1218 | } srtp_profile_t; |
| 1219 | |
| 1220 | |
| 1221 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1222 | * @brief srtp_crypto_policy_set_from_profile_for_rtp() sets a crypto policy |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1223 | * structure to the appropriate value for RTP based on an srtp_profile_t |
| 1224 | * |
| 1225 | * @param p is a pointer to the policy structure to be set |
| 1226 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1227 | * The function call srtp_crypto_policy_set_rtp_default(&policy, profile) |
| 1228 | * sets the srtp_crypto_policy_t at location policy to the policy for RTP |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1229 | * protection, as defined by the srtp_profile_t profile. |
| 1230 | * |
| 1231 | * This function is a convenience that helps to avoid dealing directly |
| 1232 | * with the policy data structure. You are encouraged to initialize |
| 1233 | * policy elements with this function call. Doing so may allow your |
| 1234 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1235 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1236 | * |
| 1237 | * @return values |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1238 | * - srtp_err_status_ok no problems were encountered |
| 1239 | * - srtp_err_status_bad_param the profile is not supported |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1240 | * |
| 1241 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1242 | srtp_err_status_t srtp_crypto_policy_set_from_profile_for_rtp(srtp_crypto_policy_t *policy, srtp_profile_t profile); |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1243 | |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1248 | * @brief srtp_crypto_policy_set_from_profile_for_rtcp() sets a crypto policy |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1249 | * structure to the appropriate value for RTCP based on an srtp_profile_t |
| 1250 | * |
| 1251 | * @param p is a pointer to the policy structure to be set |
| 1252 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1253 | * The function call srtp_crypto_policy_set_rtcp_default(&policy, profile) |
| 1254 | * sets the srtp_crypto_policy_t at location policy to the policy for RTCP |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1255 | * protection, as defined by the srtp_profile_t profile. |
| 1256 | * |
| 1257 | * This function is a convenience that helps to avoid dealing directly |
| 1258 | * with the policy data structure. You are encouraged to initialize |
| 1259 | * policy elements with this function call. Doing so may allow your |
| 1260 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1261 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1262 | * |
| 1263 | * @return values |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1264 | * - srtp_err_status_ok no problems were encountered |
| 1265 | * - srtp_err_status_bad_param the profile is not supported |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1266 | * |
| 1267 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1268 | srtp_err_status_t srtp_crypto_policy_set_from_profile_for_rtcp(srtp_crypto_policy_t *policy, srtp_profile_t profile); |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1269 | |
| 1270 | /** |
| 1271 | * @brief returns the master key length for a given SRTP profile |
| 1272 | */ |
| 1273 | unsigned int |
| 1274 | srtp_profile_get_master_key_length(srtp_profile_t profile); |
| 1275 | |
| 1276 | |
| 1277 | /** |
| 1278 | * @brief returns the master salt length for a given SRTP profile |
| 1279 | */ |
| 1280 | unsigned int |
| 1281 | srtp_profile_get_master_salt_length(srtp_profile_t profile); |
| 1282 | |
| 1283 | /** |
| 1284 | * @brief appends the salt to the key |
| 1285 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1286 | * The function call srtp_append_salt_to_key(k, klen, s, slen) |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1287 | * copies the string s to the location at klen bytes following |
| 1288 | * the location k. |
| 1289 | * |
| 1290 | * @warning There must be at least bytes_in_salt + bytes_in_key bytes |
| 1291 | * available at the location pointed to by key. |
| 1292 | * |
| 1293 | */ |
| 1294 | |
| 1295 | void |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1296 | srtp_append_salt_to_key(unsigned char *key, unsigned int bytes_in_key, |
| 1297 | unsigned char *salt, unsigned int bytes_in_salt); |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1298 | |
| 1299 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1300 | |
| 1301 | /** |
| 1302 | * @} |
| 1303 | */ |
| 1304 | |
| 1305 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1306 | |
| 1307 | /** |
| 1308 | * @defgroup SRTCP Secure RTCP |
| 1309 | * @ingroup SRTP |
| 1310 | * |
| 1311 | * @brief Secure RTCP functions are used to protect RTCP traffic. |
| 1312 | * |
| 1313 | * RTCP is the control protocol for RTP. libSRTP protects RTCP |
| 1314 | * traffic in much the same way as it does RTP traffic. The function |
| 1315 | * srtp_protect_rtcp() applies cryptographic protections to outbound |
| 1316 | * RTCP packets, and srtp_unprotect_rtcp() verifies the protections on |
| 1317 | * inbound RTCP packets. |
| 1318 | * |
| 1319 | * A note on the naming convention: srtp_protect_rtcp() has an srtp_t |
| 1320 | * as its first argument, and thus has `srtp_' as its prefix. The |
| 1321 | * trailing `_rtcp' indicates the protocol on which it acts. |
| 1322 | * |
| 1323 | * @{ |
| 1324 | */ |
| 1325 | |
| 1326 | /** |
| 1327 | * @brief srtp_protect_rtcp() is the Secure RTCP sender-side packet |
| 1328 | * processing function. |
| 1329 | * |
| 1330 | * The function call srtp_protect_rtcp(ctx, rtp_hdr, len_ptr) applies |
| 1331 | * SRTCP protection to the RTCP packet rtcp_hdr (which has length |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1332 | * *len_ptr) using the SRTP session context ctx. If srtp_err_status_ok is |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1333 | * returned, then rtp_hdr points to the resulting SRTCP packet and |
| 1334 | * *len_ptr is the number of octets in that packet; otherwise, no |
| 1335 | * assumptions should be made about the value of either data elements. |
| 1336 | * |
| 1337 | * @warning This function assumes that it can write the authentication |
| 1338 | * tag into the location in memory immediately following the RTCP |
| 1339 | * packet, and assumes that the RTCP packet is aligned on a 32-bit |
| 1340 | * boundary. |
| 1341 | * |
jfigus | 5e33729 | 2013-05-28 13:57:47 -0400 | [diff] [blame] | 1342 | * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN+4 |
| 1343 | * into the location in memory immediately following the RTCP packet. |
| 1344 | * Callers MUST ensure that this much writable memory is available in |
| 1345 | * the buffer that holds the RTCP packet. |
| 1346 | * |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1347 | * @param ctx is the SRTP context to use in processing the packet. |
| 1348 | * |
| 1349 | * @param rtcp_hdr is a pointer to the RTCP packet (before the call); after |
| 1350 | * the function returns, it points to the srtp packet. |
| 1351 | * |
| 1352 | * @param pkt_octet_len is a pointer to the length in octets of the |
| 1353 | * complete RTCP packet (header and body) before the function call, |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1354 | * and of the complete SRTCP packet after the call, if srtp_err_status_ok |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1355 | * was returned. Otherwise, the value of the data to which it points |
| 1356 | * is undefined. |
| 1357 | * |
| 1358 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1359 | * - srtp_err_status_ok if there were no problems. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1360 | * - [other] if there was a failure in |
| 1361 | * the cryptographic mechanisms. |
| 1362 | */ |
| 1363 | |
| 1364 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1365 | srtp_err_status_t srtp_protect_rtcp(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1366 | |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1367 | |
| 1368 | /** |
| 1369 | * @brief srtp_protect_rtcp_mki() is the Secure RTCP sender-side packet |
| 1370 | * processing function that can utilize mki. |
| 1371 | * |
| 1372 | * The function call srtp_protect_rtcp(ctx, rtp_hdr, len_ptr) applies |
| 1373 | * SRTCP protection to the RTCP packet rtcp_hdr (which has length |
| 1374 | * *len_ptr) using the SRTP session context ctx. If srtp_err_status_ok is |
| 1375 | * returned, then rtp_hdr points to the resulting SRTCP packet and |
| 1376 | * *len_ptr is the number of octets in that packet; otherwise, no |
| 1377 | * assumptions should be made about the value of either data elements. |
| 1378 | * |
| 1379 | * @warning This function assumes that it can write the authentication |
| 1380 | * tag into the location in memory immediately following the RTCP |
| 1381 | * packet, and assumes that the RTCP packet is aligned on a 32-bit |
| 1382 | * boundary. |
| 1383 | * |
| 1384 | * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN+4 |
| 1385 | * into the location in memory immediately following the RTCP packet. |
| 1386 | * Callers MUST ensure that this much writable memory is available in |
| 1387 | * the buffer that holds the RTCP packet. |
| 1388 | * |
| 1389 | * @param ctx is the SRTP context to use in processing the packet. |
| 1390 | * |
| 1391 | * @param rtcp_hdr is a pointer to the RTCP packet (before the call); after |
| 1392 | * the function returns, it points to the srtp packet. |
| 1393 | * |
| 1394 | * @param pkt_octet_len is a pointer to the length in octets of the |
| 1395 | * complete RTCP packet (header and body) before the function call, |
| 1396 | * and of the complete SRTCP packet after the call, if srtp_err_status_ok |
| 1397 | * was returned. Otherwise, the value of the data to which it points |
| 1398 | * is undefined. |
| 1399 | * |
| 1400 | * @param use_mki is a boolean to tell the system if mki is being used. If |
| 1401 | * set to false then will use the first set of session keys. If set to true will |
| 1402 | * use the session keys identified by the mki_index |
| 1403 | * |
| 1404 | * @param mki_index integer value specifying which set of session kesy should be |
| 1405 | * used if use_mki is set to true. |
| 1406 | * |
| 1407 | * @return |
| 1408 | * - srtp_err_status_ok if there were no problems. |
| 1409 | * - [other] if there was a failure in |
| 1410 | * the cryptographic mechanisms. |
| 1411 | */ |
| 1412 | |
| 1413 | srtp_err_status_t srtp_protect_rtcp_mki(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len, |
| 1414 | unsigned int use_mki, unsigned int mki_index); |
| 1415 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1416 | /** |
| 1417 | * @brief srtp_unprotect_rtcp() is the Secure RTCP receiver-side packet |
| 1418 | * processing function. |
| 1419 | * |
| 1420 | * The function call srtp_unprotect_rtcp(ctx, srtp_hdr, len_ptr) |
| 1421 | * verifies the Secure RTCP protection of the SRTCP packet pointed to |
| 1422 | * by srtcp_hdr (which has length *len_ptr), using the SRTP session |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1423 | * context ctx. If srtp_err_status_ok is returned, then srtcp_hdr points |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1424 | * to the resulting RTCP packet and *len_ptr is the number of octets |
| 1425 | * in that packet; otherwise, no assumptions should be made about the |
| 1426 | * value of either data elements. |
| 1427 | * |
| 1428 | * @warning This function assumes that the SRTCP packet is aligned on a |
| 1429 | * 32-bit boundary. |
| 1430 | * |
| 1431 | * @param ctx is a pointer to the srtp_t which applies to the |
| 1432 | * particular packet. |
| 1433 | * |
| 1434 | * @param srtcp_hdr is a pointer to the header of the SRTCP packet |
| 1435 | * (before the call). After the function returns, it points to the |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1436 | * rtp packet if srtp_err_status_ok was returned; otherwise, the value of |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1437 | * the data to which it points is undefined. |
| 1438 | * |
| 1439 | * @param pkt_octet_len is a pointer to the length in octets of the |
| 1440 | * complete SRTCP packet (header and body) before the function call, |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1441 | * and of the complete rtp packet after the call, if srtp_err_status_ok was |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1442 | * returned. Otherwise, the value of the data to which it points is |
| 1443 | * undefined. |
| 1444 | * |
| 1445 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1446 | * - srtp_err_status_ok if the RTCP packet is valid. |
| 1447 | * - srtp_err_status_auth_fail if the SRTCP packet failed the message |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1448 | * authentication check. |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1449 | * - srtp_err_status_replay_fail if the SRTCP packet is a replay (e.g. has |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1450 | * already been processed and accepted). |
| 1451 | * - [other] if there has been an error in the cryptographic mechanisms. |
| 1452 | * |
| 1453 | */ |
| 1454 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1455 | srtp_err_status_t srtp_unprotect_rtcp(srtp_t ctx, void *srtcp_hdr, int *pkt_octet_len); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1456 | |
| 1457 | /** |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1458 | * @brief srtp_unprotect_rtcp() is the Secure RTCP receiver-side packet |
| 1459 | * processing function. |
| 1460 | * |
| 1461 | * The function call srtp_unprotect_rtcp(ctx, srtp_hdr, len_ptr) |
| 1462 | * verifies the Secure RTCP protection of the SRTCP packet pointed to |
| 1463 | * by srtcp_hdr (which has length *len_ptr), using the SRTP session |
| 1464 | * context ctx. If srtp_err_status_ok is returned, then srtcp_hdr points |
| 1465 | * to the resulting RTCP packet and *len_ptr is the number of octets |
| 1466 | * in that packet; otherwise, no assumptions should be made about the |
| 1467 | * value of either data elements. |
| 1468 | * |
| 1469 | * @warning This function assumes that the SRTCP packet is aligned on a |
| 1470 | * 32-bit boundary. |
| 1471 | * |
| 1472 | * @param ctx is a pointer to the srtp_t which applies to the |
| 1473 | * particular packet. |
| 1474 | * |
| 1475 | * @param srtcp_hdr is a pointer to the header of the SRTCP packet |
| 1476 | * (before the call). After the function returns, it points to the |
| 1477 | * rtp packet if srtp_err_status_ok was returned; otherwise, the value of |
| 1478 | * the data to which it points is undefined. |
| 1479 | * |
| 1480 | * @param pkt_octet_len is a pointer to the length in octets of the |
| 1481 | * complete SRTCP packet (header and body) before the function call, |
| 1482 | * and of the complete rtp packet after the call, if srtp_err_status_ok was |
| 1483 | * returned. Otherwise, the value of the data to which it points is |
| 1484 | * undefined. |
| 1485 | * |
| 1486 | * @return |
| 1487 | * - srtp_err_status_ok if the RTCP packet is valid. |
| 1488 | * - srtp_err_status_auth_fail if the SRTCP packet failed the message |
| 1489 | * authentication check. |
| 1490 | * - srtp_err_status_replay_fail if the SRTCP packet is a replay (e.g. has |
| 1491 | * already been processed and accepted). |
| 1492 | * - srtp_err_status_bad_mki if the MKI in the packet is not a known MKI id |
| 1493 | * - [other] if there has been an error in the cryptographic mechanisms. |
| 1494 | * |
| 1495 | */ |
| 1496 | |
Geir Istad | 626e9e8 | 2017-02-20 18:15:05 +0100 | [diff] [blame] | 1497 | srtp_err_status_t srtp_unprotect_rtcp_mki(srtp_t ctx, void *srtcp_hdr, |
| 1498 | int *pkt_octet_len, |
| 1499 | unsigned int use_mki); |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1500 | |
| 1501 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1502 | * @} |
| 1503 | */ |
| 1504 | |
Iñaki Baz Castillo | 241fec3 | 2014-08-21 00:51:00 +0200 | [diff] [blame] | 1505 | |
| 1506 | /** |
| 1507 | * @defgroup User data associated to a SRTP session. |
| 1508 | * @ingroup SRTP |
| 1509 | * |
| 1510 | * @brief Store custom user data within a SRTP session. |
| 1511 | * |
| 1512 | * @{ |
| 1513 | */ |
| 1514 | |
| 1515 | /** |
| 1516 | * @brief srtp_set_user_data() stores the given pointer into the SRTP |
| 1517 | * session for later retrieval. |
| 1518 | * |
| 1519 | * @param ctx is the srtp_t context in which the given data pointer is |
| 1520 | * stored. |
| 1521 | * |
| 1522 | * @param data is a pointer to the custom information (struct, function, |
| 1523 | * etc) associated with the SRTP session. |
| 1524 | * |
| 1525 | * @return void. |
| 1526 | * |
| 1527 | */ |
| 1528 | |
| 1529 | void |
| 1530 | srtp_set_user_data(srtp_t ctx, void *data); |
| 1531 | |
| 1532 | /** |
| 1533 | * @brief srtp_get_user_data() retrieves the pointer to the custom data |
| 1534 | * previously stored with srtp_set_user_data(). |
| 1535 | * |
| 1536 | * This function is mostly useful for retrieving data associated to a |
| 1537 | * SRTP session when an event fires. The user can then get such a custom |
| 1538 | * data by calling this function with the session field of the |
| 1539 | * srtp_event_data_t struct as argument. |
| 1540 | * |
| 1541 | * @param ctx is the srtp_t context in which the given data pointer was |
| 1542 | * stored. |
| 1543 | * |
| 1544 | * @return void* pointer to the user data. |
| 1545 | * |
| 1546 | */ |
| 1547 | |
| 1548 | void* |
| 1549 | srtp_get_user_data(srtp_t ctx); |
| 1550 | |
| 1551 | /** |
| 1552 | * @} |
| 1553 | */ |
| 1554 | |
| 1555 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1556 | /** |
| 1557 | * @defgroup SRTPevents SRTP events and callbacks |
| 1558 | * @ingroup SRTP |
| 1559 | * |
| 1560 | * @brief libSRTP can use a user-provided callback function to |
| 1561 | * handle events. |
| 1562 | * |
| 1563 | * |
| 1564 | * libSRTP allows a user to provide a callback function to handle |
| 1565 | * events that need to be dealt with outside of the data plane (see |
| 1566 | * the enum srtp_event_t for a description of these events). Dealing |
| 1567 | * with these events is not a strict necessity; they are not |
| 1568 | * security-critical, but the application may suffer if they are not |
| 1569 | * handled. The function srtp_set_event_handler() is used to provide |
| 1570 | * the callback function. |
| 1571 | * |
| 1572 | * A default event handler that merely reports on the events as they |
| 1573 | * happen is included. It is also possible to set the event handler |
| 1574 | * function to NULL, in which case all events will just be silently |
| 1575 | * ignored. |
| 1576 | * |
| 1577 | * @{ |
| 1578 | */ |
| 1579 | |
| 1580 | /** |
| 1581 | * @brief srtp_event_t defines events that need to be handled |
| 1582 | * |
| 1583 | * The enum srtp_event_t defines events that need to be handled |
| 1584 | * outside the `data plane', such as SSRC collisions and |
| 1585 | * key expirations. |
| 1586 | * |
| 1587 | * When a key expires or the maximum number of packets has been |
| 1588 | * reached, an SRTP stream will enter an `expired' state in which no |
| 1589 | * more packets can be protected or unprotected. When this happens, |
| 1590 | * it is likely that you will want to either deallocate the stream |
jfigus | 92c3de3 | 2016-02-02 13:44:39 -0500 | [diff] [blame] | 1591 | * (using srtp_remove_stream()), and possibly allocate a new one. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1592 | * |
| 1593 | * When an SRTP stream expires, the other streams in the same session |
| 1594 | * are unaffected, unless key sharing is used by that stream. In the |
| 1595 | * latter case, all of the streams in the session will expire. |
| 1596 | */ |
| 1597 | |
| 1598 | typedef enum { |
| 1599 | event_ssrc_collision, /**< |
| 1600 | * An SSRC collision occured. |
| 1601 | */ |
| 1602 | event_key_soft_limit, /**< An SRTP stream reached the soft key |
| 1603 | * usage limit and will expire soon. |
| 1604 | */ |
| 1605 | event_key_hard_limit, /**< An SRTP stream reached the hard |
| 1606 | * key usage limit and has expired. |
| 1607 | */ |
| 1608 | event_packet_index_limit /**< An SRTP stream reached the hard |
| 1609 | * packet limit (2^48 packets). |
| 1610 | */ |
| 1611 | } srtp_event_t; |
| 1612 | |
| 1613 | /** |
| 1614 | * @brief srtp_event_data_t is the structure passed as a callback to |
| 1615 | * the event handler function |
| 1616 | * |
| 1617 | * The struct srtp_event_data_t holds the data passed to the event |
| 1618 | * handler function. |
| 1619 | */ |
| 1620 | |
| 1621 | typedef struct srtp_event_data_t { |
| 1622 | srtp_t session; /**< The session in which the event happend. */ |
Pascal Bühler | ef54b90 | 2017-02-16 09:39:13 +0100 | [diff] [blame] | 1623 | uint32_t ssrc; /**< The ssrc in host order of the stream in which the event happend */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1624 | srtp_event_t event; /**< An enum indicating the type of event. */ |
| 1625 | } srtp_event_data_t; |
| 1626 | |
| 1627 | /** |
| 1628 | * @brief srtp_event_handler_func_t is the function prototype for |
| 1629 | * the event handler. |
| 1630 | * |
| 1631 | * The typedef srtp_event_handler_func_t is the prototype for the |
| 1632 | * event handler function. It has as its only argument an |
| 1633 | * srtp_event_data_t which describes the event that needs to be handled. |
| 1634 | * There can only be a single, global handler for all events in |
| 1635 | * libSRTP. |
| 1636 | */ |
| 1637 | |
| 1638 | typedef void (srtp_event_handler_func_t)(srtp_event_data_t *data); |
| 1639 | |
| 1640 | /** |
| 1641 | * @brief sets the event handler to the function supplied by the caller. |
| 1642 | * |
| 1643 | * The function call srtp_install_event_handler(func) sets the event |
| 1644 | * handler function to the value func. The value NULL is acceptable |
| 1645 | * as an argument; in this case, events will be ignored rather than |
| 1646 | * handled. |
| 1647 | * |
| 1648 | * @param func is a pointer to a fuction that takes an srtp_event_data_t |
| 1649 | * pointer as an argument and returns void. This function |
| 1650 | * will be used by libSRTP to handle events. |
| 1651 | */ |
| 1652 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1653 | srtp_err_status_t srtp_install_event_handler(srtp_event_handler_func_t func); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1654 | |
| 1655 | /** |
jfigus | f62b64d | 2014-10-08 13:53:57 -0400 | [diff] [blame] | 1656 | * @brief Returns the version string of the library. |
| 1657 | * |
| 1658 | */ |
Christian Oien | d4e3eec | 2014-10-24 10:14:08 +0200 | [diff] [blame] | 1659 | const char *srtp_get_version_string(void); |
jfigus | f62b64d | 2014-10-08 13:53:57 -0400 | [diff] [blame] | 1660 | |
| 1661 | /** |
| 1662 | * @brief Returns the numeric representation of the library version. |
| 1663 | * |
| 1664 | */ |
| 1665 | unsigned int srtp_get_version(void); |
| 1666 | |
| 1667 | /** |
jfigus | 46d6b47 | 2014-11-14 16:42:01 -0500 | [diff] [blame] | 1668 | * @brief srtp_set_debug_module(mod_name, v) |
| 1669 | * |
| 1670 | * sets dynamic debugging to the value v (0 for off, 1 for on) for the |
| 1671 | * debug module with the name mod_name |
| 1672 | * |
| 1673 | * returns err_status_ok on success, err_status_fail otherwise |
| 1674 | */ |
| 1675 | srtp_err_status_t srtp_set_debug_module(char *mod_name, int v); |
| 1676 | |
| 1677 | /** |
| 1678 | * @brief srtp_list_debug_modules() outputs a list of debugging modules |
| 1679 | * |
| 1680 | */ |
| 1681 | srtp_err_status_t srtp_list_debug_modules(void); |
| 1682 | |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1683 | /** |
Pascal Bühler | af15178 | 2017-02-24 10:51:52 +0100 | [diff] [blame^] | 1684 | * @brief srtp_log_level_t defines log levels. |
| 1685 | * |
| 1686 | * The enumeration srtp_log_level_t defines log levels reported |
| 1687 | * in the srtp_log_handler_func_t. |
| 1688 | * |
| 1689 | */ |
| 1690 | typedef enum { |
| 1691 | srtp_log_level_error, /**< log level is reporting an error message */ |
| 1692 | srtp_log_level_warning, /**< log level is reporting a warning message */ |
| 1693 | srtp_log_level_info, /**< log level is reporting an info message */ |
| 1694 | srtp_log_level_debug /**< log level is reporting a debug message */ |
| 1695 | } srtp_log_level_t; |
| 1696 | |
| 1697 | /** |
| 1698 | * @brief srtp_log_handler_func_t is the function prototype for |
| 1699 | * the log handler. |
| 1700 | * |
| 1701 | * The typedef srtp_event_handler_func_t is the prototype for the |
| 1702 | * event handler function. It has as srtp_log_level_t and log |
| 1703 | * message as arguments. |
| 1704 | * There can only be a single, global handler for all log messages in |
| 1705 | * libSRTP. |
| 1706 | */ |
| 1707 | typedef void (srtp_log_handler_func_t)(srtp_log_level_t level, const char * msg); |
| 1708 | |
| 1709 | /** |
| 1710 | * @brief sets the log handler to the function supplied by the caller. |
| 1711 | * |
| 1712 | * The function call srtp_install_log_handler(func) sets the log |
| 1713 | * handler function to the value func. The value NULL is acceptable |
| 1714 | * as an argument; in this case, log messages will be ignored. |
| 1715 | * This function can be called before srtp_init() inorder to capture |
| 1716 | * any logging during start up. |
| 1717 | * |
| 1718 | * @param func is a pointer to a fuction of type srtp_log_handler_func_t. |
| 1719 | * This function will be used by libSRTP to output log messages. |
| 1720 | */ |
| 1721 | srtp_err_status_t srtp_install_log_handler(srtp_log_handler_func_t func); |
| 1722 | |
| 1723 | /** |
Ryan Hooper | ab0345b | 2017-02-07 16:07:59 -0500 | [diff] [blame] | 1724 | * @brief srtp_get_protect_trailer_length(session, use_mki, mki_index, length) |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1725 | * |
| 1726 | * Determines the length of the amount of data Lib SRTP will add to the |
| 1727 | * packet during the protect process. The length is returned in the length parameter |
| 1728 | * |
| 1729 | * returns err_status_ok on success, err_status_bad_mki if the MKI index is invalid |
| 1730 | * |
| 1731 | */ |
Ryan Hooper | ab0345b | 2017-02-07 16:07:59 -0500 | [diff] [blame] | 1732 | srtp_err_status_t srtp_get_protect_trailer_length(srtp_t session, uint32_t use_mki, |
| 1733 | uint32_t mki_index, uint32_t *length); |
| 1734 | |
| 1735 | /** |
| 1736 | * @brief srtp_get_protect_rtcp_trailer_length(session, use_mki, mki_index, length) |
| 1737 | * |
| 1738 | * Determines the length of the amount of data Lib SRTP will add to the |
| 1739 | * packet during the protect process. The length is returned in the length parameter |
| 1740 | * |
| 1741 | * returns err_status_ok on success, err_status_bad_mki if the MKI index is invalid |
| 1742 | * |
| 1743 | */ |
| 1744 | srtp_err_status_t srtp_get_protect_rtcp_trailer_length(srtp_t session, uint32_t use_mki, |
| 1745 | uint32_t mki_index, uint32_t *length); |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1746 | |
jfigus | 46d6b47 | 2014-11-14 16:42:01 -0500 | [diff] [blame] | 1747 | |
| 1748 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1749 | * @} |
| 1750 | */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1751 | /* in host order, so outside the #if */ |
| 1752 | #define SRTCP_E_BIT 0x80000000 |
| 1753 | /* for byte-access */ |
| 1754 | #define SRTCP_E_BYTE_BIT 0x80 |
| 1755 | #define SRTCP_INDEX_MASK 0x7fffffff |
| 1756 | |
Marcus Sundberg | cb60bf8 | 2005-10-17 17:23:05 +0000 | [diff] [blame] | 1757 | #ifdef __cplusplus |
| 1758 | } |
| 1759 | #endif |
| 1760 | |
Pascal Bühler | c3655db | 2017-02-01 09:11:27 +0100 | [diff] [blame] | 1761 | #endif /* SRTP_SRTP_H */ |