Struct fog_crypto::lock::LockKey[][src]

pub struct LockKey { /* fields omitted */ }

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]

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]

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]

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]

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]

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]

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]

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]

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

impl Clone for LockKey[src]

impl Debug for LockKey[src]

impl Display for LockKey[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Display just the LockId (never the underlying key).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,