libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-srtp.h File Reference

Go to the source code of this file.

Data Structures

struct  lws_srtp_ctx
 
struct  lws_srtp_ctx::lws_srtp_src_ctx
 

Macros

#define lws_srtp_protect   lws_srtp_protect_rtp
 

Enumerations

enum  lws_srtp_profiles { LWS_SRTP_PROFILE_AES128_CM_HMAC_SHA1_80 = 0x01 , LWS_SRTP_PROFILE_AES128_CM_HMAC_SHA1_32 = 0x02 }
 

Functions

LWS_VISIBLE LWS_EXTERN int lws_srtp_init (struct lws_srtp_ctx *ctx, enum lws_srtp_profiles profile, const uint8_t *master_key, const uint8_t *master_salt)
 
LWS_VISIBLE LWS_EXTERN int lws_srtp_protect_rtp (struct lws_srtp_ctx *ctx, uint8_t *pkt, size_t *len, size_t max_len)
 
LWS_VISIBLE LWS_EXTERN int lws_srtp_protect_rtcp (struct lws_srtp_ctx *ctx, uint8_t *pkt, size_t *len, size_t max_len)
 
LWS_VISIBLE LWS_EXTERN int lws_srtp_unprotect_rtp (struct lws_srtp_ctx *ctx, uint8_t *pkt, size_t *len)
 
LWS_VISIBLE LWS_EXTERN int lws_srtp_unprotect_rtcp (struct lws_srtp_ctx *ctx, uint8_t *pkt, size_t *len)
 

Data Structure Documentation

◆ lws_srtp_ctx

struct lws_srtp_ctx

Definition at line 33 of file lws-srtp.h.

+ Collaboration diagram for lws_srtp_ctx:
Data Fields
uint8_t master_key[16]
uint8_t master_salt[14]
uint8_t session_key[16]
uint8_t session_salt[14]
uint8_t session_auth[20]
uint8_t srtcp_session_key[16]
uint8_t srtcp_session_salt[14]
uint8_t srtcp_session_auth[20]
struct lws_srtp_src_ctx src[4]
uint32_t srtcp_index
enum lws_srtp_profiles profile
int keys_derived

◆ lws_srtp_ctx::lws_srtp_src_ctx

struct lws_srtp_ctx::lws_srtp_src_ctx

Definition at line 46 of file lws-srtp.h.

+ Collaboration diagram for lws_srtp_ctx::lws_srtp_src_ctx:
Data Fields
uint32_t ssrc
uint32_t roc
uint16_t last_seq
uint8_t any_packet_received

Macro Definition Documentation

◆ lws_srtp_protect

#define lws_srtp_protect   lws_srtp_protect_rtp

Definition at line 95 of file lws-srtp.h.

Enumeration Type Documentation

◆ lws_srtp_profiles

Enumerator
LWS_SRTP_PROFILE_AES128_CM_HMAC_SHA1_80 
LWS_SRTP_PROFILE_AES128_CM_HMAC_SHA1_32 

Definition at line 28 of file lws-srtp.h.

28 {
31};
@ LWS_SRTP_PROFILE_AES128_CM_HMAC_SHA1_32
Definition lws-srtp.h:30
@ LWS_SRTP_PROFILE_AES128_CM_HMAC_SHA1_80
Definition lws-srtp.h:29

Function Documentation

◆ lws_srtp_init()

LWS_VISIBLE LWS_EXTERN int lws_srtp_init ( struct lws_srtp_ctx * ctx,
enum lws_srtp_profiles profile,
const uint8_t * master_key,
const uint8_t * master_salt )

lws_srtp_init() - Initialize SRTP context

Parameters
ctxSRTP context
profileSRTP profile to use
master_key16-byte master key
master_salt14-byte master salt

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_srtp_protect_rtp()

LWS_VISIBLE LWS_EXTERN int lws_srtp_protect_rtp ( struct lws_srtp_ctx * ctx,
uint8_t * pkt,
size_t * len,
size_t max_len )

lws_srtp_protect() - Encrypt and authenticate RTP packet

Parameters
ctxSRTP context
pktRTP packet (header + payload), must have space for auth tag
lenPointer to packet length (updated on success)
max_lenMaximum size of pkt buffer

Returns 0 for OK or nonzero for error. lws_srtp_protect_rtp() - Encrypt and authenticate RTP packet

Parameters
ctxSRTP context
pktRTP packet (header + payload), must have space for auth tag
lenPointer to packet length (updated on success)
max_lenMaximum size of pkt buffer

Returns 0 for OK or nonzero for error. Note: lws_srtp_protect() is an alias for this.

◆ lws_srtp_protect_rtcp()

LWS_VISIBLE LWS_EXTERN int lws_srtp_protect_rtcp ( struct lws_srtp_ctx * ctx,
uint8_t * pkt,
size_t * len,
size_t max_len )

lws_srtp_protect_rtcp() - Encrypt and authenticate RTCP packet

Parameters
ctxSRTP context
pktRTCP packet (header + payload), must have space for index and tag
lenPointer to packet length (updated on success)
max_lenMaximum size of pkt buffer

Returns 0 for OK or nonzero for error.

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_srtp_unprotect_rtp()

LWS_VISIBLE LWS_EXTERN int lws_srtp_unprotect_rtp ( struct lws_srtp_ctx * ctx,
uint8_t * pkt,
size_t * len )

lws_srtp_unprotect_rtp() - Decrypt and authenticate RTP packet

Parameters
ctxSRTP context
pktProtected RTP packet (header + payload + tag)
lenPointer to packet length (updated on success to reflect decrypted payload)

Returns 0 for OK or nonzero for error.

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_srtp_unprotect_rtcp()

LWS_VISIBLE LWS_EXTERN int lws_srtp_unprotect_rtcp ( struct lws_srtp_ctx * ctx,
uint8_t * pkt,
size_t * len )

lws_srtp_unprotect_rtcp() - Decrypt and authenticate RTCP packet

Parameters
ctxSRTP context
pktProtected RTCP packet (header + payload + index/E + tag)
lenPointer to packet length (updated on success to reflect decrypted payload)

Returns 0 for OK or nonzero for error.