Struct EncryptedFrameView

Source
pub struct EncryptedFrameView<'buf> { /* private fields */ }
Expand description

A view on a buffer which contains an encrypted frame in the format as of RFC 9605 4.2. The frame is assumed to be stored in the buffer as follows:

| Meta Data | Sframe Header | Encrypted Data | Auth Tag |

where the meta data is optional and can e.g. be a media header

Implementations§

Source§

impl<'ibuf> EncryptedFrameView<'ibuf>

Source

pub fn try_new<D>(data: &'ibuf D) -> Result<Self>
where D: AsRef<[u8]> + ?Sized,

Tries to create a new view on a buffer deserializing the contained SframeHeader. Fails with an crate::error::SframeError if the buffer/header is invalid

Source

pub fn try_with_meta_data<D, M>( data: &'ibuf D, meta_data: &'ibuf M, ) -> Result<Self>
where D: AsRef<[u8]> + ?Sized, M: AsRef<[u8]> + ?Sized,

Tries to create a new view on a buffer deserializing the contained SframeHeader. Associates the provided meta data with the frame. Fails with an crate::error::SframeError if the buffer is invalid

Source

pub fn header(&self) -> &SframeHeader

the header of the encrypted frame

Source

pub fn meta_data(&self) -> &[u8]

the associated meta data of the encrypted frame

Source

pub fn cipher_text(&self) -> &[u8]

the cipher text (Sframe Header + Encrypted Data + Authentication Tag) of the encrypted frame

Source

pub fn validate<V>(self, validator: &V) -> Result<Self>
where V: FrameValidation + ?Sized,

Validates the header of the encrypted frame Semantic sugar to allow chaining the validation with decryption returns an crate::error::SframeError when validation fails

Source

pub fn decrypt(&self, key_store: &impl KeyStore) -> Result<MediaFrame>

Tries to decrypt the encrypted frame with a key from the provided key store. As [DecryptionKey] implements KeyStore this can also be a single key. Dynamically allocates memory for the resulting MediaFrame returns an crate::error::SframeError if no matching key with the key id in this SframeHeader is available or if decryption has failed in general.

Source

pub fn decrypt_into<'obuf>( &self, key_store: &impl KeyStore, buffer: &'obuf mut impl FrameBuffer, ) -> Result<MediaFrameView<'obuf>>

Tries to decrypt the encrypted frame with a key from the provided key store and stores the result into the provided buffer. On success an MediaFrameView on the buffer is returned. As [DecryptionKey] implements KeyStore this can also be a single key. returns an crate::error::SframeError if no matching key with the key id in this SframeHeader is available or if decryption has failed in general.

Trait Implementations§

Source§

impl<'buf> Clone for EncryptedFrameView<'buf>

Source§

fn clone(&self) -> EncryptedFrameView<'buf>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'buf> Debug for EncryptedFrameView<'buf>

Source§

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

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

impl<'buf> TryFrom<&'buf [u8]> for EncryptedFrameView<'buf>

Source§

type Error = SframeError

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

fn try_from(data: &'buf [u8]) -> Result<Self>

Performs the conversion.
Source§

impl<'buf> TryFrom<&'buf Vec<u8>> for EncryptedFrameView<'buf>

Source§

type Error = SframeError

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

fn try_from(data: &'buf Vec<u8>) -> Result<Self>

Performs the conversion.
Source§

impl<'buf> Copy for EncryptedFrameView<'buf>

Auto Trait Implementations§

§

impl<'buf> Freeze for EncryptedFrameView<'buf>

§

impl<'buf> RefUnwindSafe for EncryptedFrameView<'buf>

§

impl<'buf> Send for EncryptedFrameView<'buf>

§

impl<'buf> Sync for EncryptedFrameView<'buf>

§

impl<'buf> Unpin for EncryptedFrameView<'buf>

§

impl<'buf> UnwindSafe for EncryptedFrameView<'buf>

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> 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, 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.