diff options
author | Alfred E. Heggestad <aeh@db.org> | 2014-06-18 23:59:37 +0200 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2014-06-18 23:59:37 +0200 |
commit | c94c27cf8461e477b5a2acf01574ef9222485c64 (patch) | |
tree | 31999dd249129b074fd1495e143ffb6c65bef84c /modules/libsrtp/sdes.c | |
parent | 5b5eb4e1000ab9f941904a2b9cdae2965f880d89 (diff) |
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
Diffstat (limited to 'modules/libsrtp/sdes.c')
-rw-r--r-- | modules/libsrtp/sdes.c | 45 |
1 files changed, 45 insertions, 0 deletions
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 <re.h> +#include <baresip.h> +#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:<tag> <crypto-suite> <key-params> [<session-params>] + */ +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; +} |