From c94c27cf8461e477b5a2acf01574ef9222485c64 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 18 Jun 2014 23:59:37 +0200 Subject: srtp: split srtp-module into 'srtp' and 'libsrtp' libre v0.4.9 has a very fast and robust SRTP-stack and we want to use it in baresip. however libsrtp is also working so we want to keep the module using libsrtp around for a while. two modules providing SDES-SRTP: - libsrtp.so -- SRTP using libsrtp - srtp.so -- Native SRTP-stack in libre --- modules/libsrtp/sdes.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 modules/libsrtp/sdes.c (limited to 'modules/libsrtp/sdes.c') diff --git a/modules/libsrtp/sdes.c b/modules/libsrtp/sdes.c new file mode 100644 index 0000000..a750432 --- /dev/null +++ b/modules/libsrtp/sdes.c @@ -0,0 +1,45 @@ +/** + * @file sdes.c SDP Security Descriptions for Media Streams (RFC 4568) + * + * Copyright (C) 2010 Creytiv.com + */ +#include +#include +#include "sdes.h" + + +const char sdp_attr_crypto[] = "crypto"; + + +int sdes_encode_crypto(struct sdp_media *m, uint32_t tag, const char *suite, + const char *key, size_t key_len) +{ + return sdp_media_set_lattr(m, true, sdp_attr_crypto, "%u %s inline:%b", + tag, suite, key, key_len); +} + + +/* http://tools.ietf.org/html/rfc4568 + * a=crypto: [] + */ +int sdes_decode_crypto(struct crypto *c, const char *val) +{ + struct pl tag, key_prms; + int err; + + err = re_regex(val, str_len(val), "[0-9]+ [^ ]+ [^ ]+[]*[^]*", + &tag, &c->suite, &key_prms, NULL, &c->sess_prms); + if (err) + return err; + + c->tag = pl_u32(&tag); + + c->lifetime = c->mki = pl_null; + err = re_regex(key_prms.p, key_prms.l, "[^:]+:[^|]+[|]*[^|]*[|]*[^|]*", + &c->key_method, &c->key_info, + NULL, &c->lifetime, NULL, &c->mki); + if (err) + return err; + + return 0; +} -- cgit v1.2.3