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>
impl<'ibuf> EncryptedFrameView<'ibuf>
Sourcepub fn try_new<D>(data: &'ibuf D) -> Result<Self>
pub fn try_new<D>(data: &'ibuf D) -> Result<Self>
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
Sourcepub fn try_with_meta_data<D, M>(
data: &'ibuf D,
meta_data: &'ibuf M,
) -> Result<Self>
pub fn try_with_meta_data<D, M>( data: &'ibuf D, meta_data: &'ibuf M, ) -> Result<Self>
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
Sourcepub fn header(&self) -> &SframeHeader
pub fn header(&self) -> &SframeHeader
the header of the encrypted frame
Sourcepub fn cipher_text(&self) -> &[u8] ⓘ
pub fn cipher_text(&self) -> &[u8] ⓘ
the cipher text (Sframe Header + Encrypted Data + Authentication Tag) of the encrypted frame
Sourcepub fn validate<V>(self, validator: &V) -> Result<Self>where
V: FrameValidation + ?Sized,
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
Sourcepub fn decrypt(&self, key_store: &impl KeyStore) -> Result<MediaFrame>
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.
Sourcepub fn decrypt_into<'obuf>(
&self,
key_store: &impl KeyStore,
buffer: &'obuf mut impl FrameBuffer,
) -> Result<MediaFrameView<'obuf>>
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>
impl<'buf> Clone for EncryptedFrameView<'buf>
Source§fn clone(&self) -> EncryptedFrameView<'buf>
fn clone(&self) -> EncryptedFrameView<'buf>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more