Skip to main content

Context

Struct Context 

Source
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

Source

pub fn decrypt_rtcp(&mut self, encrypted: &[u8]) -> Result<BytesMut>

DecryptRTCP decrypts a RTCP packet with an encrypted payload

Source

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

Source

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.

Source

pub fn decrypt_rtp(&mut self, encrypted: &[u8]) -> Result<BytesMut>

DecryptRTP decrypts a RTP packet with an encrypted payload

Source

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.

Source

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

Source

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.