Go to the documentation of this file.
21 # define LIBVLC_SRTP_H 1
68 const void *salt,
size_t saltlen);
void(* header)(demux_t *, void *, block_t *)
Definition: rtp.h:33
void srtp_setrcc_rate(srtp_session_t *s, uint16_t rate)
Sets Roll-over-Counter Carry (RCC) rate for the SRTP session.
Definition: srtp.c:384
#define GetDWBE(p)
Definition: vlc_common.h:1014
vlc_tick_t last_rx
Definition: session.c:142
int srtp_setkeystring(srtp_session_t *s, const char *key, const char *salt)
Sets (or resets) the master key and master salt for a SRTP session from hexadecimal strings.
Definition: srtp.c:352
uint32_t frequency
Definition: rtp.h:35
static void block_ChainRelease(block_t *p_block)
Definition: vlc_block.h:358
unsigned srcc
Definition: session.c:42
@ SRTCP_UNENCRYPTED
Definition: srtp.h:28
static void proto_destroy(srtp_proto_t *p)
Definition: srtp.c:88
gcry_cipher_hd_t cipher
Definition: srtp.c:52
int srtcp_recv(srtp_session_t *s, uint8_t *buf, size_t *lenp)
Turns a SRTCP packet into a RTCP packet: authenticates the packet, then decrypts it.
Definition: srtp.c:821
rtp_source_t ** srcv
Definition: session.c:41
static uint32_t rtp_timestamp(const block_t *block)
Definition: session.c:207
static void no_destroy(demux_t *demux, void *opaque)
Definition: session.c:94
void srtp_destroy(srtp_session_t *s)
Releases all resources associated with a Secure RTP session.
Definition: srtp.c:98
srtp_session_t * srtp_create(int encr, int auth, unsigned tag_len, int prf, unsigned flags)
Allocates a Secure RTP one-way session.
Definition: srtp.c:134
srtp_proto_t rtcp
Definition: srtp.c:61
size_t i_buffer
Payload length.
Definition: vlc_block.h:122
@ SRTP_ENCR_AES_F8
Definition: srtp.h:43
static ssize_t hexstring(const char *in, uint8_t *out, size_t outlen)
Definition: srtp.c:327
void rtp_session_destroy(demux_t *demux, rtp_session_t *session)
Destroys an RTP session.
Definition: session.c:77
static uint16_t rtp_seq(const uint8_t *buf)
Returns RTP sequence (in host-byte order)
Definition: srtp.c:431
uint16_t max_seq
Definition: session.c:149
static vlc_tick_t vlc_tick_from_samples(int64_t samples, int samp_rate)
Definition: vlc_tick.h:101
uint32_t ref_rtp
Definition: session.c:145
static const uint8_t * rtcp_digest(gcry_md_hd_t md, const void *data, size_t len)
Message Authentication and Integrity for RTCP.
Definition: srtp.c:700
gcry_md_hd_t mac
Definition: srtp.c:53
@ SRTP_ENCR_AES_CM
Definition: srtp.h:42
@ SRTP_UNAUTHENTICATED
Definition: srtp.h:29
static int proto_create(srtp_proto_t *p, int gcipher, int gmd)
Definition: srtp.c:108
static int do_derive(gcry_cipher_hd_t prf, const void *salt, const uint8_t *r, size_t rlen, uint8_t label, void *out, size_t outlen)
AES-CM key derivation (saltlen = 14 bytes)
Definition: srtp.c:236
@ SRTP_ENCR_NULL
Definition: srtp.h:41
struct srtp_proto_t srtp_proto_t
LARGE_INTEGER freq
Definition: thread.c:556
vlc_tick_t ref_ntp
Definition: session.c:146
#define msg_Dbg(p_this,...)
Definition: vlc_messages.h:106
void srtp_destroy(srtp_session_t *s)
Releases all resources associated with a Secure RTP session.
Definition: srtp.c:98
int srtp_setkey(srtp_session_t *s, const void *key, size_t keylen, const void *salt, size_t saltlen)
Sets (or resets) the master key and master salt for a SRTP session.
Definition: srtp.c:266
static int rtcp_crypt(gcry_cipher_hd_t hd, uint32_t ssrc, uint32_t index, const uint32_t *salt, uint8_t *data, size_t len)
AES-CM for RTCP (salt = 14 bytes + 2 nul bytes)
Definition: srtp.c:691
int srtp_recv(srtp_session_t *s, uint8_t *buf, size_t *lenp)
Turns a SRTP packet into a RTP packet: authenticates the packet, then decrypts it.
Definition: srtp.c:623
static void srtp_test(void)
Definition: srtp-test-aes.c:144
@ SRTP_RCC_MODE3
Definition: srtp.h:33
@ SRTP_AUTH
Definition: srtp.c:74
int srtcp_send(srtp_session_t *s, uint8_t *buf, size_t *lenp, size_t bufsize)
Turns a RTCP packet into a SRTCP packet: encrypt it, then computes the authentication tag and appends...
Definition: srtp.c:781
uint16_t max_misorder
Max packet backward misordering.
Definition: rtp.h:76
static rtp_source_t * rtp_source_create(demux_t *, const rtp_session_t *, uint32_t, uint16_t)
Initializes a new RTP source within an RTP session.
Definition: session.c:160
uint16_t rtp_seq
Definition: srtp.c:66
srtp_proto_t rtp
Definition: srtp.c:60
#define msg_Warn(p_this,...)
Definition: vlc_messages.h:104
static void * no_init(demux_t *demux)
Definition: session.c:88
int srtp_setkey(srtp_session_t *s, const void *key, size_t keylen, const void *salt, size_t saltlen)
Sets (or resets) the master key and master salt for a SRTP session.
Definition: srtp.c:266
static int do_ctr_crypt(gcry_cipher_hd_t hd, const void *ctr, uint8_t *data, size_t len)
Counter Mode encryption/decryption (ctr length = 16 bytes) with non-padded (truncated) text.
Definition: srtp.c:206
static void printhex(const void *buf, size_t len)
Definition: srtp-test-aes.c:23
static unsigned rcc_mode(const srtp_session_t *s)
Definition: srtp.c:82
block_t * p_next
Definition: vlc_block.h:119
uint32_t ssrc
Definition: session.c:140
static void test_derivation(void)
AES-CM key derivation test vectors.
Definition: srtp-test-aes.c:37
block_t * blocks
Definition: session.c:152
vlc_tick_t vlc_tick_now(void)
Precision monotonic clock.
Definition: thread.c:261
vlc_tick_t timeout
Definition: rtp.h:74
static uint16_t rtp_seq(const block_t *block)
Definition: session.c:201
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45
static void fatal(const char *msg)
Definition: srtp-test-aes.c:30
uint32_t i_flags
Definition: vlc_block.h:126
int srtcp_send(srtp_session_t *s, uint8_t *buf, size_t *lenp, size_t maxsiz)
Turns a RTCP packet into a SRTCP packet: encrypt it, then computes the authentication tag and appends...
Definition: srtp.c:781
static int hexdigit(char c)
Definition: srtp.c:316
uint8_t ptc
Definition: session.c:43
static void rtp_source_destroy(demux_t *, const rtp_session_t *, rtp_source_t *)
Destroys an RTP source and its associated streams.
Definition: session.c:190
static const uint8_t * rtp_digest(gcry_md_hd_t md, const uint8_t *data, size_t len, uint32_t roc)
Message Authentication and Integrity for RTP.
Definition: srtp.c:439
static int srtcp_crypt(srtp_session_t *s, uint8_t *buf, size_t len)
Encrypts/decrypts a RTCP packet and updates SRTCP context (CTR block cypher mode of operation has ide...
Definition: srtp.c:719
uint32_t salt[4]
Definition: srtp.c:55
@ SRTCP_AUTH
Definition: srtp.c:77
State for a RTP session:
Definition: session.c:39
static void rtp_decode(demux_t *, const rtp_session_t *, rtp_source_t *)
Decodes one RTP packet.
Definition: session.c:468
void * opaque[]
Definition: session.c:153
static int srtp_crypt(srtp_session_t *s, uint8_t *buf, size_t len)
Encrypts/decrypts a RTP packet and updates SRTP context (CTR block cypher mode of operation has ident...
Definition: srtp.c:461
void *(* init)(demux_t *)
Definition: rtp.h:31
stream_t definition
Definition: vlc_stream.h:46
vlc_tick_t i_pts
Definition: vlc_block.h:129
uint64_t window
Definition: srtp.c:54
uint16_t rtp_rcc
Definition: srtp.c:67
@ SRTP_FLAGS_MASK
Definition: srtp.h:35
@ SRTP_UNENCRYPTED
Definition: srtp.h:27
uint32_t rtcp_index
Definition: srtp.c:64
@ SRTP_RCC_MODE2
Definition: srtp.h:32
static const struct rtp_pt_t * rtp_find_ptype(const rtp_session_t *session, rtp_source_t *source, const block_t *block, void **pt_data)
Definition: session.c:214
bool rtp_dequeue(demux_t *demux, const rtp_session_t *session, vlc_tick_t *restrict deadlinep)
Dequeues RTP packets and pass them to decoder.
Definition: session.c:393
@ SRTCP_CRYPT
Definition: srtp.c:76
static int rtp_crypt(gcry_cipher_hd_t hd, uint32_t ssrc, uint32_t roc, uint16_t seq, const uint32_t *salt, uint8_t *data, size_t len)
AES-CM for RTP (salt = 14 bytes + 2 nul bytes)
Definition: srtp.c:393
srtp_session_t * srtp_create(int encr, int auth, unsigned tag_len, int prf, unsigned flags)
Allocates a Secure RTP one-way session.
Definition: srtp.c:134
RTP demux module shared declarations.
void(* decode)(demux_t *, void *, block_t *)
Definition: rtp.h:34
unsigned flags
Definition: srtp.c:62
@ SRTP_PRF_AES_CM
Definition: srtp.h:56
static int64_t samples_from_vlc_tick(vlc_tick_t t, int samp_rate)
Definition: vlc_tick.h:105
State for an RTP source.
Definition: session.c:138
#define VLC_TICK_FROM_MS(ms)
Definition: vlc_tick.h:122
#define GetWBE(p)
Definition: vlc_common.h:1013
uint16_t last_seq
Definition: session.c:151
uint8_t tag_len
Definition: srtp.c:68
@ SRTCP_SALT
Definition: srtp.c:78
int main(void)
Definition: srtp-test-recv.c:36
uint32_t jitter
Definition: session.c:141
int srtp_send(srtp_session_t *s, uint8_t *buf, size_t *lenp, size_t maxsize)
Turns a RTP packet into a SRTP packet: encrypt it, then computes the authentication tag and appends i...
Definition: srtp.c:540
int srtp_recv(srtp_session_t *s, uint8_t *buf, size_t *lenp)
Turns a SRTP packet into a RTP packet: authenticates the packet, then decrypts it.
Definition: srtp.c:623
@ SRTP_CRYPT
Definition: srtp.c:73
uint32_t rtp_roc
Definition: srtp.c:65
unsigned kdr
Definition: srtp.c:63
@ SRTP_SALT
Definition: srtp.c:75
uint8_t * p_buffer
Payload start.
Definition: vlc_block.h:121
int srtp_send(srtp_session_t *s, uint8_t *buf, size_t *lenp, size_t bufsize)
Turns a RTP packet into a SRTP packet: encrypt it, then computes the authentication tag and appends i...
Definition: srtp.c:540
rtp_session_t * rtp_session_create(demux_t *demux)
Creates a new RTP session.
Definition: session.c:58
void(* destroy)(demux_t *, void *)
Definition: rtp.h:32
rtp_pt_t * ptv
Definition: session.c:44
uint8_t number
Definition: rtp.h:36
static uint8_t rtp_ptype(const block_t *block)
Definition: rtp.h:40
@ SRTP_AUTH_NULL
Definition: srtp.h:49
static void test_keystream(void)
AES-CM key derivation test vectors.
Definition: srtp-test-aes.c:95
static uint32_t srtp_compute_roc(const srtp_session_t *s, uint16_t seq)
Determines SRTP Roll-Over-Counter (in host-byte order)
Definition: srtp.c:410
#define BLOCK_FLAG_DISCONTINUITY
The content doesn't follow the last block, possible some blocks in between have been lost.
Definition: vlc_block.h:67
@ SRTP_RCC_MODE1
Definition: srtp.h:31
int rtp_add_type(demux_t *demux, rtp_session_t *ses, const rtp_pt_t *pt)
Adds a payload type to an RTP session.
Definition: session.c:108
@ SRTP_AUTH_HMAC_SHA1
Definition: srtp.h:50
void block_Release(block_t *block)
Releases a block.
Definition: block.c:135
static void no_decode(demux_t *demux, void *opaque, block_t *block)
Definition: session.c:99
uint8_t max_src
Max simultaneous RTP sources.
Definition: rtp.h:77
void * p_sys
Private data pointer.
Definition: vlc_stream.h:138
Definition: vlc_block.h:117
#define msg_Err(p_this,...)
Definition: vlc_messages.h:102
uint32_t last_ts
Definition: session.c:143
void rtp_queue(demux_t *demux, rtp_session_t *session, block_t *block)
Receives an RTP packet and queues it.
Definition: session.c:239
int srtcp_recv(srtp_session_t *s, uint8_t *buf, size_t *lenp)
Turns a SRTCP packet into a RTCP packet: authenticates the packet, then decrypts it.
Definition: srtp.c:821
void srtp_setrcc_rate(srtp_session_t *s, uint16_t rate)
Sets Roll-over-Counter Carry (RCC) rate for the SRTP session.
Definition: srtp.c:384
uint16_t bad_seq
Definition: session.c:148
int main(void)
Definition: srtp-test-aes.c:150
uint16_t max_dropout
Max packet forward misordering.
Definition: rtp.h:75
int srtp_setkeystring(srtp_session_t *s, const char *key, const char *salt)
Sets (or resets) the master key and master salt for a SRTP session from hexadecimal strings.
Definition: srtp.c:352