Skip to main content

MessageIntegrity

Struct MessageIntegrity 

Source
pub struct MessageIntegrity<'a> { /* private fields */ }
Expand description

The MESSAGE-INTEGRITY key: an HMAC-SHA1 is computed over the message with it.

Built from a short-term password, or from a long-term username/realm/password triple.

Implementations§

Source§

impl<'a> MessageIntegrity<'a>

Source

pub fn new_raw_integrity_with_provider( key: impl Into<Vec<u8>>, crypto: &'a dyn RTCCrypto, ) -> Self

Creates a raw-key integrity attribute with an explicit crypto provider.

Source

pub fn new_short_term_integrity_with_provider( password: String, crypto: &'a dyn RTCCrypto, ) -> Self

Creates a short-term integrity attribute with an explicit crypto provider.

The password’s bytes are the key as they are: it must already be OpaqueString-processed (RFC 8489 section 9.1.1). That holds for every ICE password, which is ASCII by its grammar; for a password of any other origin use short_term.

Source

pub fn short_term(password: &str, crypto: &'a dyn RTCCrypto) -> Result<Self>

Creates a short-term integrity attribute: key = OpaqueString(password) (RFC 8489 section 9.1.1).

§Errors

Fails for a password OpaqueString does not allow (RFC 8265 section 4.2).

Source

pub fn new_long_term_integrity_with_provider( username: String, realm: String, password: String, crypto: &'a dyn RTCCrypto, ) -> Result<Self>

Creates a long-term integrity attribute with an explicit crypto provider, with the MD5 key of RFC 8489 section 9.2.2 (realm and password OpaqueString-processed).

Source

pub fn long_term_integrity_key( username: String, realm: String, password: String, crypto: &'a dyn RTCCrypto, ) -> Result<Vec<u8>>

Creates a long-term integrity key with an explicit crypto provider: the MD5 key of RFC 8489 section 9.2.2. long_term_key takes the password algorithm.

Source

pub fn check(m: &mut Message, key: &[u8], crypto: &dyn RTCCrypto) -> Result<()>

Check checks MESSAGE-INTEGRITY attribute: the first one in m, over the message up to it. Attributes after it are not covered, whatever they are.

A receiver that goes on to read the message uses Validator instead, which runs this check and then exposes only the attributes it covers (RFC 8489 section 9).

CPU costly, see BenchmarkMessageIntegrity_Check.

Trait Implementations§

Source§

impl<'a> Clone for MessageIntegrity<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Display for MessageIntegrity<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Setter for MessageIntegrity<'a>

Source§

fn add_to(&self, m: &mut Message) -> Result<()>

Encodes this value into m as an attribute. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for MessageIntegrity<'a>

§

impl<'a> !UnwindSafe for MessageIntegrity<'a>

§

impl<'a> Forget for MessageIntegrity<'a>

§

impl<'a> Freeze for MessageIntegrity<'a>
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, &'a dyn RTCCrypto: Freeze,

§

impl<'a> Move for MessageIntegrity<'a>

§

impl<'a> Send for MessageIntegrity<'a>
where RawVecInner: Send, &'a dyn RTCCrypto: Send,

§

impl<'a> Sync for MessageIntegrity<'a>
where RawVecInner: Sync,

§

impl<'a> Unpin for MessageIntegrity<'a>
where *const u8 is !null: Unpin, &'a dyn RTCCrypto: Unpin,

§

impl<'a> UnsafeUnpin for MessageIntegrity<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.