Skip to content
Snippets Groups Projects
Commit 1a3f251e authored by Aleix Conchillo Flaqué's avatar Aleix Conchillo Flaqué Committed by Josep Torra
Browse files

mikey: allow passing srtp or srtcp to create mikey message

Current implementation requires all srtp and srtcp parameters to be
given in the caps. MIKEY uses only one algorithm for encryption and one
for authentication so we now allow passing srtp or srtcp parameters. If
both are given srtp parametres will be preferred.

https://bugzilla.gnome.org/show_bug.cgi?id=765027
parent 5347403a
No related branches found
Tags gst-editing-services-1.7.2
No related merge requests found
......@@ -2204,6 +2204,7 @@ gst_mikey_message_new_from_caps (GstCaps * caps)
GstMapInfo info;
GstBuffer *srtpkey;
const GValue *val;
const gchar *cipher, *auth;
const gchar *srtpcipher, *srtpauth, *srtcpcipher, *srtcpauth;
g_return_val_if_fail (caps != NULL && GST_IS_CAPS (caps), NULL);
......@@ -2224,12 +2225,23 @@ gst_mikey_message_new_from_caps (GstCaps * caps)
srtcpcipher = gst_structure_get_string (s, "srtcp-cipher");
srtcpauth = gst_structure_get_string (s, "srtcp-auth");
if (srtpcipher == NULL || srtpauth == NULL || srtcpcipher == NULL ||
srtcpauth == NULL) {
/* we need srtp cipher/auth or srtcp cipher/auth */
if ((srtpcipher == NULL || srtpauth == NULL)
&& (srtcpcipher == NULL || srtcpauth == NULL)) {
GST_WARNING ("could not find the right SRTP parameters in caps");
return NULL;
}
/* prefer srtp cipher over srtcp */
cipher = srtpcipher;
if (cipher == NULL)
cipher = srtcpcipher;
/* prefer srtp auth over srtcp */
auth = srtpauth;
if (auth == NULL)
auth = srtcpauth;
msg = gst_mikey_message_new ();
/* unencrypted MIKEY message, we send this over TLS so this is allowed */
gst_mikey_message_set_info (msg, GST_MIKEY_VERSION, GST_MIKEY_TYPE_PSK_INIT,
......@@ -2248,14 +2260,14 @@ gst_mikey_message_new_from_caps (GstCaps * caps)
byte = 1;
gst_mikey_payload_sp_add_param (payload, GST_MIKEY_SP_SRTP_ENC_ALG, 1, &byte);
/* encryption key length */
byte = enc_key_length_from_cipher_name (srtpcipher);
byte = enc_key_length_from_cipher_name (cipher);
gst_mikey_payload_sp_add_param (payload, GST_MIKEY_SP_SRTP_ENC_KEY_LEN, 1,
&byte);
/* only HMAC-SHA1 */
gst_mikey_payload_sp_add_param (payload, GST_MIKEY_SP_SRTP_AUTH_ALG, 1,
&byte);
/* authentication key length */
byte = auth_key_length_from_auth_name (srtpauth);
byte = auth_key_length_from_auth_name (auth);
gst_mikey_payload_sp_add_param (payload, GST_MIKEY_SP_SRTP_AUTH_KEY_LEN, 1,
&byte);
/* we enable encryption on RTP and RTCP */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment