pub struct Context { /* private fields */ }Expand description
Context represents a SRTP cryptographic context Context can only be used for one-way operations it must either used ONLY for encryption or ONLY for decryption
Implementations§
Source§impl Context
impl Context
Sourcepub fn decrypt_rtcp(&mut self, encrypted: &[u8]) -> Result<BytesMut>
pub fn decrypt_rtcp(&mut self, encrypted: &[u8]) -> Result<BytesMut>
DecryptRTCP decrypts a RTCP packet with an encrypted payload
Sourcepub fn encrypt_rtcp(&mut self, decrypted: &[u8]) -> Result<BytesMut>
pub fn encrypt_rtcp(&mut self, decrypted: &[u8]) -> Result<BytesMut>
EncryptRTCP marshals and encrypts an RTCP packet, writing to the dst buffer provided.
If the dst buffer does not have the capacity to hold len(plaintext) + 14 bytes, a new one will be allocated and returned.
Source§impl Context
impl Context
Sourcepub fn decrypt_rtp_with_header(
&mut self,
encrypted: &[u8],
header: &Header,
) -> Result<BytesMut>
pub fn decrypt_rtp_with_header( &mut self, encrypted: &[u8], header: &Header, ) -> Result<BytesMut>
Decrypts an SRTP packet whose header has already been parsed.
Saves re-parsing when the caller needed the header to route the packet. The header must
be the one belonging to encrypted.
§Errors
Fails if authentication fails, if the packet is a replay, or if it is too short to hold the profile’s auth tag.
Sourcepub fn decrypt_rtp(&mut self, encrypted: &[u8]) -> Result<BytesMut>
pub fn decrypt_rtp(&mut self, encrypted: &[u8]) -> Result<BytesMut>
DecryptRTP decrypts a RTP packet with an encrypted payload
Sourcepub fn encrypt_rtp_with_header(
&mut self,
plaintext: &[u8],
header: &Header,
) -> Result<BytesMut>
pub fn encrypt_rtp_with_header( &mut self, plaintext: &[u8], header: &Header, ) -> Result<BytesMut>
Encrypts an RTP payload, using an already-parsed header.
Saves re-parsing when the caller has just built the header. Returns the full protected packet, header included.
§Errors
Fails if the SRTP context has no key for this SSRC or the cipher rejects the input.
Sourcepub fn encrypt_rtp(&mut self, plaintext: &[u8]) -> Result<BytesMut>
pub fn encrypt_rtp(&mut self, plaintext: &[u8]) -> Result<BytesMut>
EncryptRTP marshals and encrypts an RTP packet, writing to the dst buffer provided.
If the dst buffer does not have the capacity to hold len(plaintext) + 10 bytes, a new one will be allocated and returned.
Source§impl Context
impl Context
Sourcepub fn new(
master_key: &[u8],
master_salt: &[u8],
profile: ProtectionProfile,
srtp_ctx_opt: Option<ContextOption>,
srtcp_ctx_opt: Option<ContextOption>,
) -> Result<Context>
pub fn new( master_key: &[u8], master_salt: &[u8], profile: ProtectionProfile, srtp_ctx_opt: Option<ContextOption>, srtcp_ctx_opt: Option<ContextOption>, ) -> Result<Context>
CreateContext creates a new SRTP Context