Struct fog_crypto::lock::LockKey [−][src]
A key that allows decrypting data meant for a particular LockId
.
This acts as a wrapper for a specific cryptographic private decryption key,
Example
// Make a new temporary key let mut csprng = rand::rngs::OsRng {}; let key = LockKey::new_temp(&mut csprng); let id = key.id().clone(); println!("LockId(Base58): {}", key.id()); // ... // Wait for encrypted data to show up // ... // Decrypt Some received data let lockbox = DataLockboxRef::from_bytes(received.as_ref())?; let data = key.decrypt_data(&lockbox)?;
Implementations
impl LockKey
[src]
pub fn new_temp<R>(csprng: &mut R) -> LockKey where
R: CryptoRng + RngCore,
[src]
R: CryptoRng + RngCore,
Generate a temporary LockKey
that exists only in program memory.
pub fn new_temp_with_version<R>(
csprng: &mut R,
version: u8
) -> Result<LockKey, CryptoError> where
R: CryptoRng + RngCore,
[src]
csprng: &mut R,
version: u8
) -> Result<LockKey, CryptoError> where
R: CryptoRng + RngCore,
Generate a temporary LockKey
that exists only in program memory. Uses the specified
version instead of the default, and fails if the version is unsupported.
pub fn version(&self) -> u8
[src]
Version of Diffie-Hellman key exchange algorithm used by this key.
pub fn id(&self) -> &LockId
[src]
The public identifier for this key.
pub fn decrypt_lock_key(
&self,
lockbox: &LockLockboxRef
) -> Result<LockKey, CryptoError>
[src]
&self,
lockbox: &LockLockboxRef
) -> Result<LockKey, CryptoError>
Attempt to decrypt a LockLockboxRef
with this key. On success, the returned LockKey
is
temporary and not associated with any Vault.
pub fn decrypt_identity_key(
&self,
lockbox: &IdentityLockboxRef
) -> Result<IdentityKey, CryptoError>
[src]
&self,
lockbox: &IdentityLockboxRef
) -> Result<IdentityKey, CryptoError>
Attempt to decrypt a IdentityLockboxRef
with this key. On success, the returned
IdentityKey
is temporary and not associated with any Vault.
pub fn decrypt_stream_key(
&self,
lockbox: &StreamLockboxRef
) -> Result<StreamKey, CryptoError>
[src]
&self,
lockbox: &StreamLockboxRef
) -> Result<StreamKey, CryptoError>
Attempt to decrypt a StreamLockboxRef
with this key. On success, the returned
StreamKey
is temporary and not associated with any Vault.
pub fn decrypt_data(
&self,
lockbox: &DataLockboxRef
) -> Result<Vec<u8>, CryptoError>
[src]
&self,
lockbox: &DataLockboxRef
) -> Result<Vec<u8>, CryptoError>
Attempt to decrypt a DataLockboxRef
with this key.
pub fn export_for_lock<R: CryptoRng + RngCore>(
&self,
csprng: &mut R,
lock: &LockId
) -> Option<LockLockbox>
[src]
&self,
csprng: &mut R,
lock: &LockId
) -> Option<LockLockbox>
Export the signing key in an LockLockbox
, with receive_lock
as the recipient. If
the key cannot be exported, this should return None.
pub fn export_for_stream<R: CryptoRng + RngCore>(
&self,
csprng: &mut R,
stream: &StreamKey
) -> Option<LockLockbox>
[src]
&self,
csprng: &mut R,
stream: &StreamKey
) -> Option<LockLockbox>
Export the private key in a LockLockbox
, with receive_stream
as the recipient. If
the key cannot be exported, this should return None. Additionally, if the underlying
implementation does not allow moving the raw key into memory (i.e. it cannot call
StreamInterface::encrypt
or
lock_id_encrypt
) then None can also be returned.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for LockKey
[src]
impl !Send for LockKey
[src]
impl !Sync for LockKey
[src]
impl Unpin for LockKey
[src]
impl !UnwindSafe for LockKey
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,