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 |
| 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 | |
| 288 | typedef struct srtp_stream_ctx_t_ srtp_stream_ctx_t; |
| 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 | /* |
| 292 | * nota bene: since libSRTP doesn't support the use of the MKI, the |
| 293 | * SRTP_MAX_TRAILER_LEN value is just the maximum tag length |
| 294 | */ |
| 295 | |
| 296 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 297 | * @brief srtp_sec_serv_t describes a set of security services. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 298 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 299 | * A srtp_sec_serv_t enumeration is used to describe the particular |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 300 | * security services that will be applied by a particular crypto |
| 301 | * policy (or other mechanism). |
| 302 | */ |
| 303 | |
| 304 | typedef enum { |
| 305 | sec_serv_none = 0, /**< no services */ |
| 306 | sec_serv_conf = 1, /**< confidentiality */ |
| 307 | sec_serv_auth = 2, /**< authentication */ |
| 308 | sec_serv_conf_and_auth = 3 /**< confidentiality and authentication */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 309 | } srtp_sec_serv_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 310 | |
| 311 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 312 | * @brief srtp_crypto_policy_t describes a particular crypto policy that |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 313 | * can be applied to an SRTP stream. |
| 314 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 315 | * A srtp_crypto_policy_t describes a particular cryptographic policy that |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 316 | * can be applied to an SRTP or SRTCP stream. An SRTP session policy |
| 317 | * consists of a list of these policies, one for each SRTP stream |
| 318 | * in the session. |
| 319 | */ |
| 320 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 321 | typedef struct srtp_crypto_policy_t { |
| 322 | srtp_cipher_type_id_t cipher_type; /**< An integer representing |
| 323 | * the type of cipher. */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 324 | int cipher_key_len; /**< The length of the cipher key |
| 325 | * in octets. */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 326 | srtp_auth_type_id_t auth_type; /**< An integer representing the |
| 327 | * authentication function. */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 328 | int auth_key_len; /**< The length of the authentication |
| 329 | * function key in octets. */ |
| 330 | int auth_tag_len; /**< The length of the authentication |
| 331 | * tag in octets. */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 332 | srtp_sec_serv_t sec_serv; /**< The flag indicating the security |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 333 | * services to be applied. */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 334 | } srtp_crypto_policy_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 335 | |
| 336 | |
| 337 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 338 | * @brief srtp_ssrc_type_t describes the type of an SSRC. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 339 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 340 | * 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] | 341 | * @ref srtp_policy_t for more informataion. |
| 342 | */ |
| 343 | |
| 344 | typedef enum { |
| 345 | ssrc_undefined = 0, /**< Indicates an undefined SSRC type. */ |
| 346 | ssrc_specific = 1, /**< Indicates a specific SSRC value */ |
| 347 | ssrc_any_inbound = 2, /**< Indicates any inbound SSRC value |
| 348 | (i.e. a value that is used in the |
| 349 | function srtp_unprotect()) */ |
| 350 | ssrc_any_outbound = 3 /**< Indicates any outbound SSRC value |
| 351 | (i.e. a value that is used in the |
| 352 | function srtp_protect()) */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 353 | } srtp_ssrc_type_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 354 | |
| 355 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 356 | * @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] | 357 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 358 | * 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] | 359 | * ssrc_specific), or a wildcard SSRC value that will match all |
| 360 | * outbound SSRCs (if its type is ssrc_any_outbound) or all inbound |
| 361 | * SSRCs (if its type is ssrc_any_inbound). |
| 362 | * |
| 363 | */ |
| 364 | |
| 365 | typedef struct { |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 366 | srtp_ssrc_type_t type; /**< The type of this particular SSRC */ |
| 367 | unsigned int value; /**< The value of this SSRC, if it is not a wildcard */ |
| 368 | } srtp_ssrc_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 369 | |
| 370 | |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 371 | /** |
| 372 | * @brief points to an EKT policy |
| 373 | */ |
jfigus | c5887e7 | 2014-11-06 09:46:18 -0500 | [diff] [blame] | 374 | typedef struct srtp_ekt_policy_ctx_t *srtp_ekt_policy_t; |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 375 | |
| 376 | |
| 377 | /** |
| 378 | * @brief points to EKT stream data |
| 379 | */ |
jfigus | c5887e7 | 2014-11-06 09:46:18 -0500 | [diff] [blame] | 380 | typedef struct srtp_ekt_stream_ctx_t *srtp_ekt_stream_t; |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 381 | |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 382 | /** |
| 383 | * @brief srtp_master_key_t represents a master key. There will |
| 384 | * be a Master Key Index and the Master Key associated with the |
| 385 | * Master Key Index. Need to also keep track of the Master Key |
| 386 | * Index Size to correctly read it from a packet. |
| 387 | */ |
| 388 | typedef struct srtp_master_key_t { |
| 389 | unsigned char *key; |
| 390 | unsigned char *mki_id; |
| 391 | unsigned int mki_size; |
| 392 | } srtp_master_key_t; |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 393 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 394 | /** |
| 395 | * @brief represents the policy for an SRTP session. |
| 396 | * |
| 397 | * A single srtp_policy_t struct represents the policy for a single |
| 398 | * SRTP stream, and a linked list of these elements represents the |
| 399 | * policy for an entire SRTP session. Each element contains the SRTP |
| 400 | * and SRTCP crypto policies for that stream, a pointer to the SRTP |
| 401 | * master key for that stream, the SSRC describing that stream, or a |
| 402 | * flag indicating a `wildcard' SSRC value, and a `next' field that |
| 403 | * holds a pointer to the next element in the list of policy elements, |
| 404 | * or NULL if it is the last element. |
| 405 | * |
| 406 | * The wildcard value SSRC_ANY_INBOUND matches any SSRC from an |
| 407 | * inbound stream that for which there is no explicit SSRC entry in |
| 408 | * another policy element. Similarly, the value SSRC_ANY_OUTBOUND |
| 409 | * will matches any SSRC from an outbound stream that does not appear |
| 410 | * in another policy element. Note that wildcard SSRCs &b cannot be |
| 411 | * used to match both inbound and outbound traffic. This restriction |
| 412 | * is intentional, and it allows libSRTP to ensure that no security |
| 413 | * lapses result from accidental re-use of SSRC values during key |
| 414 | * sharing. |
| 415 | * |
| 416 | * |
| 417 | * @warning The final element of the list @b must have its `next' pointer |
| 418 | * set to NULL. |
| 419 | */ |
| 420 | |
| 421 | typedef struct srtp_policy_t { |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 422 | srtp_ssrc_t ssrc; /**< The SSRC value of stream, or the |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 423 | * flags SSRC_ANY_INBOUND or |
| 424 | * SSRC_ANY_OUTBOUND if key sharing |
| 425 | * is used for this policy element. |
| 426 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 427 | srtp_crypto_policy_t rtp; /**< SRTP crypto policy. */ |
| 428 | srtp_crypto_policy_t rtcp; /**< SRTCP crypto policy. */ |
Ryan Hooper | 89a288b | 2016-12-22 16:22:47 -0500 | [diff] [blame] | 429 | unsigned char *key; /**< Pointer to the SRTP master key for |
| 430 | * this stream. */ |
| 431 | srtp_master_key_t **keys; /** Array of Master Key structures */ |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 432 | unsigned long num_master_keys; /** Number of master keys */ |
jfigus | c5887e7 | 2014-11-06 09:46:18 -0500 | [diff] [blame] | 433 | srtp_ekt_policy_t ekt; /**< Pointer to the EKT policy structure |
David McGrew | 79870d6 | 2007-06-15 18:17:39 +0000 | [diff] [blame] | 434 | * for this stream (if any) */ |
Jonathan Lennox | a1242f8 | 2010-05-17 21:46:04 +0000 | [diff] [blame] | 435 | unsigned long window_size; /**< The window size to use for replay |
| 436 | * protection. */ |
Jonathan Lennox | dcee5c6 | 2010-05-17 22:08:40 +0000 | [diff] [blame] | 437 | int allow_repeat_tx; /**< Whether retransmissions of |
| 438 | * packets with the same sequence number |
| 439 | * are allowed. (Note that such repeated |
| 440 | * transmissions must have the same RTP |
| 441 | * payload, or a severe security weakness |
| 442 | * is introduced!) */ |
Joachim Bauch | 99a7482 | 2015-11-17 00:08:19 +0100 | [diff] [blame] | 443 | int *enc_xtn_hdr; /**< List of header ids to encrypt. */ |
| 444 | 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] | 445 | struct srtp_policy_t *next; /**< Pointer to next stream policy. */ |
| 446 | } srtp_policy_t; |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | /** |
| 452 | * @brief An srtp_t points to an SRTP session structure. |
| 453 | * |
| 454 | * The typedef srtp_t is a pointer to a structure that represents |
| 455 | * an SRTP session. This datatype is intentially opaque in |
| 456 | * order to separate the interface from the implementation. |
| 457 | * |
| 458 | * An SRTP session consists of all of the traffic sent to the RTP and |
| 459 | * RTCP destination transport addresses, using the RTP/SAVP (Secure |
| 460 | * Audio/Video Profile). A session can be viewed as a set of SRTP |
| 461 | * streams, each of which originates with a different participant. |
| 462 | */ |
| 463 | |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 464 | typedef srtp_ctx_t *srtp_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 465 | |
| 466 | |
| 467 | /** |
| 468 | * @brief An srtp_stream_t points to an SRTP stream structure. |
| 469 | * |
| 470 | * The typedef srtp_stream_t is a pointer to a structure that |
| 471 | * represents an SRTP stream. This datatype is intentionally |
| 472 | * opaque in order to separate the interface from the implementation. |
| 473 | * |
| 474 | * An SRTP stream consists of all of the traffic sent to an SRTP |
| 475 | * session by a single participant. A session can be viewed as |
| 476 | * a set of streams. |
| 477 | * |
| 478 | */ |
jfigus | a9ac898 | 2014-10-31 14:49:31 -0400 | [diff] [blame] | 479 | typedef srtp_stream_ctx_t *srtp_stream_t; |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 480 | |
| 481 | |
| 482 | |
| 483 | /** |
| 484 | * @brief srtp_init() initializes the srtp library. |
| 485 | * |
| 486 | * @warning This function @b must be called before any other srtp |
| 487 | * functions. |
| 488 | */ |
| 489 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 490 | srtp_err_status_t srtp_init(void); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 491 | |
| 492 | /** |
Jonathan Lennox | 5ae7633 | 2010-05-15 04:48:59 +0000 | [diff] [blame] | 493 | * @brief srtp_shutdown() de-initializes the srtp library. |
| 494 | * |
| 495 | * @warning No srtp functions may be called after calling this function. |
| 496 | */ |
| 497 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 498 | srtp_err_status_t srtp_shutdown(void); |
Jonathan Lennox | 5ae7633 | 2010-05-15 04:48:59 +0000 | [diff] [blame] | 499 | |
| 500 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 501 | * @brief srtp_protect() is the Secure RTP sender-side packet processing |
| 502 | * function. |
| 503 | * |
| 504 | * The function call srtp_protect(ctx, rtp_hdr, len_ptr) applies SRTP |
| 505 | * protection to the RTP packet rtp_hdr (which has length *len_ptr) using |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 506 | * 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] | 507 | * points to the resulting SRTP packet and *len_ptr is the number of |
| 508 | * octets in that packet; otherwise, no assumptions should be made |
| 509 | * about the value of either data elements. |
| 510 | * |
| 511 | * The sequence numbers of the RTP packets presented to this function |
| 512 | * need not be consecutive, but they @b must be out of order by less |
| 513 | * than 2^15 = 32,768 packets. |
| 514 | * |
| 515 | * @warning This function assumes that it can write the authentication |
| 516 | * tag into the location in memory immediately following the RTP |
| 517 | * packet, and assumes that the RTP packet is aligned on a 32-bit |
| 518 | * boundary. |
| 519 | * |
jfigus | dfe68ea | 2013-05-28 09:00:14 -0400 | [diff] [blame] | 520 | * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN |
| 521 | * into the location in memory immediately following the RTP packet. |
| 522 | * Callers MUST ensure that this much writable memory is available in |
| 523 | * the buffer that holds the RTP packet. |
jfigus | 5e33729 | 2013-05-28 13:57:47 -0400 | [diff] [blame] | 524 | * |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 525 | * @param ctx is the SRTP context to use in processing the packet. |
| 526 | * |
| 527 | * @param rtp_hdr is a pointer to the RTP packet (before the call); after |
| 528 | * the function returns, it points to the srtp packet. |
| 529 | * |
| 530 | * @param len_ptr is a pointer to the length in octets of the complete |
| 531 | * RTP packet (header and body) before the function call, and of the |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 532 | * 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] | 533 | * Otherwise, the value of the data to which it points is undefined. |
| 534 | * |
| 535 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 536 | * - srtp_err_status_ok no problems |
| 537 | * - srtp_err_status_replay_fail rtp sequence number was non-increasing |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 538 | * - @e other failure in cryptographic mechanisms |
| 539 | */ |
| 540 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 541 | 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] | 542 | |
| 543 | /** |
| 544 | * @brief srtp_protect_mki() is the Secure RTP sender-side packet processing |
| 545 | * function that can utilize MKI. |
| 546 | * |
| 547 | * The function call srtp_protect(ctx, rtp_hdr, len_ptr) applies SRTP |
| 548 | * protection to the RTP packet rtp_hdr (which has length *len_ptr) using |
| 549 | * the SRTP context ctx. If srtp_err_status_ok is returned, then rtp_hdr |
| 550 | * points to the resulting SRTP packet and *len_ptr is the number of |
| 551 | * octets in that packet; otherwise, no assumptions should be made |
| 552 | * about the value of either data elements. |
| 553 | * |
| 554 | * The sequence numbers of the RTP packets presented to this function |
| 555 | * need not be consecutive, but they @b must be out of order by less |
| 556 | * than 2^15 = 32,768 packets. |
| 557 | * |
| 558 | * @warning This function assumes that it can write the authentication |
| 559 | * tag into the location in memory immediately following the RTP |
| 560 | * packet, and assumes that the RTP packet is aligned on a 32-bit |
| 561 | * boundary. |
| 562 | * |
| 563 | * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN |
| 564 | * into the location in memory immediately following the RTP packet. |
| 565 | * Callers MUST ensure that this much writable memory is available in |
| 566 | * the buffer that holds the RTP packet. |
| 567 | * |
| 568 | * @param ctx is the SRTP context to use in processing the packet. |
| 569 | * |
| 570 | * @param rtp_hdr is a pointer to the RTP packet (before the call); after |
| 571 | * the function returns, it points to the srtp packet. |
| 572 | * |
| 573 | * @param len_ptr is a pointer to the length in octets of the complete |
| 574 | * RTP packet (header and body) before the function call, and of the |
| 575 | * complete SRTP packet after the call, if srtp_err_status_ok was returned. |
| 576 | * Otherwise, the value of the data to which it points is undefined. |
| 577 | * |
| 578 | * @param use_mki is a boolean to tell the system if mki is being used. If |
| 579 | * set to false then will use the first set of session keys. If set to true will |
| 580 | * use the session keys identified by the mki_index |
| 581 | * |
| 582 | * @param mki_index integer value specifying which set of session kesy should be |
| 583 | * used if use_mki is set to true. |
| 584 | * |
| 585 | * @return |
| 586 | * - srtp_err_status_ok no problems |
| 587 | * - srtp_err_status_replay_fail rtp sequence number was non-increasing |
| 588 | * - @e other failure in cryptographic mechanisms |
| 589 | */ |
| 590 | |
Geir Istad | 626e9e8 | 2017-02-20 18:15:05 +0100 | [diff] [blame^] | 591 | srtp_err_status_t srtp_protect_mki(srtp_ctx_t *ctx, void *rtp_hdr, |
| 592 | int *pkt_octet_len, unsigned int use_mki, |
| 593 | unsigned int mki_index); |
| 594 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 595 | /** |
| 596 | * @brief srtp_unprotect() is the Secure RTP receiver-side packet |
| 597 | * processing function. |
| 598 | * |
| 599 | * The function call srtp_unprotect(ctx, srtp_hdr, len_ptr) verifies |
| 600 | * the Secure RTP protection of the SRTP packet pointed to by srtp_hdr |
| 601 | * (which has length *len_ptr), using the SRTP context ctx. If |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 602 | * 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] | 603 | * RTP packet and *len_ptr is the number of octets in that packet; |
| 604 | * otherwise, no assumptions should be made about the value of either |
| 605 | * data elements. |
| 606 | * |
| 607 | * The sequence numbers of the RTP packets presented to this function |
| 608 | * need not be consecutive, but they @b must be out of order by less |
| 609 | * than 2^15 = 32,768 packets. |
| 610 | * |
| 611 | * @warning This function assumes that the SRTP packet is aligned on a |
| 612 | * 32-bit boundary. |
| 613 | * |
Iñaki Baz Castillo | 241fec3 | 2014-08-21 00:51:00 +0200 | [diff] [blame] | 614 | * @param ctx is the SRTP session which applies to the particular packet. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 615 | * |
| 616 | * @param srtp_hdr is a pointer to the header of the SRTP packet |
| 617 | * (before the call). after the function returns, it points to the |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 618 | * 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] | 619 | * the data to which it points is undefined. |
| 620 | * |
| 621 | * @param len_ptr is a pointer to the length in octets of the complete |
| 622 | * srtp packet (header and body) before the function call, and of the |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 623 | * 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] | 624 | * Otherwise, the value of the data to which it points is undefined. |
| 625 | * |
| 626 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 627 | * - srtp_err_status_ok if the RTP packet is valid. |
| 628 | * - srtp_err_status_auth_fail if the SRTP packet failed the message |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 629 | * authentication check. |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 630 | * - 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] | 631 | * already been processed and accepted). |
| 632 | * - [other] if there has been an error in the cryptographic mechanisms. |
| 633 | * |
| 634 | */ |
| 635 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 636 | 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] | 637 | |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 638 | /** |
| 639 | * @brief srtp_unprotect_mki() is the Secure RTP receiver-side packet |
| 640 | * processing function that checks for MKI. |
| 641 | * |
| 642 | * The function call srtp_unprotect(ctx, srtp_hdr, len_ptr) verifies |
| 643 | * the Secure RTP protection of the SRTP packet pointed to by srtp_hdr |
| 644 | * (which has length *len_ptr), using the SRTP context ctx. If |
| 645 | * srtp_err_status_ok is returned, then srtp_hdr points to the resulting |
| 646 | * RTP packet and *len_ptr is the number of octets in that packet; |
| 647 | * otherwise, no assumptions should be made about the value of either |
| 648 | * data elements. |
| 649 | * |
| 650 | * The sequence numbers of the RTP packets presented to this function |
| 651 | * need not be consecutive, but they @b must be out of order by less |
| 652 | * than 2^15 = 32,768 packets. |
| 653 | * |
| 654 | * @warning This function assumes that the SRTP packet is aligned on a |
| 655 | * 32-bit boundary. |
| 656 | * |
| 657 | * @param ctx is the SRTP session which applies to the particular packet. |
| 658 | * |
| 659 | * @param srtp_hdr is a pointer to the header of the SRTP packet |
| 660 | * (before the call). after the function returns, it points to the |
| 661 | * rtp packet if srtp_err_status_ok was returned; otherwise, the value of |
| 662 | * the data to which it points is undefined. |
| 663 | * |
| 664 | * @param len_ptr is a pointer to the length in octets of the complete |
| 665 | * srtp packet (header and body) before the function call, and of the |
| 666 | * complete rtp packet after the call, if srtp_err_status_ok was returned. |
| 667 | * Otherwise, the value of the data to which it points is undefined. |
| 668 | * |
| 669 | * @return |
| 670 | * - srtp_err_status_ok if the RTP packet is valid. |
| 671 | * - srtp_err_status_auth_fail if the SRTP packet failed the message |
| 672 | * authentication check. |
| 673 | * - srtp_err_status_replay_fail if the SRTP packet is a replay (e.g. packet has |
| 674 | * already been processed and accepted). |
| 675 | * - srtp_err_status_bad_mki if the MKI in the packet is not a known MKI id |
| 676 | * - [other] if there has been an error in the cryptographic mechanisms. |
| 677 | * |
| 678 | */ |
| 679 | |
Geir Istad | 626e9e8 | 2017-02-20 18:15:05 +0100 | [diff] [blame^] | 680 | srtp_err_status_t srtp_unprotect_mki(srtp_t ctx, void *srtp_hdr, int *len_ptr, |
| 681 | unsigned int use_mki); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 682 | |
| 683 | /** |
| 684 | * @brief srtp_create() allocates and initializes an SRTP session. |
| 685 | |
jfigus | 92c3de3 | 2016-02-02 13:44:39 -0500 | [diff] [blame] | 686 | * The function call srtp_create(session, policy) allocates and |
| 687 | * initializes an SRTP session context, applying the given policy. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 688 | * |
Iñaki Baz Castillo | 241fec3 | 2014-08-21 00:51:00 +0200 | [diff] [blame] | 689 | * @param session is a pointer to the SRTP session to which the policy is |
| 690 | * to be added. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 691 | * |
| 692 | * @param policy is the srtp_policy_t struct that describes the policy |
| 693 | * for the session. The struct may be a single element, or it may be |
| 694 | * 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] | 695 | * processed. It may also be NULL, in which case streams should be added |
| 696 | * later using srtp_add_stream(). The final element of the list @b must |
| 697 | * have its `next' field set to NULL. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 698 | * |
| 699 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 700 | * - srtp_err_status_ok if creation succeded. |
| 701 | * - srtp_err_status_alloc_fail if allocation failed. |
| 702 | * - srtp_err_status_init_fail if initialization failed. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 703 | */ |
| 704 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 705 | 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] | 706 | |
| 707 | |
| 708 | /** |
| 709 | * @brief srtp_add_stream() allocates and initializes an SRTP stream |
| 710 | * within a given SRTP session. |
| 711 | * |
| 712 | * The function call srtp_add_stream(session, policy) allocates and |
| 713 | * initializes a new SRTP stream within a given, previously created |
| 714 | * session, applying the policy given as the other argument to that |
| 715 | * stream. |
| 716 | * |
| 717 | * @return values: |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 718 | * - srtp_err_status_ok if stream creation succeded. |
| 719 | * - srtp_err_status_alloc_fail if stream allocation failed |
| 720 | * - srtp_err_status_init_fail if stream initialization failed. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 721 | */ |
| 722 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 723 | 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] | 724 | |
| 725 | |
| 726 | /** |
| 727 | * @brief srtp_remove_stream() deallocates an SRTP stream. |
| 728 | * |
| 729 | * The function call srtp_remove_stream(session, ssrc) removes |
| 730 | * the SRTP stream with the SSRC value ssrc from the SRTP session |
| 731 | * context given by the argument session. |
| 732 | * |
| 733 | * @param session is the SRTP session from which the stream |
| 734 | * will be removed. |
| 735 | * |
jfigus | 68f8a88 | 2016-02-03 12:48:23 -0500 | [diff] [blame] | 736 | * @param ssrc is the SSRC value of the stream to be removed |
| 737 | * in network byte order. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 738 | * |
| 739 | * @warning Wildcard SSRC values cannot be removed from a |
| 740 | * session. |
| 741 | * |
| 742 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 743 | * - srtp_err_status_ok if the stream deallocation succeded. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 744 | * - [other] otherwise. |
| 745 | * |
| 746 | */ |
| 747 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 748 | 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] | 749 | |
| 750 | /** |
Pascal Bühler | bd3112a | 2015-11-06 20:29:15 +0100 | [diff] [blame] | 751 | * @brief srtp_update() udpates all streams in the session. |
| 752 | * |
| 753 | * The function call srtp_update(session, policy) updates |
| 754 | * all the streams in the session applying the given policy |
| 755 | * and key. The exsisting ROC value of all streams will be |
| 756 | * preserved. |
| 757 | * |
| 758 | * @param session is the SRTP session that contains the streams |
| 759 | * to be updated. |
| 760 | * |
| 761 | * @param policy is the srtp_policy_t struct that describes the policy |
| 762 | * for the session. The struct may be a single element, or it may be |
| 763 | * the head of a list, in which case each element of the list is |
| 764 | * processed. The final element of the list @b must |
| 765 | * have its `next' field set to NULL. |
| 766 | * |
| 767 | * @return |
| 768 | * - srtp_err_status_ok if stream creation succeded. |
| 769 | * - srtp_err_status_alloc_fail if stream allocation failed |
| 770 | * - srtp_err_status_init_fail if stream initialization failed. |
| 771 | * - [other] otherwise. |
| 772 | * |
| 773 | */ |
| 774 | |
| 775 | srtp_err_status_t srtp_update(srtp_t session, const srtp_policy_t *policy); |
| 776 | |
| 777 | /** |
| 778 | * @brief srtp_update_stream() udpates a SRTP stream. |
| 779 | * |
| 780 | * The function call srtp_update_stream(session, policy) updates |
| 781 | * the stream(s) in the session that match applying the given |
| 782 | * policy and key. The exsisting ROC value of all stream(s) will |
| 783 | * be preserved. |
| 784 | * |
| 785 | * @param session is the SRTP session that contains the streams |
| 786 | * to be updated. |
| 787 | * |
| 788 | * @param policy is the srtp_policy_t struct that describes the policy |
| 789 | * for the session. |
| 790 | * |
| 791 | * @return |
| 792 | * - srtp_err_status_ok if stream creation succeded. |
| 793 | * - srtp_err_status_alloc_fail if stream allocation failed |
| 794 | * - srtp_err_status_init_fail if stream initialization failed. |
| 795 | * - [other] otherwise. |
| 796 | * |
| 797 | */ |
| 798 | |
| 799 | srtp_err_status_t srtp_update_stream(srtp_t session, const srtp_policy_t *policy); |
| 800 | |
| 801 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 802 | * @brief srtp_crypto_policy_set_rtp_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 RTP 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 | * |
| 807 | * The function call crypto_policy_set_rtp_default(&p) sets the |
| 808 | * crypto_policy_t at location p to the SRTP default policy for RTP |
| 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 |
| 814 | * elements in the crypto_policy_t datatype. |
| 815 | * |
| 816 | * @return void. |
| 817 | * |
| 818 | */ |
| 819 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 820 | void srtp_crypto_policy_set_rtp_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_rtcp_default() sets a crypto policy |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 824 | * structure to the SRTP default policy for RTCP 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 |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 827 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 828 | * The function call srtp_crypto_policy_set_rtcp_default(&p) sets the |
| 829 | * 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] | 830 | * protection, as defined in the specification. This function is a |
| 831 | * convenience that helps to avoid dealing directly with the policy |
| 832 | * data structure. You are encouraged to initialize policy elements |
| 833 | * with this function call. Doing so may allow your code to be |
| 834 | * forward compatible with later versions of libSRTP that include more |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 835 | * elements in the srtp_crypto_policy_t datatype. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 836 | * |
| 837 | * @return void. |
| 838 | * |
| 839 | */ |
| 840 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 841 | void srtp_crypto_policy_set_rtcp_default(srtp_crypto_policy_t *p); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 842 | |
| 843 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 844 | * @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] | 845 | * policy structure to the SRTP default policy for RTP protection. |
| 846 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 847 | * @param p is a pointer to the policy structure to be set |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 848 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 849 | * The function srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80() is a |
| 850 | * synonym for srtp_crypto_policy_set_rtp_default(). It conforms to the |
Jonathan Lennox | d8d5cd0 | 2010-05-17 20:08:17 +0000 | [diff] [blame] | 851 | * naming convention used in RFC 4568 (SDP Security Descriptions for |
| 852 | * Media Streams). |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 853 | * |
| 854 | * @return void. |
| 855 | * |
| 856 | */ |
| 857 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 858 | #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] | 859 | |
| 860 | |
| 861 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 862 | * @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] | 863 | * policy structure to a short-authentication tag policy |
| 864 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 865 | * @param p is a pointer to the policy structure to be set |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 866 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 867 | * The function call srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32(&p) |
| 868 | * sets the srtp_crypto_policy_t at location p to use policy |
Jonathan Lennox | d8d5cd0 | 2010-05-17 20:08:17 +0000 | [diff] [blame] | 869 | * AES_CM_128_HMAC_SHA1_32 as defined in RFC 4568. |
| 870 | * This policy uses AES-128 |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 871 | * Counter Mode encryption and HMAC-SHA1 authentication, with an |
| 872 | * authentication tag that is only 32 bits long. This length is |
| 873 | * considered adequate only for protecting audio and video media that |
| 874 | * use a stateless playback function. See Section 7.5 of RFC 3711 |
| 875 | * (http://www.ietf.org/rfc/rfc3711.txt). |
| 876 | * |
| 877 | * This function is a convenience that helps to avoid dealing directly |
| 878 | * with the policy data structure. You are encouraged to initialize |
| 879 | * policy elements with this function call. Doing so may allow your |
| 880 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 881 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 882 | * |
| 883 | * @warning This crypto policy is intended for use in SRTP, but not in |
| 884 | * SRTCP. It is recommended that a policy that uses longer |
| 885 | * authentication tags be used for SRTCP. See Section 7.5 of RFC 3711 |
| 886 | * (http://www.ietf.org/rfc/rfc3711.txt). |
| 887 | * |
| 888 | * @return void. |
| 889 | * |
| 890 | */ |
| 891 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 892 | 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] | 893 | |
| 894 | |
| 895 | |
| 896 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 897 | * @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] | 898 | * policy structure to an encryption-only policy |
| 899 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 900 | * @param p is a pointer to the policy structure to be set |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 901 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 902 | * The function call srtp_crypto_policy_set_aes_cm_128_null_auth(&p) sets |
| 903 | * 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] | 904 | * (AES-128 Counter Mode), but to use no authentication method. This |
| 905 | * policy is NOT RECOMMENDED unless it is unavoidable; see Section 7.5 |
| 906 | * of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). |
| 907 | * |
| 908 | * This function is a convenience that helps to avoid dealing directly |
| 909 | * with the policy data structure. You are encouraged to initialize |
| 910 | * policy elements with this function call. Doing so may allow your |
| 911 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 912 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 913 | * |
| 914 | * @warning This policy is NOT RECOMMENDED for SRTP unless it is |
| 915 | * unavoidable, and it is NOT RECOMMENDED at all for SRTCP; see |
| 916 | * Section 7.5 of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). |
| 917 | * |
| 918 | * @return void. |
| 919 | * |
| 920 | */ |
| 921 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 922 | 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] | 923 | |
| 924 | |
| 925 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 926 | * @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] | 927 | * policy structure to an authentication-only policy |
| 928 | * |
David McGrew | c4fc00b | 2006-06-08 18:51:27 +0000 | [diff] [blame] | 929 | * @param p is a pointer to the policy structure to be set |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 930 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 931 | * The function call srtp_crypto_policy_set_null_cipher_hmac_sha1_80(&p) |
| 932 | * 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] | 933 | * bit authentication tag to provide message authentication, but to |
| 934 | * use no encryption. This policy is NOT RECOMMENDED for SRTP unless |
| 935 | * there is a requirement to forego encryption. |
| 936 | * |
| 937 | * This function is a convenience that helps to avoid dealing directly |
| 938 | * with the policy data structure. You are encouraged to initialize |
| 939 | * policy elements with this function call. Doing so may allow your |
| 940 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 941 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 942 | * |
| 943 | * @warning This policy is NOT RECOMMENDED for SRTP unless there is a |
| 944 | * requirement to forego encryption. |
| 945 | * |
| 946 | * @return void. |
| 947 | * |
| 948 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 949 | 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] | 950 | |
jfigus | 267956d | 2014-11-06 10:49:21 -0500 | [diff] [blame] | 951 | /** |
| 952 | * @brief srtp_crypto_policy_set_null_cipher_hmac_null() sets a crypto |
| 953 | * policy structure to use no encryption or authentication. |
| 954 | * |
| 955 | * @param p is a pointer to the policy structure to be set |
| 956 | * |
| 957 | * The function call srtp_crypto_policy_set_null_cipher_hmac_null(&p) |
| 958 | * sets the srtp_crypto_policy_t at location p to use no encryption and |
| 959 | * no authentication. This policy should only be used for testing and |
| 960 | * troubleshootingl. |
| 961 | * |
| 962 | * This function is a convenience that helps to avoid dealing directly |
| 963 | * with the policy data structure. You are encouraged to initialize |
| 964 | * policy elements with this function call. Doing so may allow your |
| 965 | * code to be forward compatible with later versions of libSRTP that |
| 966 | * include more elements in the srtp_crypto_policy_t datatype. |
| 967 | * |
| 968 | * @warning This policy is NOT RECOMMENDED for SRTP unless there is a |
| 969 | * requirement to forego encryption and authentication. |
| 970 | * |
| 971 | * @return void. |
| 972 | * |
| 973 | */ |
| 974 | void srtp_crypto_policy_set_null_cipher_hmac_null(srtp_crypto_policy_t *p); |
| 975 | |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 976 | |
| 977 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 978 | * @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] | 979 | * policy structure to a encryption and authentication policy using AES-256 |
| 980 | * for RTP protection. |
| 981 | * |
| 982 | * @param p is a pointer to the policy structure to be set |
| 983 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 984 | * The function call srtp_crypto_policy_set_aes_cm_256_hmac_sha1_80(&p) |
| 985 | * sets the srtp_crypto_policy_t at location p to use policy |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 986 | * AES_CM_256_HMAC_SHA1_80 as defined in |
| 987 | * draft-ietf-avt-srtp-big-aes-03.txt. This policy uses AES-256 |
| 988 | * Counter Mode encryption and HMAC-SHA1 authentication, with an 80 bit |
| 989 | * authentication tag. |
| 990 | * |
| 991 | * This function is a convenience that helps to avoid dealing directly |
| 992 | * with the policy data structure. You are encouraged to initialize |
| 993 | * policy elements with this function call. Doing so may allow your |
| 994 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 995 | * include more elements in the srtp_crypto_policy_t datatype. |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 996 | * |
| 997 | * @return void. |
| 998 | * |
| 999 | */ |
| 1000 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1001 | 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] | 1002 | |
| 1003 | |
| 1004 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1005 | * @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] | 1006 | * policy structure to a short-authentication tag policy using AES-256 |
| 1007 | * encryption. |
| 1008 | * |
| 1009 | * @param p is a pointer to the policy structure to be set |
| 1010 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1011 | * The function call srtp_crypto_policy_set_aes_cm_256_hmac_sha1_32(&p) |
| 1012 | * sets the srtp_crypto_policy_t at location p to use policy |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 1013 | * AES_CM_256_HMAC_SHA1_32 as defined in |
| 1014 | * draft-ietf-avt-srtp-big-aes-03.txt. This policy uses AES-256 |
| 1015 | * Counter Mode encryption and HMAC-SHA1 authentication, with an |
| 1016 | * authentication tag that is only 32 bits long. This length is |
| 1017 | * considered adequate only for protecting audio and video media that |
| 1018 | * use a stateless playback function. See Section 7.5 of RFC 3711 |
| 1019 | * (http://www.ietf.org/rfc/rfc3711.txt). |
| 1020 | * |
| 1021 | * This function is a convenience that helps to avoid dealing directly |
| 1022 | * with the policy data structure. You are encouraged to initialize |
| 1023 | * policy elements with this function call. Doing so may allow your |
| 1024 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1025 | * include more elements in the srtp_crypto_policy_t datatype. |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 1026 | * |
| 1027 | * @warning This crypto policy is intended for use in SRTP, but not in |
| 1028 | * SRTCP. It is recommended that a policy that uses longer |
| 1029 | * authentication tags be used for SRTCP. See Section 7.5 of RFC 3711 |
| 1030 | * (http://www.ietf.org/rfc/rfc3711.txt). |
| 1031 | * |
| 1032 | * @return void. |
| 1033 | * |
| 1034 | */ |
| 1035 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1036 | 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] | 1037 | |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1038 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1039 | * @brief srtp_crypto_policy_set_aes_cm_256_null_auth() sets a crypto |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1040 | * policy structure to an encryption-only policy |
| 1041 | * |
| 1042 | * @param p is a pointer to the policy structure to be set |
| 1043 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1044 | * The function call srtp_crypto_policy_set_aes_cm_256_null_auth(&p) sets |
| 1045 | * 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] | 1046 | * (AES-256 Counter Mode), but to use no authentication method. This |
| 1047 | * policy is NOT RECOMMENDED unless it is unavoidable; see Section 7.5 |
| 1048 | * of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). |
| 1049 | * |
| 1050 | * This function is a convenience that helps to avoid dealing directly |
| 1051 | * with the policy data structure. You are encouraged to initialize |
| 1052 | * policy elements with this function call. Doing so may allow your |
| 1053 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1054 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1055 | * |
| 1056 | * @warning This policy is NOT RECOMMENDED for SRTP unless it is |
| 1057 | * unavoidable, and it is NOT RECOMMENDED at all for SRTCP; see |
| 1058 | * Section 7.5 of RFC 3711 (http://www.ietf.org/rfc/rfc3711.txt). |
| 1059 | * |
| 1060 | * @return void. |
| 1061 | * |
| 1062 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1063 | 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] | 1064 | |
| 1065 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1066 | * @brief srtp_crypto_policy_set_aes_gcm_128_8_auth() sets a crypto |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1067 | * policy structure to an AEAD encryption policy. |
| 1068 | * |
| 1069 | * @param p is a pointer to the policy structure to be set |
| 1070 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1071 | * The function call srtp_crypto_policy_set_aes_gcm_128_8_auth(&p) sets |
| 1072 | * 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] | 1073 | * (AES-128 Galois Counter Mode) with 8 octet auth tag. This |
| 1074 | * policy applies confidentiality and authentication to both the |
| 1075 | * RTP and RTCP packets. |
| 1076 | * |
| 1077 | * This function is a convenience that helps to avoid dealing directly |
| 1078 | * with the policy data structure. You are encouraged to initialize |
| 1079 | * policy elements with this function call. Doing so may allow your |
| 1080 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1081 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1082 | * |
| 1083 | * @return void. |
| 1084 | * |
| 1085 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1086 | 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] | 1087 | |
| 1088 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1089 | * @brief srtp_crypto_policy_set_aes_gcm_256_8_auth() sets a crypto |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1090 | * policy structure to an AEAD encryption policy |
| 1091 | * |
| 1092 | * @param p is a pointer to the policy structure to be set |
| 1093 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1094 | * The function call srtp_crypto_policy_set_aes_gcm_256_8_auth(&p) sets |
| 1095 | * 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] | 1096 | * (AES-256 Galois Counter Mode) with 8 octet auth tag. This |
| 1097 | * policy applies confidentiality and authentication to both the |
| 1098 | * RTP and RTCP packets. |
| 1099 | * |
| 1100 | * This function is a convenience that helps to avoid dealing directly |
| 1101 | * with the policy data structure. You are encouraged to initialize |
| 1102 | * policy elements with this function call. Doing so may allow your |
| 1103 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1104 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1105 | * |
| 1106 | * @return void. |
| 1107 | * |
| 1108 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1109 | 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] | 1110 | |
| 1111 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1112 | * @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] | 1113 | * policy structure to an AEAD authentication-only policy |
| 1114 | * |
| 1115 | * @param p is a pointer to the policy structure to be set |
| 1116 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1117 | * The function call srtp_crypto_policy_set_aes_gcm_128_8_only_auth(&p) sets |
| 1118 | * 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] | 1119 | * (AES-128 Galois Counter Mode) with 8 octet auth tag. This policy |
| 1120 | * applies confidentiality and authentication to the RTP packets, |
| 1121 | * but only authentication to the RTCP packets. |
| 1122 | * |
| 1123 | * This function is a convenience that helps to avoid dealing directly |
| 1124 | * with the policy data structure. You are encouraged to initialize |
| 1125 | * policy elements with this function call. Doing so may allow your |
| 1126 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1127 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1128 | * |
| 1129 | * @return void. |
| 1130 | * |
| 1131 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1132 | 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] | 1133 | |
| 1134 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1135 | * @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] | 1136 | * policy structure to an AEAD authentication-only policy |
| 1137 | * |
| 1138 | * @param p is a pointer to the policy structure to be set |
| 1139 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1140 | * The function call srtp_crypto_policy_set_aes_gcm_256_8_only_auth(&p) sets |
| 1141 | * 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] | 1142 | * (AES-256 Galois Counter Mode) with 8 octet auth tag. This policy |
| 1143 | * applies confidentiality and authentication to the RTP packets, |
| 1144 | * but only authentication to the RTCP packets. |
| 1145 | * |
| 1146 | * This function is a convenience that helps to avoid dealing directly |
| 1147 | * with the policy data structure. You are encouraged to initialize |
| 1148 | * policy elements with this function call. Doing so may allow your |
| 1149 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1150 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | 8c36da2 | 2013-10-01 16:41:19 -0400 | [diff] [blame] | 1151 | * |
| 1152 | * @return void. |
| 1153 | * |
| 1154 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1155 | 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] | 1156 | |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1157 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1158 | * @brief srtp_crypto_policy_set_aes_gcm_128_16_auth() sets a crypto |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1159 | * policy structure to an AEAD encryption policy. |
| 1160 | * |
| 1161 | * @param p is a pointer to the policy structure to be set |
| 1162 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1163 | * The function call srtp_crypto_policy_set_aes_gcm_128_16_auth(&p) sets |
| 1164 | * 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] | 1165 | * (AES-128 Galois Counter Mode) with 16 octet auth tag. This |
| 1166 | * policy applies confidentiality and authentication to both the |
| 1167 | * RTP and RTCP packets. |
| 1168 | * |
| 1169 | * This function is a convenience that helps to avoid dealing directly |
| 1170 | * with the policy data structure. You are encouraged to initialize |
| 1171 | * policy elements with this function call. Doing so may allow your |
| 1172 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1173 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1174 | * |
| 1175 | * @return void. |
| 1176 | * |
| 1177 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1178 | 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] | 1179 | |
| 1180 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1181 | * @brief srtp_crypto_policy_set_aes_gcm_256_16_auth() sets a crypto |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1182 | * policy structure to an AEAD encryption policy |
| 1183 | * |
| 1184 | * @param p is a pointer to the policy structure to be set |
| 1185 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1186 | * The function call srtp_crypto_policy_set_aes_gcm_256_16_auth(&p) sets |
| 1187 | * 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] | 1188 | * (AES-256 Galois Counter Mode) with 16 octet auth tag. This |
| 1189 | * policy applies confidentiality and authentication to both the |
| 1190 | * RTP and RTCP packets. |
| 1191 | * |
| 1192 | * This function is a convenience that helps to avoid dealing directly |
| 1193 | * with the policy data structure. You are encouraged to initialize |
| 1194 | * policy elements with this function call. Doing so may allow your |
| 1195 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1196 | * include more elements in the srtp_crypto_policy_t datatype. |
jfigus | c13c100 | 2014-05-08 13:34:53 -0400 | [diff] [blame] | 1197 | * |
| 1198 | * @return void. |
| 1199 | * |
| 1200 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1201 | 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] | 1202 | |
Jonathan Lennox | 5df951a | 2010-05-20 20:55:54 +0000 | [diff] [blame] | 1203 | |
David McGrew | a854688 | 2006-01-12 17:56:02 +0000 | [diff] [blame] | 1204 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1205 | * @brief srtp_dealloc() deallocates storage for an SRTP session |
| 1206 | * context. |
| 1207 | * |
| 1208 | * The function call srtp_dealloc(s) deallocates storage for the |
| 1209 | * SRTP session context s. This function should be called no more |
| 1210 | * than one time for each of the contexts allocated by the function |
| 1211 | * srtp_create(). |
| 1212 | * |
| 1213 | * @param s is the srtp_t for the session to be deallocated. |
| 1214 | * |
| 1215 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1216 | * - srtp_err_status_ok if there no problems. |
| 1217 | * - srtp_err_status_dealloc_fail a memory deallocation failure occured. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1218 | */ |
| 1219 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1220 | srtp_err_status_t srtp_dealloc(srtp_t s); |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1221 | |
| 1222 | |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1223 | /* |
| 1224 | * @brief identifies a particular SRTP profile |
| 1225 | * |
| 1226 | * An srtp_profile_t enumeration is used to identify a particular SRTP |
| 1227 | * profile (that is, a set of algorithms and parameters). These |
| 1228 | * profiles are defined in the DTLS-SRTP draft. |
| 1229 | */ |
| 1230 | |
| 1231 | typedef enum { |
| 1232 | srtp_profile_reserved = 0, |
| 1233 | srtp_profile_aes128_cm_sha1_80 = 1, |
| 1234 | srtp_profile_aes128_cm_sha1_32 = 2, |
| 1235 | srtp_profile_aes256_cm_sha1_80 = 3, |
| 1236 | srtp_profile_aes256_cm_sha1_32 = 4, |
| 1237 | srtp_profile_null_sha1_80 = 5, |
| 1238 | srtp_profile_null_sha1_32 = 6, |
| 1239 | } srtp_profile_t; |
| 1240 | |
| 1241 | |
| 1242 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1243 | * @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] | 1244 | * structure to the appropriate value for RTP based on an srtp_profile_t |
| 1245 | * |
| 1246 | * @param p is a pointer to the policy structure to be set |
| 1247 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1248 | * The function call srtp_crypto_policy_set_rtp_default(&policy, profile) |
| 1249 | * 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] | 1250 | * protection, as defined by the srtp_profile_t profile. |
| 1251 | * |
| 1252 | * This function is a convenience that helps to avoid dealing directly |
| 1253 | * with the policy data structure. You are encouraged to initialize |
| 1254 | * policy elements with this function call. Doing so may allow your |
| 1255 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1256 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1257 | * |
| 1258 | * @return values |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1259 | * - srtp_err_status_ok no problems were encountered |
| 1260 | * - srtp_err_status_bad_param the profile is not supported |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1261 | * |
| 1262 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1263 | 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] | 1264 | |
| 1265 | |
| 1266 | |
| 1267 | |
| 1268 | /** |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1269 | * @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] | 1270 | * structure to the appropriate value for RTCP based on an srtp_profile_t |
| 1271 | * |
| 1272 | * @param p is a pointer to the policy structure to be set |
| 1273 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1274 | * The function call srtp_crypto_policy_set_rtcp_default(&policy, profile) |
| 1275 | * 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] | 1276 | * protection, as defined by the srtp_profile_t profile. |
| 1277 | * |
| 1278 | * This function is a convenience that helps to avoid dealing directly |
| 1279 | * with the policy data structure. You are encouraged to initialize |
| 1280 | * policy elements with this function call. Doing so may allow your |
| 1281 | * code to be forward compatible with later versions of libSRTP that |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1282 | * include more elements in the srtp_crypto_policy_t datatype. |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1283 | * |
| 1284 | * @return values |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1285 | * - srtp_err_status_ok no problems were encountered |
| 1286 | * - srtp_err_status_bad_param the profile is not supported |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1287 | * |
| 1288 | */ |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1289 | 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] | 1290 | |
| 1291 | /** |
| 1292 | * @brief returns the master key length for a given SRTP profile |
| 1293 | */ |
| 1294 | unsigned int |
| 1295 | srtp_profile_get_master_key_length(srtp_profile_t profile); |
| 1296 | |
| 1297 | |
| 1298 | /** |
| 1299 | * @brief returns the master salt length for a given SRTP profile |
| 1300 | */ |
| 1301 | unsigned int |
| 1302 | srtp_profile_get_master_salt_length(srtp_profile_t profile); |
| 1303 | |
| 1304 | /** |
| 1305 | * @brief appends the salt to the key |
| 1306 | * |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1307 | * The function call srtp_append_salt_to_key(k, klen, s, slen) |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1308 | * copies the string s to the location at klen bytes following |
| 1309 | * the location k. |
| 1310 | * |
| 1311 | * @warning There must be at least bytes_in_salt + bytes_in_key bytes |
| 1312 | * available at the location pointed to by key. |
| 1313 | * |
| 1314 | */ |
| 1315 | |
| 1316 | void |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1317 | srtp_append_salt_to_key(unsigned char *key, unsigned int bytes_in_key, |
| 1318 | unsigned char *salt, unsigned int bytes_in_salt); |
David McGrew | 0cb86ee | 2006-07-07 15:46:57 +0000 | [diff] [blame] | 1319 | |
| 1320 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1321 | |
| 1322 | /** |
| 1323 | * @} |
| 1324 | */ |
| 1325 | |
| 1326 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1327 | |
| 1328 | /** |
| 1329 | * @defgroup SRTCP Secure RTCP |
| 1330 | * @ingroup SRTP |
| 1331 | * |
| 1332 | * @brief Secure RTCP functions are used to protect RTCP traffic. |
| 1333 | * |
| 1334 | * RTCP is the control protocol for RTP. libSRTP protects RTCP |
| 1335 | * traffic in much the same way as it does RTP traffic. The function |
| 1336 | * srtp_protect_rtcp() applies cryptographic protections to outbound |
| 1337 | * RTCP packets, and srtp_unprotect_rtcp() verifies the protections on |
| 1338 | * inbound RTCP packets. |
| 1339 | * |
| 1340 | * A note on the naming convention: srtp_protect_rtcp() has an srtp_t |
| 1341 | * as its first argument, and thus has `srtp_' as its prefix. The |
| 1342 | * trailing `_rtcp' indicates the protocol on which it acts. |
| 1343 | * |
| 1344 | * @{ |
| 1345 | */ |
| 1346 | |
| 1347 | /** |
| 1348 | * @brief srtp_protect_rtcp() is the Secure RTCP sender-side packet |
| 1349 | * processing function. |
| 1350 | * |
| 1351 | * The function call srtp_protect_rtcp(ctx, rtp_hdr, len_ptr) applies |
| 1352 | * SRTCP protection to the RTCP packet rtcp_hdr (which has length |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1353 | * *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] | 1354 | * returned, then rtp_hdr points to the resulting SRTCP packet and |
| 1355 | * *len_ptr is the number of octets in that packet; otherwise, no |
| 1356 | * assumptions should be made about the value of either data elements. |
| 1357 | * |
| 1358 | * @warning This function assumes that it can write the authentication |
| 1359 | * tag into the location in memory immediately following the RTCP |
| 1360 | * packet, and assumes that the RTCP packet is aligned on a 32-bit |
| 1361 | * boundary. |
| 1362 | * |
jfigus | 5e33729 | 2013-05-28 13:57:47 -0400 | [diff] [blame] | 1363 | * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN+4 |
| 1364 | * into the location in memory immediately following the RTCP packet. |
| 1365 | * Callers MUST ensure that this much writable memory is available in |
| 1366 | * the buffer that holds the RTCP packet. |
| 1367 | * |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1368 | * @param ctx is the SRTP context to use in processing the packet. |
| 1369 | * |
| 1370 | * @param rtcp_hdr is a pointer to the RTCP packet (before the call); after |
| 1371 | * the function returns, it points to the srtp packet. |
| 1372 | * |
| 1373 | * @param pkt_octet_len is a pointer to the length in octets of the |
| 1374 | * complete RTCP packet (header and body) before the function call, |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1375 | * 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] | 1376 | * was returned. Otherwise, the value of the data to which it points |
| 1377 | * is undefined. |
| 1378 | * |
| 1379 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1380 | * - srtp_err_status_ok if there were no problems. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1381 | * - [other] if there was a failure in |
| 1382 | * the cryptographic mechanisms. |
| 1383 | */ |
| 1384 | |
| 1385 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1386 | 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] | 1387 | |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1388 | |
| 1389 | /** |
| 1390 | * @brief srtp_protect_rtcp_mki() is the Secure RTCP sender-side packet |
| 1391 | * processing function that can utilize mki. |
| 1392 | * |
| 1393 | * The function call srtp_protect_rtcp(ctx, rtp_hdr, len_ptr) applies |
| 1394 | * SRTCP protection to the RTCP packet rtcp_hdr (which has length |
| 1395 | * *len_ptr) using the SRTP session context ctx. If srtp_err_status_ok is |
| 1396 | * returned, then rtp_hdr points to the resulting SRTCP packet and |
| 1397 | * *len_ptr is the number of octets in that packet; otherwise, no |
| 1398 | * assumptions should be made about the value of either data elements. |
| 1399 | * |
| 1400 | * @warning This function assumes that it can write the authentication |
| 1401 | * tag into the location in memory immediately following the RTCP |
| 1402 | * packet, and assumes that the RTCP packet is aligned on a 32-bit |
| 1403 | * boundary. |
| 1404 | * |
| 1405 | * @warning This function assumes that it can write SRTP_MAX_TRAILER_LEN+4 |
| 1406 | * into the location in memory immediately following the RTCP packet. |
| 1407 | * Callers MUST ensure that this much writable memory is available in |
| 1408 | * the buffer that holds the RTCP packet. |
| 1409 | * |
| 1410 | * @param ctx is the SRTP context to use in processing the packet. |
| 1411 | * |
| 1412 | * @param rtcp_hdr is a pointer to the RTCP packet (before the call); after |
| 1413 | * the function returns, it points to the srtp packet. |
| 1414 | * |
| 1415 | * @param pkt_octet_len is a pointer to the length in octets of the |
| 1416 | * complete RTCP packet (header and body) before the function call, |
| 1417 | * and of the complete SRTCP packet after the call, if srtp_err_status_ok |
| 1418 | * was returned. Otherwise, the value of the data to which it points |
| 1419 | * is undefined. |
| 1420 | * |
| 1421 | * @param use_mki is a boolean to tell the system if mki is being used. If |
| 1422 | * set to false then will use the first set of session keys. If set to true will |
| 1423 | * use the session keys identified by the mki_index |
| 1424 | * |
| 1425 | * @param mki_index integer value specifying which set of session kesy should be |
| 1426 | * used if use_mki is set to true. |
| 1427 | * |
| 1428 | * @return |
| 1429 | * - srtp_err_status_ok if there were no problems. |
| 1430 | * - [other] if there was a failure in |
| 1431 | * the cryptographic mechanisms. |
| 1432 | */ |
| 1433 | |
| 1434 | srtp_err_status_t srtp_protect_rtcp_mki(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len, |
| 1435 | unsigned int use_mki, unsigned int mki_index); |
| 1436 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1437 | /** |
| 1438 | * @brief srtp_unprotect_rtcp() is the Secure RTCP receiver-side packet |
| 1439 | * processing function. |
| 1440 | * |
| 1441 | * The function call srtp_unprotect_rtcp(ctx, srtp_hdr, len_ptr) |
| 1442 | * verifies the Secure RTCP protection of the SRTCP packet pointed to |
| 1443 | * by srtcp_hdr (which has length *len_ptr), using the SRTP session |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1444 | * 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] | 1445 | * to the resulting RTCP packet and *len_ptr is the number of octets |
| 1446 | * in that packet; otherwise, no assumptions should be made about the |
| 1447 | * value of either data elements. |
| 1448 | * |
| 1449 | * @warning This function assumes that the SRTCP packet is aligned on a |
| 1450 | * 32-bit boundary. |
| 1451 | * |
| 1452 | * @param ctx is a pointer to the srtp_t which applies to the |
| 1453 | * particular packet. |
| 1454 | * |
| 1455 | * @param srtcp_hdr is a pointer to the header of the SRTCP packet |
| 1456 | * (before the call). After the function returns, it points to the |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1457 | * 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] | 1458 | * the data to which it points is undefined. |
| 1459 | * |
| 1460 | * @param pkt_octet_len is a pointer to the length in octets of the |
| 1461 | * complete SRTCP packet (header and body) before the function call, |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1462 | * 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] | 1463 | * returned. Otherwise, the value of the data to which it points is |
| 1464 | * undefined. |
| 1465 | * |
| 1466 | * @return |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1467 | * - srtp_err_status_ok if the RTCP packet is valid. |
| 1468 | * - srtp_err_status_auth_fail if the SRTCP packet failed the message |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1469 | * authentication check. |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1470 | * - 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] | 1471 | * already been processed and accepted). |
| 1472 | * - [other] if there has been an error in the cryptographic mechanisms. |
| 1473 | * |
| 1474 | */ |
| 1475 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1476 | 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] | 1477 | |
| 1478 | /** |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1479 | * @brief srtp_unprotect_rtcp() is the Secure RTCP receiver-side packet |
| 1480 | * processing function. |
| 1481 | * |
| 1482 | * The function call srtp_unprotect_rtcp(ctx, srtp_hdr, len_ptr) |
| 1483 | * verifies the Secure RTCP protection of the SRTCP packet pointed to |
| 1484 | * by srtcp_hdr (which has length *len_ptr), using the SRTP session |
| 1485 | * context ctx. If srtp_err_status_ok is returned, then srtcp_hdr points |
| 1486 | * to the resulting RTCP packet and *len_ptr is the number of octets |
| 1487 | * in that packet; otherwise, no assumptions should be made about the |
| 1488 | * value of either data elements. |
| 1489 | * |
| 1490 | * @warning This function assumes that the SRTCP packet is aligned on a |
| 1491 | * 32-bit boundary. |
| 1492 | * |
| 1493 | * @param ctx is a pointer to the srtp_t which applies to the |
| 1494 | * particular packet. |
| 1495 | * |
| 1496 | * @param srtcp_hdr is a pointer to the header of the SRTCP packet |
| 1497 | * (before the call). After the function returns, it points to the |
| 1498 | * rtp packet if srtp_err_status_ok was returned; otherwise, the value of |
| 1499 | * the data to which it points is undefined. |
| 1500 | * |
| 1501 | * @param pkt_octet_len is a pointer to the length in octets of the |
| 1502 | * complete SRTCP packet (header and body) before the function call, |
| 1503 | * and of the complete rtp packet after the call, if srtp_err_status_ok was |
| 1504 | * returned. Otherwise, the value of the data to which it points is |
| 1505 | * undefined. |
| 1506 | * |
| 1507 | * @return |
| 1508 | * - srtp_err_status_ok if the RTCP packet is valid. |
| 1509 | * - srtp_err_status_auth_fail if the SRTCP packet failed the message |
| 1510 | * authentication check. |
| 1511 | * - srtp_err_status_replay_fail if the SRTCP packet is a replay (e.g. has |
| 1512 | * already been processed and accepted). |
| 1513 | * - srtp_err_status_bad_mki if the MKI in the packet is not a known MKI id |
| 1514 | * - [other] if there has been an error in the cryptographic mechanisms. |
| 1515 | * |
| 1516 | */ |
| 1517 | |
Geir Istad | 626e9e8 | 2017-02-20 18:15:05 +0100 | [diff] [blame^] | 1518 | srtp_err_status_t srtp_unprotect_rtcp_mki(srtp_t ctx, void *srtcp_hdr, |
| 1519 | int *pkt_octet_len, |
| 1520 | unsigned int use_mki); |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1521 | |
| 1522 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1523 | * @} |
| 1524 | */ |
| 1525 | |
Iñaki Baz Castillo | 241fec3 | 2014-08-21 00:51:00 +0200 | [diff] [blame] | 1526 | |
| 1527 | /** |
| 1528 | * @defgroup User data associated to a SRTP session. |
| 1529 | * @ingroup SRTP |
| 1530 | * |
| 1531 | * @brief Store custom user data within a SRTP session. |
| 1532 | * |
| 1533 | * @{ |
| 1534 | */ |
| 1535 | |
| 1536 | /** |
| 1537 | * @brief srtp_set_user_data() stores the given pointer into the SRTP |
| 1538 | * session for later retrieval. |
| 1539 | * |
| 1540 | * @param ctx is the srtp_t context in which the given data pointer is |
| 1541 | * stored. |
| 1542 | * |
| 1543 | * @param data is a pointer to the custom information (struct, function, |
| 1544 | * etc) associated with the SRTP session. |
| 1545 | * |
| 1546 | * @return void. |
| 1547 | * |
| 1548 | */ |
| 1549 | |
| 1550 | void |
| 1551 | srtp_set_user_data(srtp_t ctx, void *data); |
| 1552 | |
| 1553 | /** |
| 1554 | * @brief srtp_get_user_data() retrieves the pointer to the custom data |
| 1555 | * previously stored with srtp_set_user_data(). |
| 1556 | * |
| 1557 | * This function is mostly useful for retrieving data associated to a |
| 1558 | * SRTP session when an event fires. The user can then get such a custom |
| 1559 | * data by calling this function with the session field of the |
| 1560 | * srtp_event_data_t struct as argument. |
| 1561 | * |
| 1562 | * @param ctx is the srtp_t context in which the given data pointer was |
| 1563 | * stored. |
| 1564 | * |
| 1565 | * @return void* pointer to the user data. |
| 1566 | * |
| 1567 | */ |
| 1568 | |
| 1569 | void* |
| 1570 | srtp_get_user_data(srtp_t ctx); |
| 1571 | |
| 1572 | /** |
| 1573 | * @} |
| 1574 | */ |
| 1575 | |
| 1576 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1577 | /** |
| 1578 | * @defgroup SRTPevents SRTP events and callbacks |
| 1579 | * @ingroup SRTP |
| 1580 | * |
| 1581 | * @brief libSRTP can use a user-provided callback function to |
| 1582 | * handle events. |
| 1583 | * |
| 1584 | * |
| 1585 | * libSRTP allows a user to provide a callback function to handle |
| 1586 | * events that need to be dealt with outside of the data plane (see |
| 1587 | * the enum srtp_event_t for a description of these events). Dealing |
| 1588 | * with these events is not a strict necessity; they are not |
| 1589 | * security-critical, but the application may suffer if they are not |
| 1590 | * handled. The function srtp_set_event_handler() is used to provide |
| 1591 | * the callback function. |
| 1592 | * |
| 1593 | * A default event handler that merely reports on the events as they |
| 1594 | * happen is included. It is also possible to set the event handler |
| 1595 | * function to NULL, in which case all events will just be silently |
| 1596 | * ignored. |
| 1597 | * |
| 1598 | * @{ |
| 1599 | */ |
| 1600 | |
| 1601 | /** |
| 1602 | * @brief srtp_event_t defines events that need to be handled |
| 1603 | * |
| 1604 | * The enum srtp_event_t defines events that need to be handled |
| 1605 | * outside the `data plane', such as SSRC collisions and |
| 1606 | * key expirations. |
| 1607 | * |
| 1608 | * When a key expires or the maximum number of packets has been |
| 1609 | * reached, an SRTP stream will enter an `expired' state in which no |
| 1610 | * more packets can be protected or unprotected. When this happens, |
| 1611 | * it is likely that you will want to either deallocate the stream |
jfigus | 92c3de3 | 2016-02-02 13:44:39 -0500 | [diff] [blame] | 1612 | * (using srtp_remove_stream()), and possibly allocate a new one. |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1613 | * |
| 1614 | * When an SRTP stream expires, the other streams in the same session |
| 1615 | * are unaffected, unless key sharing is used by that stream. In the |
| 1616 | * latter case, all of the streams in the session will expire. |
| 1617 | */ |
| 1618 | |
| 1619 | typedef enum { |
| 1620 | event_ssrc_collision, /**< |
| 1621 | * An SSRC collision occured. |
| 1622 | */ |
| 1623 | event_key_soft_limit, /**< An SRTP stream reached the soft key |
| 1624 | * usage limit and will expire soon. |
| 1625 | */ |
| 1626 | event_key_hard_limit, /**< An SRTP stream reached the hard |
| 1627 | * key usage limit and has expired. |
| 1628 | */ |
| 1629 | event_packet_index_limit /**< An SRTP stream reached the hard |
| 1630 | * packet limit (2^48 packets). |
| 1631 | */ |
| 1632 | } srtp_event_t; |
| 1633 | |
| 1634 | /** |
| 1635 | * @brief srtp_event_data_t is the structure passed as a callback to |
| 1636 | * the event handler function |
| 1637 | * |
| 1638 | * The struct srtp_event_data_t holds the data passed to the event |
| 1639 | * handler function. |
| 1640 | */ |
| 1641 | |
| 1642 | typedef struct srtp_event_data_t { |
| 1643 | srtp_t session; /**< The session in which the event happend. */ |
| 1644 | srtp_stream_t stream; /**< The stream in which the event happend. */ |
| 1645 | srtp_event_t event; /**< An enum indicating the type of event. */ |
| 1646 | } srtp_event_data_t; |
| 1647 | |
| 1648 | /** |
| 1649 | * @brief srtp_event_handler_func_t is the function prototype for |
| 1650 | * the event handler. |
| 1651 | * |
| 1652 | * The typedef srtp_event_handler_func_t is the prototype for the |
| 1653 | * event handler function. It has as its only argument an |
| 1654 | * srtp_event_data_t which describes the event that needs to be handled. |
| 1655 | * There can only be a single, global handler for all events in |
| 1656 | * libSRTP. |
| 1657 | */ |
| 1658 | |
| 1659 | typedef void (srtp_event_handler_func_t)(srtp_event_data_t *data); |
| 1660 | |
| 1661 | /** |
| 1662 | * @brief sets the event handler to the function supplied by the caller. |
| 1663 | * |
| 1664 | * The function call srtp_install_event_handler(func) sets the event |
| 1665 | * handler function to the value func. The value NULL is acceptable |
| 1666 | * as an argument; in this case, events will be ignored rather than |
| 1667 | * handled. |
| 1668 | * |
| 1669 | * @param func is a pointer to a fuction that takes an srtp_event_data_t |
| 1670 | * pointer as an argument and returns void. This function |
| 1671 | * will be used by libSRTP to handle events. |
| 1672 | */ |
| 1673 | |
jfigus | 857009c | 2014-11-05 11:17:43 -0500 | [diff] [blame] | 1674 | 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] | 1675 | |
| 1676 | /** |
jfigus | f62b64d | 2014-10-08 13:53:57 -0400 | [diff] [blame] | 1677 | * @brief Returns the version string of the library. |
| 1678 | * |
| 1679 | */ |
Christian Oien | d4e3eec | 2014-10-24 10:14:08 +0200 | [diff] [blame] | 1680 | const char *srtp_get_version_string(void); |
jfigus | f62b64d | 2014-10-08 13:53:57 -0400 | [diff] [blame] | 1681 | |
| 1682 | /** |
| 1683 | * @brief Returns the numeric representation of the library version. |
| 1684 | * |
| 1685 | */ |
| 1686 | unsigned int srtp_get_version(void); |
| 1687 | |
| 1688 | /** |
jfigus | 46d6b47 | 2014-11-14 16:42:01 -0500 | [diff] [blame] | 1689 | * @brief srtp_set_debug_module(mod_name, v) |
| 1690 | * |
| 1691 | * sets dynamic debugging to the value v (0 for off, 1 for on) for the |
| 1692 | * debug module with the name mod_name |
| 1693 | * |
| 1694 | * returns err_status_ok on success, err_status_fail otherwise |
| 1695 | */ |
| 1696 | srtp_err_status_t srtp_set_debug_module(char *mod_name, int v); |
| 1697 | |
| 1698 | /** |
| 1699 | * @brief srtp_list_debug_modules() outputs a list of debugging modules |
| 1700 | * |
| 1701 | */ |
| 1702 | srtp_err_status_t srtp_list_debug_modules(void); |
| 1703 | |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1704 | /** |
Ryan Hooper | ab0345b | 2017-02-07 16:07:59 -0500 | [diff] [blame] | 1705 | * @brief srtp_get_protect_trailer_length(session, use_mki, mki_index, length) |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1706 | * |
| 1707 | * Determines the length of the amount of data Lib SRTP will add to the |
| 1708 | * packet during the protect process. The length is returned in the length parameter |
| 1709 | * |
| 1710 | * returns err_status_ok on success, err_status_bad_mki if the MKI index is invalid |
| 1711 | * |
| 1712 | */ |
Ryan Hooper | ab0345b | 2017-02-07 16:07:59 -0500 | [diff] [blame] | 1713 | srtp_err_status_t srtp_get_protect_trailer_length(srtp_t session, uint32_t use_mki, |
| 1714 | uint32_t mki_index, uint32_t *length); |
| 1715 | |
| 1716 | /** |
| 1717 | * @brief srtp_get_protect_rtcp_trailer_length(session, use_mki, mki_index, length) |
| 1718 | * |
| 1719 | * Determines the length of the amount of data Lib SRTP will add to the |
| 1720 | * packet during the protect process. The length is returned in the length parameter |
| 1721 | * |
| 1722 | * returns err_status_ok on success, err_status_bad_mki if the MKI index is invalid |
| 1723 | * |
| 1724 | */ |
| 1725 | srtp_err_status_t srtp_get_protect_rtcp_trailer_length(srtp_t session, uint32_t use_mki, |
| 1726 | uint32_t mki_index, uint32_t *length); |
Ryan Hooper | fe5d8b8 | 2016-12-15 14:53:58 -0500 | [diff] [blame] | 1727 | |
jfigus | 46d6b47 | 2014-11-14 16:42:01 -0500 | [diff] [blame] | 1728 | |
| 1729 | /** |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1730 | * @} |
| 1731 | */ |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1732 | /* in host order, so outside the #if */ |
| 1733 | #define SRTCP_E_BIT 0x80000000 |
| 1734 | /* for byte-access */ |
| 1735 | #define SRTCP_E_BYTE_BIT 0x80 |
| 1736 | #define SRTCP_INDEX_MASK 0x7fffffff |
| 1737 | |
Marcus Sundberg | cb60bf8 | 2005-10-17 17:23:05 +0000 | [diff] [blame] | 1738 | #ifdef __cplusplus |
| 1739 | } |
| 1740 | #endif |
| 1741 | |
Pascal Bühler | c3655db | 2017-02-01 09:11:27 +0100 | [diff] [blame] | 1742 | #endif /* SRTP_SRTP_H */ |