Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
feat(rtc_tenclave::dh::sealing): add rkyv_peek_associated helper
Browse files Browse the repository at this point in the history
  • Loading branch information
PiDelport committed Jun 17, 2021
1 parent 0d3cb55 commit a1c25ab
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions rtc_tenclave/src/dh/sealing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ where
Ok(unsealed)
}

/// Peek at a sealed message's associated data, without authenticating it.
///
/// # Safety
///
/// Callers must ensure that the sealed message contains valid serialized data,
/// to avoid undefined behaviour during deserialization.
///
/// See: [`rkyv_format::view_array`]
pub unsafe fn rkyv_peek_associated<T, A>(
sealed: &EncryptedEnclaveMessage<{ size_of::<T::Archived>() }, { size_of::<A::Archived>() }>,
) -> &A::Archived
where
T: Archive,
T::Archived: Deserialize<T, Infallible>,
A: Archive,
A::Archived: Deserialize<A, Infallible>,
{
unsafe { rkyv_format::view_array::<A>(&sealed.aad) }
}

#[derive(Debug)]
pub enum SealingError {
Rkyv(BufferSerializerError),
Expand Down

0 comments on commit a1c25ab

Please sign in to comment.