summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-05-26 12:06:34 -0400
committerSean Bright <sean.bright@gmail.com>2017-05-26 12:06:34 -0400
commit5e9cd1f20d86de1c25b7a9accffb7d3e2601878b (patch)
tree6f0b0fb740f41b0761475657087611c563766f10 /res
parentd4ccd3a6c088f4d2fefda1a44e4555dd54335cda (diff)
res_srtp: Add support for libsrtp2
ASTERISK-25294 #close Reported by: Tzafrir Cohen ASTERISK-26976 #close Reported by: Alex Change-Id: I789b1c3d1ed31365bbd9339fa58ef36f48833c40
Diffstat (limited to 'res')
-rw-r--r--res/res_srtp.c15
-rw-r--r--res/srtp/srtp_compat.h29
2 files changed, 40 insertions, 4 deletions
diff --git a/res/res_srtp.c b/res/res_srtp.c
index 97773c125..a76128fde 100644
--- a/res/res_srtp.c
+++ b/res/res_srtp.c
@@ -39,11 +39,18 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-#include <srtp/srtp.h>
-#ifdef HAVE_OPENSSL
-#include <openssl/rand.h>
+#if HAVE_SRTP_VERSION > 1
+# include <srtp2/srtp.h>
+# include <srtp2/crypto_types.h>
+# include "srtp/srtp_compat.h"
+# include <openssl/rand.h>
#else
-#include <srtp/crypto_kernel.h>
+# include <srtp/srtp.h>
+# ifdef HAVE_OPENSSL
+# include <openssl/rand.h>
+# else
+# include <srtp/crypto_kernel.h>
+# endif
#endif
#include "asterisk/lock.h"
diff --git a/res/srtp/srtp_compat.h b/res/srtp/srtp_compat.h
new file mode 100644
index 000000000..4ab39f318
--- /dev/null
+++ b/res/srtp/srtp_compat.h
@@ -0,0 +1,29 @@
+#ifndef AST_SRTP_COMPAT_H
+#define AST_SRTP_COMPAT_H
+
+/* Compatibility for libsrtp 2.x */
+
+#define crypto_policy_t srtp_crypto_policy_t
+
+#define AES_128_ICM SRTP_AES_ICM
+#define HMAC_SHA1 SRTP_HMAC_SHA1
+
+#define err_status_t srtp_err_status_t
+#define err_status_ok srtp_err_status_ok
+#define err_status_fail srtp_err_status_fail
+#define err_status_bad_param srtp_err_status_bad_param
+#define err_status_alloc_fail srtp_err_status_alloc_fail
+#define err_status_dealloc_fail srtp_err_status_dealloc_fail
+#define err_status_init_fail srtp_err_status_init_fail
+#define err_status_terminus srtp_err_status_terminus
+#define err_status_auth_fail srtp_err_status_auth_fail
+#define err_status_cipher_fail srtp_err_status_cipher_fail
+#define err_status_replay_fail srtp_err_status_replay_fail
+#define err_status_replay_old srtp_err_status_replay_old
+#define err_status_algo_fail srtp_err_status_algo_fail
+#define err_status_no_such_op srtp_err_status_no_such_op
+#define err_status_no_ctx srtp_err_status_no_ctx
+#define err_status_cant_check srtp_err_status_cant_check
+#define err_status_key_expired srtp_err_status_key_expired
+
+#endif /* AST_SRTP_COMPAT_H */