1 /*! \file rtpsrtp.h 2 * \author Lorenzo Miniero <lorenzo@meetecho.com> 3 * \copyright GNU General Public License v3 4 * \brief SRTP definitions (headers) 5 * \details Definitions of the SRTP usage. This header tries to abstract 6 * the differences there may be between libsrtp and libsrtp2, with respect 7 * to the structs and defines (e.g., errors), plus adding some helpers. 8 * 9 * \ingroup protocols 10 * \ref protocols 11 */ 12 13 #ifndef JANUS_RTPSRTP_H 14 #define JANUS_RTPSRTP_H 15 16 #ifdef HAVE_SRTP_2 17 #include <srtp2/srtp.h> 18 #include <openssl/rand.h> 19 #include <openssl/err.h> 20 #include <openssl/ssl.h> 21 #include <openssl/srtp.h> 22 int srtp_crypto_get_random(uint8_t *key, int len); 23 #else 24 #include <srtp/srtp.h> 25 #include <srtp/crypto_kernel.h> 26 #define srtp_err_status_t err_status_t 27 #define srtp_err_status_ok err_status_ok 28 #define srtp_err_status_replay_fail err_status_replay_fail 29 #define srtp_err_status_replay_old err_status_replay_old 30 #define srtp_crypto_policy_set_rtp_default crypto_policy_set_rtp_default 31 #define srtp_crypto_policy_set_rtcp_default crypto_policy_set_rtcp_default 32 #define srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32 crypto_policy_set_aes_cm_128_hmac_sha1_32 33 #define srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80 crypto_policy_set_aes_cm_128_hmac_sha1_80 34 #define srtp_crypto_policy_set_aes_gcm_256_16_auth crypto_policy_set_aes_gcm_256_16_auth 35 #define srtp_crypto_policy_set_aes_gcm_128_16_auth crypto_policy_set_aes_gcm_128_16_auth 36 #define srtp_crypto_get_random crypto_get_random 37 #endif 38 39 /* SRTP stuff (http://tools.ietf.org/html/rfc3711) */ 40 #define SRTP_MASTER_KEY_LENGTH 16 41 #define SRTP_MASTER_SALT_LENGTH 14 42 #define SRTP_MASTER_LENGTH (SRTP_MASTER_KEY_LENGTH + SRTP_MASTER_SALT_LENGTH) 43 /* AES-GCM stuff (http://tools.ietf.org/html/rfc7714) */ 44 #define SRTP_AESGCM128_MASTER_KEY_LENGTH 16 45 #define SRTP_AESGCM128_MASTER_SALT_LENGTH 12 46 #define SRTP_AESGCM128_MASTER_LENGTH (SRTP_AESGCM128_MASTER_KEY_LENGTH + SRTP_AESGCM128_MASTER_SALT_LENGTH) 47 #define SRTP_AESGCM256_MASTER_KEY_LENGTH 32 48 #define SRTP_AESGCM256_MASTER_SALT_LENGTH 12 49 #define SRTP_AESGCM256_MASTER_LENGTH (SRTP_AESGCM256_MASTER_KEY_LENGTH + SRTP_AESGCM256_MASTER_SALT_LENGTH) 50 51 /* SRTP profiles */ 52 typedef enum janus_srtp_profile { 53 JANUS_SRTP_AES128_CM_SHA1_32 = 1, 54 JANUS_SRTP_AES128_CM_SHA1_80, 55 JANUS_SRTP_AEAD_AES_128_GCM, 56 JANUS_SRTP_AEAD_AES_256_GCM 57 } janus_srtp_profile; 58 59 #ifndef SRTP_AEAD_AES_256_GCM 60 #undef HAVE_SRTP_AESGCM 61 #endif 62 63 /*! \brief Helper method to get a string representation of a libsrtp error code 64 * @param[in] error The libsrtp error code 65 * @returns A string representation of the error code */ 66 const char *janus_srtp_error_str(int error); 67 68 #endif 69