pub struct DataEnvelope { /* private fields */ }Expand description
DataEnvelope allows sealing structs entire structs to encrypted blobs.
Sealing a struct results in an encrypted blob, and a content-encryption-key. The content-encryption-key must be provided again when unsealing the data. A content encryption key allows easy key-rotation of the encrypting-key, as now just the content-encryption-keys need to be re-uploaded, instead of all data.
The content-encryption-key cannot be re-used for encrypting other data.
Note: This is explicitly meant for structured data, not large binary blobs (files).
Implementations§
Source§impl DataEnvelope
impl DataEnvelope
Sourcepub fn seal<Ids: KeySlotIds, T>(
data: T,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<(Self, Ids::Symmetric), DataEnvelopeError>where
T: Serialize + SealableVersionedData,
pub fn seal<Ids: KeySlotIds, T>(
data: T,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<(Self, Ids::Symmetric), DataEnvelopeError>where
T: Serialize + SealableVersionedData,
Seals a struct into an encrypted blob, and stores the content-encryption-key in the provided context.
Sourcepub fn seal_with_wrapping_key<Ids: KeySlotIds, T>(
data: T,
wrapping_key: &Ids::Symmetric,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<(Self, EncString), DataEnvelopeError>where
T: Serialize + SealableVersionedData,
pub fn seal_with_wrapping_key<Ids: KeySlotIds, T>(
data: T,
wrapping_key: &Ids::Symmetric,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<(Self, EncString), DataEnvelopeError>where
T: Serialize + SealableVersionedData,
Seals a struct into an encrypted blob. The content encryption key is wrapped with the provided wrapping key
Sourcepub fn unseal<Ids: KeySlotIds, T>(
&self,
cek_keyslot: Ids::Symmetric,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<T, DataEnvelopeError>where
T: DeserializeOwned + SealableVersionedData,
pub fn unseal<Ids: KeySlotIds, T>(
&self,
cek_keyslot: Ids::Symmetric,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<T, DataEnvelopeError>where
T: DeserializeOwned + SealableVersionedData,
Unseals the data from the encrypted blob using a content-encryption-key stored in the context.
Sourcepub fn unseal_with_wrapping_key<Ids: KeySlotIds, T>(
&self,
wrapping_key: &Ids::Symmetric,
wrapped_cek: &EncString,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<T, DataEnvelopeError>where
T: DeserializeOwned + SealableVersionedData,
pub fn unseal_with_wrapping_key<Ids: KeySlotIds, T>(
&self,
wrapping_key: &Ids::Symmetric,
wrapped_cek: &EncString,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<T, DataEnvelopeError>where
T: DeserializeOwned + SealableVersionedData,
Unseals the data from the encrypted blob and wrapped content-encryption-key.
Trait Implementations§
Source§impl Clone for DataEnvelope
impl Clone for DataEnvelope
Source§fn clone(&self) -> DataEnvelope
fn clone(&self) -> DataEnvelope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DataEnvelope
impl Debug for DataEnvelope
Source§impl<'de> Deserialize<'de> for DataEnvelope
impl<'de> Deserialize<'de> for DataEnvelope
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for DataEnvelope
impl Display for DataEnvelope
Source§impl From<&DataEnvelope> for Vec<u8>
impl From<&DataEnvelope> for Vec<u8>
Source§fn from(val: &DataEnvelope) -> Self
fn from(val: &DataEnvelope) -> Self
Source§impl From<DataEnvelope> for String
impl From<DataEnvelope> for String
Source§fn from(val: DataEnvelope) -> Self
fn from(val: DataEnvelope) -> Self
Source§impl FromStr for DataEnvelope
impl FromStr for DataEnvelope
Auto Trait Implementations§
impl Freeze for DataEnvelope
impl RefUnwindSafe for DataEnvelope
impl Send for DataEnvelope
impl Sync for DataEnvelope
impl Unpin for DataEnvelope
impl UnsafeUnpin for DataEnvelope
impl UnwindSafe for DataEnvelope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.