Struct bdrck::crypto::wrap::WrappedKey
source · pub struct WrappedKey { /* private fields */ }
Expand description
A wrapped key is an AbstractKey
which has been wrapped (encrypted) with another AbstractKey
.
This is useful because it lets us have e.g. a single “master key” which is wrapped by several
sub-keys, which can be added / removed at will without having to actually re-encrypt all of the
data encrypted with the “master key”.
Implementations§
source§impl WrappedKey
impl WrappedKey
sourcepub fn wrap<KA: AbstractKey, KB: AbstractKey>(
to_wrap: &KA,
wrap_with: &KB
) -> Result<Self>
pub fn wrap<KA: AbstractKey, KB: AbstractKey>( to_wrap: &KA, wrap_with: &KB ) -> Result<Self>
Wrap the key to_wrap
with the key wrap_with
used for encryption.
sourcepub fn unwrap<KA: AbstractKey, KB: AbstractKey>(
&self,
wrapped_with: &KB
) -> Result<KA>
pub fn unwrap<KA: AbstractKey, KB: AbstractKey>( &self, wrapped_with: &KB ) -> Result<KA>
Unwrap the previously wrapped key this structure represents. This basically decrypts and then deserializes the underlying key data, returning the newly constructed key.
sourcepub fn get_digest(&self) -> Digest
pub fn get_digest(&self) -> Digest
Return a digest/signature computed from the encrypted key data.
sourcepub fn get_wrapping_digest(&self) -> &Digest
pub fn get_wrapping_digest(&self) -> &Digest
Return the digest/signature of the outermost key used to wrap this key.
Trait Implementations§
source§impl<'de> Deserialize<'de> for WrappedKey
impl<'de> Deserialize<'de> for WrappedKey
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for WrappedKey
impl Send for WrappedKey
impl Sync for WrappedKey
impl Unpin for WrappedKey
impl UnwindSafe for WrappedKey
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
Mutably borrows from an owned value. Read more