[asterisk-commits] jpeeler: branch jpeeler/srtp r110151 - in /team/jpeeler/srtp: channels/ inclu...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 19 17:22:06 CDT 2008
Author: jpeeler
Date: Wed Mar 19 17:22:06 2008
New Revision: 110151
URL: http://svn.digium.com/view/asterisk?view=rev&rev=110151
Log:
added some missing files
Added:
team/jpeeler/srtp/channels/sdp_crypto.c (with props)
team/jpeeler/srtp/channels/sdp_crypto.h (with props)
team/jpeeler/srtp/channels/sdp_mikey.c (with props)
team/jpeeler/srtp/channels/sdp_mikey.h (with props)
team/jpeeler/srtp/channels/sip_srtp.c (with props)
team/jpeeler/srtp/channels/sip_srtp.h (with props)
team/jpeeler/srtp/include/asterisk/mikey.h (with props)
team/jpeeler/srtp/res/mikey.cc (with props)
team/jpeeler/srtp/res/mikey.h (with props)
team/jpeeler/srtp/res/res_mikey.c (with props)
team/jpeeler/srtp/res/res_srtp.c (with props)
Modified:
team/jpeeler/srtp/include/asterisk/autoconfig.h.in
Added: team/jpeeler/srtp/channels/sdp_crypto.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/srtp/channels/sdp_crypto.c?view=auto&rev=110151
==============================================================================
--- team/jpeeler/srtp/channels/sdp_crypto.c (added)
+++ team/jpeeler/srtp/channels/sdp_crypto.c Wed Mar 19 17:22:06 2008
@@ -1,0 +1,309 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2006 - 2007, Mikael Magnusson
+ *
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file sdp_crypto.c
+ *
+ * \brief SDP Security descriptions
+ *
+ * Specified in RFC 4568
+ *
+ * \author Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/options.h"
+#include "sdp_crypto.h"
+
+#define SRTP_MASTER_LEN 30
+#define SRTP_MASTERKEY_LEN 16
+#define SRTP_MASTERSALT_LEN (SRTP_MASTER_LEN - SRTP_MASTERKEY_LEN)
+#define SRTP_MASTER_LEN64 ((SRTP_MASTER_LEN * 8 + 5) / 6 + 1)
+
+struct sdp_crypto {
+ char *a_crypto;
+ unsigned char local_key[SRTP_MASTER_LEN];
+ char local_key64[SRTP_MASTER_LEN64];
+};
+
+static int set_crypto_policy(struct ast_srtp_policy *policy,
+ int suite_val, const unsigned char *master_key,
+ unsigned long ssrc, int inbound);
+
+
+static struct sdp_crypto *sdp_crypto_alloc(void)
+{
+ struct sdp_crypto *crypto = malloc(sizeof(*crypto));
+
+ if (crypto)
+ memset(crypto, 0, sizeof(*crypto));
+ else
+ ast_log(LOG_ERROR, "Out of memory, can't allocate crypto structure\n");
+
+ return crypto;
+}
+
+void sdp_crypto_destroy(struct sdp_crypto *crypto)
+{
+ if (crypto->a_crypto)
+ free(crypto->a_crypto);
+ crypto->a_crypto = NULL;
+ free(crypto);
+}
+
+struct sdp_crypto *sdp_crypto_setup(void)
+{
+ struct sdp_crypto *p = sdp_crypto_alloc();
+
+ if (!p)
+ return NULL;
+
+ if (ast_srtp_get_random(p->local_key, sizeof(p->local_key)) < 0) {
+ sdp_crypto_destroy(p);
+ return NULL;
+ }
+
+ ast_base64encode(p->local_key64, p->local_key,
+ SRTP_MASTER_LEN, sizeof(p->local_key64));
+
+ {
+ /* FIXME mikma, remove block */
+ int key_len;
+ unsigned char remote_key[SRTP_MASTER_LEN];
+
+ key_len = ast_base64decode(remote_key, p->local_key64, sizeof(remote_key));
+
+ if (key_len != SRTP_MASTER_LEN)
+ ast_log(LOG_ERROR, "base64 encode/decode bad len %d != %d\n", key_len, SRTP_MASTER_LEN);
+
+ if (memcmp(remote_key, p->local_key, SRTP_MASTER_LEN))
+ ast_log(LOG_ERROR, "base64 encode/decode bad key\n");
+ }
+
+ ast_log(LOG_DEBUG, "local_key64 %s len %zu\n", p->local_key64, strlen(p->local_key64));
+ return p;
+}
+
+static int set_crypto_policy(struct ast_srtp_policy *policy,
+ int suite_val, const unsigned char *master_key,
+ unsigned long ssrc, int inbound)
+{
+ const unsigned char *master_salt = NULL;
+
+ master_salt = master_key + SRTP_MASTERKEY_LEN;
+ if (ast_srtp_policy_set_master_key(policy,
+ master_key, SRTP_MASTERKEY_LEN,
+ master_salt, SRTP_MASTERSALT_LEN) < 0)
+ return -1;
+
+
+ if (ast_srtp_policy_set_suite(policy, suite_val)) {
+ ast_log(LOG_WARNING, "Could not set remote SRTP suite\n");
+ return -1;
+ }
+
+ ast_srtp_policy_set_ssrc(policy, ssrc, inbound);
+
+ return 0;
+}
+
+static int sdp_crypto_activate(struct sdp_crypto *p, int suite_val,
+ unsigned char *remote_key,
+ struct ast_rtp *rtp)
+{
+ struct ast_srtp_policy *local_policy = NULL;
+ struct ast_srtp_policy *remote_policy = NULL;
+ int res = -1;
+
+ if (!p)
+ return -1;
+
+ local_policy = ast_srtp_policy_alloc();
+ if (!local_policy)
+ goto err;
+
+ remote_policy = ast_srtp_policy_alloc();
+ if (!remote_policy) {
+ goto err;
+ }
+
+ if (set_crypto_policy(local_policy, suite_val, p->local_key,
+ ast_rtp_get_ssrc(rtp), 0) < 0)
+ goto err;
+
+ if (set_crypto_policy(remote_policy, suite_val, remote_key, 0, 1) < 0)
+ goto err;
+
+/* FIXME MIKMA */
+ if (ast_rtp_add_srtp_policy(rtp, local_policy)) {
+ ast_log(LOG_WARNING, "Could not set local SRTP policy\n");
+ goto err;
+ }
+
+ if (ast_rtp_add_srtp_policy(rtp, remote_policy)) {
+ ast_log(LOG_WARNING, "Could not set remote SRTP policy\n");
+ goto err;
+ }
+
+
+ if (option_debug > 1)
+ ast_log(LOG_DEBUG, "SRTP policy activated\n");
+ res = 0;
+
+err:
+ if (local_policy)
+ ast_srtp_policy_destroy(local_policy);
+
+ if (remote_policy)
+ ast_srtp_policy_destroy(remote_policy);
+ return res;
+}
+
+int sdp_crypto_process(struct sdp_crypto *p, const char *attr,
+ struct ast_rtp *rtp)
+{
+ char *str = NULL;
+ char *name = NULL;
+ char *tag = NULL;
+ char *suite = NULL;
+ char *key_params = NULL;
+ char *key_param = NULL;
+ char *session_params = NULL;
+ char *key_salt = NULL;
+ char *lifetime = NULL;
+ int found = 0;
+ int attr_len = strlen(attr);
+ int key_len = 0;
+ unsigned char remote_key[SRTP_MASTER_LEN];
+ int suite_val = 0;
+
+ if (!ast_srtp_is_registered())
+ return -1;
+
+ /* Crypto already accepted */
+/* if (p && p->a_crypto) */
+/* return -1; */
+
+ str = ast_strdupa(attr);
+
+ name = strsep(&str, ":");
+ tag = strsep(&str, " ");
+ suite = strsep(&str, " ");
+ key_params = strsep(&str, " ");
+ session_params = strsep(&str, " ");
+
+ if (!tag || !suite) {
+ ast_log(LOG_WARNING, "Unrecognized a=%s", attr);
+ return -1;
+ }
+
+ if (session_params) {
+ ast_log(LOG_WARNING, "Unsupported crypto parameters: %s",
+ session_params);
+ return -1;
+ }
+
+ if (!strcmp(suite, "AES_CM_128_HMAC_SHA1_80")) {
+ suite_val = AST_AES_CM_128_HMAC_SHA1_80;
+ } else if (!strcmp(suite, "AES_CM_128_HMAC_SHA1_32")) {
+ suite_val = AST_AES_CM_128_HMAC_SHA1_32;
+ } else {
+ ast_log(LOG_WARNING, "Unsupported crypto suite: %s",
+ suite);
+ return -1;
+ }
+
+ while ((key_param = strsep(&key_params, ";"))) {
+ char *method = NULL;
+ char *info = NULL;
+
+ method = strsep(&key_param, ":");
+ info = strsep(&key_param, ";");
+
+ if (!strcmp(method, "inline")) {
+ key_salt = strsep(&info, "|");
+ lifetime = strsep(&info, "|");
+
+ if (lifetime) {
+ ast_log(LOG_NOTICE, "Crypto life time unsupported: %s\n",
+ attr);
+ continue;
+ }
+
+/* if (info || strncmp(lifetime, "2^", 2)) { */
+/* ast_log(LOG_NOTICE, "MKI unsupported: %s\n", */
+/* attr); */
+/* continue; */
+/* } */
+
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) {
+ ast_log(LOG_NOTICE, "SRTP crypto offer not acceptable\n");
+ return -1;
+ }
+
+ key_len = ast_base64decode(remote_key, key_salt, sizeof(remote_key));
+ if (key_len != SRTP_MASTER_LEN) {
+ ast_log(LOG_WARNING, "SRTP sdescriptions key %d != %d\n",
+ key_len, SRTP_MASTER_LEN);
+ return -1;
+ }
+
+ if (sdp_crypto_activate(p, suite_val, remote_key, rtp) < 0)
+ return -1;
+
+ if (!p->a_crypto) {
+ free(p->a_crypto);
+
+ p->a_crypto = malloc(attr_len+11);
+ snprintf(p->a_crypto, attr_len+10,
+ "a=crypto:%s %s inline:%s\r\n",
+ tag, suite, p->local_key64);
+ }
+
+ return 0;
+}
+
+int sdp_crypto_offer(struct sdp_crypto *p)
+{
+ char crypto_buf[128];
+
+ /* Crypto offer */
+ const char *crypto_suite = "AES_CM_128_HMAC_SHA1_80";
+
+ if (p->a_crypto)
+ free(p->a_crypto);
+
+ snprintf(crypto_buf, sizeof(crypto_buf),
+ "a=crypto:1 %s inline:%s\r\n",
+ crypto_suite, p->local_key64);
+ p->a_crypto = strdup(crypto_buf);
+
+ return 0;
+}
+
+const char *sdp_crypto_attrib(struct sdp_crypto *p)
+{
+ return p->a_crypto;
+}
Propchange: team/jpeeler/srtp/channels/sdp_crypto.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/jpeeler/srtp/channels/sdp_crypto.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/jpeeler/srtp/channels/sdp_crypto.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/jpeeler/srtp/channels/sdp_crypto.h
URL: http://svn.digium.com/view/asterisk/team/jpeeler/srtp/channels/sdp_crypto.h?view=auto&rev=110151
==============================================================================
--- team/jpeeler/srtp/channels/sdp_crypto.h (added)
+++ team/jpeeler/srtp/channels/sdp_crypto.h Wed Mar 19 17:22:06 2008
@@ -1,0 +1,46 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2006 - 2007, Mikael Magnusson
+ *
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file sdp_crypto.h
+ *
+ * \brief SDP Security descriptions
+ *
+ * Specified in RFC 4568
+ *
+ * \author Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#ifndef _SDP_CRYPTO_H
+#define _SDP_CRYPTO_H
+
+#include <asterisk/rtp.h>
+
+struct sdp_crypto;
+
+struct sdp_crypto *sdp_crypto_setup(void);
+void sdp_crypto_destroy(struct sdp_crypto *crypto);
+
+/* int sdp_crypto_activate(struct sdp_crypto *p, int suite_val, */
+/* unsigned char *remote_key, */
+/* struct ast_rtp *rtp); */
+int sdp_crypto_process(struct sdp_crypto *p, const char *attr,
+ struct ast_rtp *rtp);
+int sdp_crypto_offer(struct sdp_crypto *p);
+const char *sdp_crypto_attrib(struct sdp_crypto *p);
+
+#endif /* _SDP_CRYPTO_H */
Propchange: team/jpeeler/srtp/channels/sdp_crypto.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/jpeeler/srtp/channels/sdp_crypto.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/jpeeler/srtp/channels/sdp_crypto.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/jpeeler/srtp/channels/sdp_mikey.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/srtp/channels/sdp_mikey.c?view=auto&rev=110151
==============================================================================
--- team/jpeeler/srtp/channels/sdp_mikey.c (added)
+++ team/jpeeler/srtp/channels/sdp_mikey.c Wed Mar 19 17:22:06 2008
@@ -1,0 +1,275 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2006 - 2007, Mikael Magnusson
+ *
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file sdp_mikey.c
+ *
+ * \brief SDP MIKEY key management
+ *
+ * SDP MIKEY key management
+ * Specified in RFC 3830 and 4567
+ *
+ * \author Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/options.h"
+#include "asterisk/rtp.h"
+#include "asterisk/mikey.h"
+#include "sdp_mikey.h"
+
+/*
+ MIKEY
+ Specified in: RFC 3830, RFC 4567
+*/
+
+/*
+ TODO disable rtp until keys are available.
+ TODO sometimes first RTP packet is received before rtp callback
+ is installed, leads to that ssrc not being activated.
+ */
+
+struct sdp_mikey {
+ struct mikey *mikey;
+ char *a_mikey;
+};
+
+static int sdp_mikey_activate(struct sdp_mikey *p, struct ast_rtp *rtp);
+
+
+int sdp_mikey_init(void)
+{
+ return 0;
+}
+
+void sdp_mikey_uninit(void)
+{
+}
+
+static struct sdp_mikey *sdp_mikey_alloc(void)
+{
+ struct ast_mikey_res *res = ast_get_mikey();
+ struct sdp_mikey *mikey;
+
+ if (!res) {
+ ast_log(LOG_ERROR, "res_mikey not loaded\n");
+ return NULL;
+ }
+
+ mikey = malloc(sizeof(*mikey));
+
+ if (mikey)
+ memset(mikey, 0, sizeof(*mikey));
+ else
+ ast_log(LOG_ERROR, "Out of memory, can't allocate mikey structure\n");
+
+ return mikey;
+}
+
+void sdp_mikey_destroy(struct sdp_mikey *p)
+{
+ struct ast_mikey_res *res = ast_get_mikey();
+
+ if (p->mikey)
+ res->mikey_destroy(p->mikey);
+ p->mikey = NULL;
+
+ if (p->a_mikey)
+ free(p->a_mikey);
+ p->a_mikey = NULL;
+
+ free(p);
+}
+
+struct sdp_mikey *sdp_mikey_setup(const char *peersecret,
+ struct ast_rtp *rtp)
+{
+ struct ast_mikey_res *res = ast_get_mikey();
+ struct sdp_mikey *p = sdp_mikey_alloc();
+
+ if (!p)
+ return NULL;
+
+ p->mikey = res->mikey_alloc();
+ if (peersecret) {
+ ast_log(LOG_NOTICE, "Using MIKEY PSK %s\n", peersecret);
+ res->mikey_set_psk_secret(p->mikey, (unsigned char*)peersecret,
+ strlen(peersecret));
+ }
+ else {
+ ast_log(LOG_NOTICE, "Now MIKEY PSK available\n");
+ }
+
+ res->mikey_set_ssrc(p->mikey, ast_rtp_get_ssrc(rtp));
+
+ return p;
+}
+
+int sdp_mikey_process(struct sdp_mikey *p, const char *attr,
+ struct ast_rtp *rtp)
+{
+ struct ast_mikey_res *mod = ast_get_mikey();
+ char buf[8192] = "a=key-mgmt:mikey ";
+ size_t prefixlen = strlen(buf);
+ size_t buflen = sizeof(buf) - prefixlen - 2;
+ int res;
+
+ if (!p->mikey) {
+ ast_log(LOG_ERROR, "No MIKEY object\n");
+ return -1;
+ }
+
+ ast_log(LOG_DEBUG, "%s\n", attr);
+
+ res = mod->mikey_process(p->mikey, attr, buf + prefixlen, buflen);
+
+ if (res < 0) {
+ ast_log(LOG_NOTICE, "Couldn't parse MIKEY offer\n");
+ return -1;
+ }
+
+ if (p->a_mikey)
+ free(p->a_mikey);
+ p->a_mikey = NULL;
+
+ if (sdp_mikey_activate(p, rtp) < 0)
+ return -1;
+
+ if (res > 0) {
+ /* Parsed offer, built response */
+ strcat(buf, "\r\n");
+
+ p->a_mikey = strdup(buf);
+ }
+ return 0;
+}
+
+int sdp_mikey_offer(struct sdp_mikey *p, struct ast_rtp *rtp)
+{
+ struct ast_mikey_res *mod = ast_get_mikey();
+ char buf[8192] = "a=key-mgmt:mikey ";
+ size_t prefixlen = strlen(buf);
+ size_t buflen = sizeof(buf) - prefixlen - 2;
+ int res;
+
+ /* Crypto already accepted */
+ if (p && p->a_mikey)
+ return -1;
+
+ res = mod->mikey_build_offer(p->mikey, buf + prefixlen, buflen, AST_MIKEY_TYPE_DH_HMAC);
+
+ if (res < 0) {
+ ast_log(LOG_NOTICE, "Couldn't build MIKEY offer\n");
+ return -1;
+ }
+
+ if (sdp_mikey_activate(p, rtp) < 0)
+ return -1;
+
+ strcat(buf, "\r\n");
+
+ if (p->a_mikey)
+ free(p->a_mikey);
+
+ p->a_mikey = strdup(buf);
+ return 0;
+}
+
+static int cb_no_ctx(struct ast_rtp *rtp, unsigned long ssrc, void *data)
+{
+ struct ast_mikey_res *mod = ast_get_mikey();
+ struct sdp_mikey *p = data;
+ struct ast_srtp_policy *policy = NULL;
+ int res = -1;
+
+ ast_log(LOG_DEBUG, "SRTP cb\n");
+
+ if (!p) {
+ ast_log(LOG_WARNING, "No pvt\n");
+ goto err;
+ }
+
+ if (!p->mikey) {
+ ast_log(LOG_WARNING, "No mikey\n");
+ goto err;
+ }
+
+ policy = mod->mikey_create_policy(p->mikey, ssrc);
+ if (!policy) {
+ ast_log(LOG_ERROR, "Could not create MIKEY policy\n");
+ goto err;
+ }
+
+ /* was p->rtp */
+ if (ast_rtp_add_srtp_policy(rtp, policy)) {
+ ast_log(LOG_ERROR, "Could not set SRTP policy\n");
+ goto err;
+ }
+
+ res = 0;
+
+err:
+ if (policy)
+ ast_srtp_policy_destroy(policy);
+ return res;
+}
+
+struct ast_srtp_cb srtp_cb = {
+ no_ctx: cb_no_ctx
+};
+
+static int sdp_mikey_activate(struct sdp_mikey *p, struct ast_rtp *rtp)
+{
+ struct ast_mikey_res *mod = ast_get_mikey();
+ struct ast_srtp_policy *policy = NULL;
+ int res = -1;
+
+ if (!p || !p->mikey)
+ return -1;
+
+ policy = mod->mikey_create_policy(p->mikey, ast_rtp_get_ssrc(rtp));
+ if (!policy) {
+ ast_log(LOG_ERROR, "Could not create MIKEY policy\n");
+ goto err;
+ }
+
+ if (ast_rtp_add_srtp_policy(rtp, policy)) {
+ ast_log(LOG_ERROR, "Could not set local SRTP policy\n");
+ goto err;
+ }
+
+ ast_rtp_set_srtp_cb(rtp, &srtp_cb, p);
+
+ if (option_debug > 1)
+ ast_log(LOG_NOTICE, "SRTP policy activated\n");
+ res = 0;
+
+err:
+ if (policy)
+ ast_srtp_policy_destroy(policy);
+ return res;
+}
+
+const char *sdp_mikey_attrib(struct sdp_mikey *p)
+{
+ ast_log(LOG_DEBUG, "Return mikey attrib %s\n", p->a_mikey);
+
+ return p->a_mikey;
+}
Propchange: team/jpeeler/srtp/channels/sdp_mikey.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/jpeeler/srtp/channels/sdp_mikey.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/jpeeler/srtp/channels/sdp_mikey.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/jpeeler/srtp/channels/sdp_mikey.h
URL: http://svn.digium.com/view/asterisk/team/jpeeler/srtp/channels/sdp_mikey.h?view=auto&rev=110151
==============================================================================
--- team/jpeeler/srtp/channels/sdp_mikey.h (added)
+++ team/jpeeler/srtp/channels/sdp_mikey.h Wed Mar 19 17:22:06 2008
@@ -1,0 +1,48 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2006 - 2007, Mikael Magnusson
+ *
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file sdp_mikey.h
+ *
+ * \brief SDP MIKEY key management
+ *
+ * SDP MIKEY key management
+ * Specified in RFC 3830 and 4567
+ *
+ * \author Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#ifndef _SDP_MIKEY_H
+#define _SDP_MIKEY_H
+
+#include <asterisk/rtp.h>
+
+struct sdp_mikey;
+
+int sdp_mikey_init(void);
+void sdp_mikey_uninit(void);
+
+struct sdp_mikey *sdp_mikey_setup(const char *peersecret,
+ struct ast_rtp *rtp);
+void sdp_mikey_destroy(struct sdp_mikey *p);
+/* int sdp_mikey_activate(struct sdp_mikey *p, struct ast_rtp *rtp); */
+int sdp_mikey_offer(struct sdp_mikey *p, struct ast_rtp *rtp);
+int sdp_mikey_process(struct sdp_mikey *p, const char *attr,
+ struct ast_rtp *rtp);
+const char *sdp_mikey_attrib(struct sdp_mikey *p);
+
+#endif /* _SDP_MIKEY_H */
Propchange: team/jpeeler/srtp/channels/sdp_mikey.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/jpeeler/srtp/channels/sdp_mikey.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/jpeeler/srtp/channels/sdp_mikey.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/jpeeler/srtp/channels/sip_srtp.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/srtp/channels/sip_srtp.c?view=auto&rev=110151
==============================================================================
--- team/jpeeler/srtp/channels/sip_srtp.c (added)
+++ team/jpeeler/srtp/channels/sip_srtp.c Wed Mar 19 17:22:06 2008
@@ -1,0 +1,54 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2006 - 2007, Mikael Magnusson
+ *
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file sip_srtp.c
+ *
+ * \brief SIP Secure RTP (SRTP)
+ *
+ * Specified in RFC 3711
+ *
+ * \author Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "sip_srtp.h"
+
+struct sip_srtp *sip_srtp_alloc(void)
+{
+ struct sip_srtp *srtp = malloc(sizeof(*srtp));
+
+ if (srtp)
+ memset(srtp, 0, sizeof(*srtp));
+ else
+ ast_log(LOG_ERROR, "Out of memory, can't allocate srtp structure\n");
+ return srtp;
+}
+
+void sip_srtp_destroy(struct sip_srtp *srtp)
+{
+ if (srtp->crypto)
+ sdp_crypto_destroy(srtp->crypto);
+ srtp->crypto = NULL;
+
+ if (srtp->mikey)
+ sdp_mikey_destroy(srtp->mikey);
+ srtp->mikey = NULL;
+}
Propchange: team/jpeeler/srtp/channels/sip_srtp.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/jpeeler/srtp/channels/sip_srtp.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/jpeeler/srtp/channels/sip_srtp.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/jpeeler/srtp/channels/sip_srtp.h
URL: http://svn.digium.com/view/asterisk/team/jpeeler/srtp/channels/sip_srtp.h?view=auto&rev=110151
==============================================================================
--- team/jpeeler/srtp/channels/sip_srtp.h (added)
+++ team/jpeeler/srtp/channels/sip_srtp.h Wed Mar 19 17:22:06 2008
@@ -1,0 +1,69 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2006 - 2007, Mikael Magnusson
+ *
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file sip_srtp.h
+ *
+ * \brief SIP Secure RTP (SRTP)
+ *
+ * Specified in RFC 3711
+ *
+ * \author Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+#ifndef _SIP_SRTP_H
+#define _SIP_SRTP_H
+
+#include "sdp_crypto.h"
+#include "sdp_mikey.h"
+
+/* SRTP flags */
+#define SRTP_ENCR_OPTIONAL (1<<1) /* SRTP encryption optional */
+#define SRTP_CRYPTO_ENABLE (1<<3)
+#define SRTP_MIKEY_ENABLE (1<<4)
+#define SRTP_CRYPTO_OFFER_OK (1<<5)
+#define SRTP_MIKEY_OFFER_OK (1<<6)
+
+
+/*! \brief structure for secure RTP audio */
+struct sip_srtp {
+ unsigned int flags;
+ struct sdp_crypto *crypto;
+ struct sdp_mikey *mikey;
+};
+
+/*----- SRTP interface functions */
+struct sip_srtp *sip_srtp_alloc(void);
+void sip_srtp_destroy(struct sip_srtp *srtp);
+
+#if 0
+struct sip_sdp_keymgmt {
+ int (*init)(void);
+ void (*uninit)(void);
+ struct sdp_keymgmt *(*setup)(const char *peersecret,
+ struct ast_rtp *rtp);
+ void (*destroy)(struct sdp_keymgmt *p);
+ int (*offer)(struct sdp_keymgmt *p, struct ast_rtp *rtp);
+ const char *(*attrib)(struct sdp_keymgmt *p);
+ /* FIX attr offset */
+ int (*process)(struct sdp_keymgmt *p, const char *attr,
+ struct ast_rtp *rtp);
+};
+
+#endif
+
+#endif /* _SIP_SRTP_H */
Propchange: team/jpeeler/srtp/channels/sip_srtp.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/jpeeler/srtp/channels/sip_srtp.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/jpeeler/srtp/channels/sip_srtp.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/jpeeler/srtp/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/team/jpeeler/srtp/include/asterisk/autoconfig.h.in?view=diff&rev=110151&r1=110150&r2=110151
==============================================================================
--- team/jpeeler/srtp/include/asterisk/autoconfig.h.in (original)
+++ team/jpeeler/srtp/include/asterisk/autoconfig.h.in Wed Mar 19 17:22:06 2008
@@ -381,6 +381,18 @@
/* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
+
+/* Define to 1 if you have the `mcrypto' library (-lmcrypto). */
+#undef HAVE_LIBMCRYPTO
+
+/* Define to 1 if you have the `mikey' library (-lmikey). */
+#undef HAVE_LIBMIKEY
+
+/* Define to 1 if you have the `mnetutil' library (-lmnetutil). */
+#undef HAVE_LIBMNETUTIL
+
+/* Define to 1 if you have the `mutil' library (-lmutil). */
+#undef HAVE_LIBMUTIL
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
@@ -1181,6 +1193,9 @@
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
/* Define like PROTOTYPES; this can be used by system headers. */
#undef __PROTOTYPES
Added: team/jpeeler/srtp/include/asterisk/mikey.h
URL: http://svn.digium.com/view/asterisk/team/jpeeler/srtp/include/asterisk/mikey.h?view=auto&rev=110151
==============================================================================
--- team/jpeeler/srtp/include/asterisk/mikey.h (added)
+++ team/jpeeler/srtp/include/asterisk/mikey.h Wed Mar 19 17:22:06 2008
@@ -1,0 +1,82 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2005 - 2007, Mikael Magnusson
+ *
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file mikey.h
+ * \brief MIKEY - Multimedia Internet KEYing
+ *
+ * Supported modes:
+ * Pre-shared, Public key, D-H Sign, D-H HMAC and RSA in reverse mode.
+ *
+ * MIKEY is defined in RFC 3830, D-H HMAC in 4650 and RSA-R in 4738.
+ */
+
+#ifndef _ASTERISK_MIKEY_H
+#define _ASTERISK_MIKEY_H
+
+#include <asterisk/rtp.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum ast_mikey_type {
+ AST_MIKEY_TYPE_PSK = 0,
+ AST_MIKEY_TYPE_PK,
+ AST_MIKEY_TYPE_DH_SIGN,
+ AST_MIKEY_TYPE_DH_HMAC,
+ AST_MIKEY_TYPE_RSA_R,
+};
+
+struct ast_mikey_res {
+ int (*mikey_init)(void);
+ void (*mikey_uninit)(void);
+/* int (*mikey_add_global_ca_file)(const char *ca_file); */
+/* int (*mikey_add_global_cert_file)(const char *cert_file, */
+/* const char *key_file); */
+
+ struct mikey *(*mikey_alloc)(void);
+ void (*mikey_destroy)(struct mikey *mikey);
+ void (*mikey_set_ssrc)(struct mikey *mikey, uint32_t ssrc);
+ void (*mikey_set_psk_secret)(struct mikey *mikey,
+ const unsigned char *secret, size_t len);
+ int (*mikey_add_ca_file)(struct mikey *mikey, const char *ca_file);
+ int (*mikey_add_cert_file)(struct mikey *mikey, const char *cert_file,
+ const char *key_file);
+
+ int (*mikey_build_offer)(struct mikey *mikey, char *buf, size_t len,
+ enum ast_mikey_type type);
+
+ int (*mikey_process)(struct mikey *mikey, const char *offer,
+ char *buf, size_t buflen);
+
+ struct ast_srtp_policy *(*mikey_create_policy)(struct mikey *mikey,
+ uint32_t ssrc);
+};
+
+int ast_register_mikey(struct ast_mikey_res *mikey_res);
+
+int ast_unregister_mikey(struct ast_mikey_res *mikey_res);
+
+struct ast_mikey_res *ast_get_mikey(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ASTERISK_MIKEY_H */
Propchange: team/jpeeler/srtp/include/asterisk/mikey.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/jpeeler/srtp/include/asterisk/mikey.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/jpeeler/srtp/include/asterisk/mikey.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/jpeeler/srtp/res/mikey.cc
URL: http://svn.digium.com/view/asterisk/team/jpeeler/srtp/res/mikey.cc?view=auto&rev=110151
==============================================================================
--- team/jpeeler/srtp/res/mikey.cc (added)
+++ team/jpeeler/srtp/res/mikey.cc Wed Mar 19 17:22:06 2008
@@ -1,0 +1,907 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2005 - 2007, Mikael Magnusson
+ *
+ * Mikael Magnusson <mikma at users.sourceforge.net>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file mikey.cc
+ *
+ * \brief MIKEY - Multimedia InternetKEYing
+ *
+ * MIKEY is specified in RFC 3830, 4650 and 4738.
+ *
+ * \author Mikael Magnusson <mikma at users.sourceforge.net>
+ */
+
+extern "C" {
+#include "asterisk/autoconfig.h"
+
+#include"asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision:$")
+}
+
+#include<libmcrypto/init.h>
+#include<libmcrypto/SipSimSoft.h>
+#include<libmikey/Mikey.h>
+#include<libmikey/MikeyMessage.h>
+#include<libmikey/MikeyPayloadSP.h>
+#include<libmikey/MikeyPayloadHDR.h>
+#include<libmikey/MikeyPayloadERR.h>
+#include<libmikey/MikeyException.h>
+#include<libmikey/KeyAgreementDHHMAC.h>
+#include<libmikey/KeyAgreementRSAR.h>
+#include<libmutil/stringutils.h>
+
+#include<iostream>
+#include"mikey.h"
+#include "asterisk/paths.h"
+
+using namespace std;
+
+#define DEBUG_OUTPUT
+
+#define MASTER_KEY_LEN 16
+#define MASTER_SALT_LEN 14
+
+
+// local functions
+static int message_to_base64(MRef<MikeyMessage *> msg,
+ char *buf, size_t buflen);
+static int string_to_buf(const string &msg, char *buf, size_t buflen);
+static void dump_hex(unsigned char *buf, size_t bufsize);
+static int getPolicyParamTypeValue(MikeyPayloadSP *policy, uint8_t type,
+ uint8_t *value);
+static void dump_policy(MikeyPayloadSP *sp);
+static bool check_policy(MikeyPayloadSP *policy);
+static bool check_policies(MRef<MikeyMessage *> msg);
+static void dump_crypto_params(MRef<KeyAgreement *> ka);
+
+
+// local class declarations
+class ast_mikey_config: public IMikeyConfig
+{
+public:
+ ast_mikey_config();
+ virtual ~ast_mikey_config();
+
+ void set_psk_secret(const unsigned char *secret, size_t len);
+ int add_ca_file(const char *ca_file);
+ int add_cert(const char *cert_file, const char *key_file);
+
+ // IMikeyConfig
+ virtual const std::string getUri() const{ return uri; }
+ virtual MRef<SipSim*> getSim() const{ return sim; }
+ virtual size_t getPskLength() const{ return psk_len; }
+ virtual const byte_t* getPsk() const{ return psk; }
+ virtual bool isMethodEnabled( int kaType ) const{ return true; }
+ virtual bool isCertCheckEnabled() const{ return true; }
+
+private:
+ string uri;
+ MRef<SipSim*> sim;
+ byte_t *psk;
+ size_t psk_len;
+};
+
+
+struct mikey
+{
+protected:
+ int activate();
+ int add_ssrc(uint32_t ssrc, struct ast_srtp_policy *policy);
+ int set_crypto_policy(uint32_t ssrc, struct ast_srtp_policy *policy);
+
+public:
+ mikey();
+ virtual ~mikey();
+
+ MRef<ast_mikey_config*> get_config() { return config; }
+
+ void add_stream(uint32_t ssrc);
+ int build_offer(char *buf, size_t buflen, int ka_type);
+ int parse_offer(const char *offer, char *buf, size_t buflen);
+ struct ast_srtp_policy *create_policy(uint32_t ssrc);
+
+private:
+ MRef<ast_mikey_config*> config;
+ MRef<Mikey*> state;
+};
+
+
+// globals
+static MRef<CertificateChain *> g_cert_chain;
+static MRef<CertificateSet *> g_ca_db;
+
+/*
+
+RFC 3830
+
+EALG
+
+SRTP encr alg | Value
+---------------------
+NULL | 0
+AES-CM | 1
+AES-F8 | 2
+
+EKEYL - Encryption key length
+
+AALG
+
+SRTP auth alg | Value
+---------------------
+NULL | 0
+HMAC-SHA-1 | 1
+
+AKEYL - Auth key length
+
+SALTKEYL - master salt key length
+
+PRF
+
+SRTP PRF | Value
+---------------------
+AES-CM | 0
+
+DERRATE - key derivation rate
+
+SRTP_ENCR_ON_OFF - encryption on/off
+
+SRTCP_ENCR_ONOFF - SRTCP encryption on/off
+
+FEC_ORDER
+
+FEC order | Value | Comments
+--------------------------------
+FEC-SRTP | 0 | First FEC, then SRTP
+
+SRTP_AUTH_ON_OFF - SRTP authentication on/off
+
+SRTP_AUTH_TAGL - Authentication tag length
+
+SRTP_PREFIX - SRTP prefix length
+
+*/
+
+
+//
+// Local functions
+//
+
+static int message_to_base64(MRef<MikeyMessage *> msg, char *buf, size_t buflen)
+{
+ const string base64 = msg->b64Message();
+
+ if (buflen <= base64.size())
+ return -1;
+
+ strncpy(buf, base64.c_str(), buflen);
+// printf("message_to_base64 '%s'\n", buf);
+ return base64.size();
+}
+
+static int string_to_buf(const string &msg, char *buf, size_t buflen)
+{
+ if (buflen <= msg.size())
+ return -1;
+
+ strncpy(buf, msg.c_str(), buflen);
+// printf("message_to_base64 '%s'\n", buf);
+ return msg.size();
+}
+
+
+#define dump_var(name) printf("Var: %10s = %08x\n", #name, name);
+
+static void dump_hex(unsigned char *buf, size_t bufsize)
+{
+ int i;
+ size_t start_pos = 0;
+
+ while(start_pos < bufsize) {
+ size_t pos;
+
+ printf("%04x ", start_pos);
+
+ for (i = 0, pos = start_pos; i < 16 && pos < bufsize; i++,pos++) {
+ printf("%02x ", buf[pos]);
+ if (i == 7)
+ printf(" ");
+ }
+
+ printf(" ");
+
+ for (i = 0, pos = start_pos; i < 16 && pos < bufsize; i++,pos++) {
+ int c = buf[pos];
+
+ if (isalnum(c))
+ printf("%c", c);
+ else
+ printf(".");
+ }
+
+ printf("\n");
+ start_pos += 16;
+ }
+}
+
+static int getPolicyParamTypeValue(MikeyPayloadSP *policy, uint8_t type,
+ uint8_t *value)
+{
+ MikeyPolicyParam *param = policy->getParameterType(type);
+
+ if (param->length != 1)
+ return -1;
+
+ *value = param->value[0];
+ return 0;
+}
+
+static void dump_policy(MikeyPayloadSP *sp)
+{
+ int i;
+
+ for( i = 0; i < 20; i++ ){
+ MikeyPolicyParam* param = sp->getParameterType( i );
+
+ if( param ){
+ if( param->length == 1 )
+ cerr << (int)param->type << ": [byte] " << (int)param->value[0] << endl;
+ else
+ cerr << (int)param->type << ": [length] " << (int)param->length << endl;
+ }
+ }
+}
+
+// Check if offered policy is acceptable.
+static bool check_policy(MikeyPayloadSP *policy)
+{
+ unsigned int i;
+
+ printf("Check Policy %d\n", policy->policy_no);
+
+ dump_policy( policy );
+
+ if (policy->prot_type != MIKEY_PROTO_SRTP) {
+// *error = new MikeyMessage();
+// (*error)->addPayload(new MikeyPayloadERR(MIKEY_ERR_TYPE_INVALID_SP));
+ printf("Bad prot type %d\n", policy->prot_type);
+ return false;
+ }
+
+ // Predefined default SRTP parameter values
+ byte_t values[] = { MIKEY_SRTP_EALG_AESCM, MASTER_KEY_LEN,
+ MIKEY_SRTP_AALG_SHA1HMAC,
+ 20, MASTER_SALT_LEN, MIKEY_SRTP_PRF_AESCM, 0, 1, 1,
+ MIKEY_FEC_ORDER_FEC_SRTP, 1, 10, 0};
+
+ for (i = 0; i < sizeof(values)/sizeof(values[0]); i++) {
+ getPolicyParamTypeValue(policy, i, &values[i]);
+ }
+
+ if (values[MIKEY_SRTP_EALG] == MIKEY_SRTP_EALG_AESCM) {
+ if (values[MIKEY_SRTP_EKEYL] != MASTER_KEY_LEN) {
+ printf("Bad AES encryption key length\n");
+ return false;
+ }
+
+ if (values[MIKEY_SRTP_SALTKEYL] != MASTER_SALT_LEN) {
+ printf("Bad salt key length\n");
+ return false;
+ }
+ } else if (values[MIKEY_SRTP_EALG] == MIKEY_SRTP_EALG_NULL) {
+ if (values[MIKEY_SRTP_EKEYL] != 0) {
+ printf("Bad null encryption key length\n");
+ return false;
+ }
+ } else {
+ printf("Bad encryption alg\n");
+ return false;
+ }
+
+ if (values[MIKEY_SRTP_AALG] == MIKEY_SRTP_AALG_SHA1HMAC) {
+ if (values[MIKEY_SRTP_AKEYL] != 20) {
+ printf("Bad SHA1 auth key length\n");
+ return false;
+ }
+
+ if (values[MIKEY_SRTP_AUTH_TAGL] < 4) {
+ printf("Bad SHA1 auth tag length\n");
+ return false;
+ }
+ } else if (values[MIKEY_SRTP_AALG] == MIKEY_SRTP_AALG_NULL) {
+ if (values[MIKEY_SRTP_AKEYL] != 0) {
+ printf("Bad NULL auth key length\n");
+ return false;
+ }
+
+ if (values[MIKEY_SRTP_AUTH_TAGL] != 0) {
+ printf("Bad NULL auth tag length\n");
+ return false;
+ }
+ }
+
+ if (values[MIKEY_SRTP_PRF] != MIKEY_SRTP_PRF_AESCM) {
+ printf("Bad prf\n");
+ return false;
+ }
+
+ if (values[MIKEY_SRTP_KEY_DERRATE] != 0) {
+ printf("Bad key derivation rate\n");
+ return false;
+ }
+
+ if (values[MIKEY_SRTP_FEC_ORDER] != MIKEY_FEC_ORDER_FEC_SRTP) {
+ printf("Bad fec order\n");
+ return false;
+ }
+
+ if (values[MIKEY_SRTP_PREFIX] != 0) {
+ printf("Bad prefix length\n");
+ return false;
+ }
+
+ if (values[MIKEY_SRTP_ENCR_ON_OFF] != 1) {
+ printf("Bad encryption on/off\n");
+ return false;
+ }
+
+ printf("Policy %d ok\n", policy->policy_no);
+
+ return true;
+}
+
+// Check if all offered policies is acceptable.
+static bool check_policies(MRef<MikeyMessage *> msg)
+{
+ list<MRef<MikeyPayload *> >::iterator i;
+
+ for( i = msg->firstPayload(); i != msg->lastPayload(); i++ ) {
+ MikeyPayloadSP *sp = dynamic_cast<MikeyPayloadSP *>(**i);
+
+ if (sp) {
+ if (!check_policy(sp))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static void dump_crypto_params(MRef<KeyAgreement *> ka)
+{
+ uint32_t ssrc = 17;
+
+ cerr << "dump_crypto_params" << endl;
+
+ uint8_t csId = ka->getSrtpCsId(ssrc);
+ uint32_t roc = ka->getSrtpRoc(ssrc );
+ uint8_t policyNo = ka->findpolicyNo(ssrc);
+
+ uint8_t ealg = ka->getPolicyParamTypeValue(policyNo, MIKEY_PROTO_SRTP,
+ MIKEY_SRTP_EALG);
+ uint8_t ekeyl = ka->getPolicyParamTypeValue(policyNo, MIKEY_PROTO_SRTP,
+ MIKEY_SRTP_EKEYL);
+ uint8_t aalg = ka->getPolicyParamTypeValue(policyNo, MIKEY_PROTO_SRTP,
+ MIKEY_SRTP_AALG);
+ uint8_t akeyl = ka->getPolicyParamTypeValue(policyNo, MIKEY_PROTO_SRTP,
+ MIKEY_SRTP_AKEYL);
+ uint8_t skeyl = ka->getPolicyParamTypeValue(policyNo, MIKEY_PROTO_SRTP,
+ MIKEY_SRTP_SALTKEYL);
+ uint8_t prf = ka->getPolicyParamTypeValue(policyNo, MIKEY_PROTO_SRTP,
+ MIKEY_SRTP_PRF);
+ uint8_t keydr = ka->getPolicyParamTypeValue(policyNo, MIKEY_PROTO_SRTP,
+ MIKEY_SRTP_KEY_DERRATE);
[... 1290 lines stripped ...]
More information about the asterisk-commits
mailing list