pub trait IsContext {
Show 15 methods
// Required methods
fn encrypt(
&mut self,
recipients: &Recipients,
plaintext: Plaintext,
) -> Result<Ciphertext>;
fn decrypt(&mut self, ciphertext: Ciphertext) -> Result<Plaintext>;
fn can_decrypt(&mut self, ciphertext: Ciphertext) -> Result<bool>;
fn keys_public(&mut self) -> Result<Vec<Key>>;
fn keys_private(&mut self) -> Result<Vec<Key>>;
fn import_key(&mut self, key: &[u8]) -> Result<()>;
fn export_key(&mut self, key: Key) -> Result<Vec<u8>>;
fn supports_proto(&self, proto: Proto) -> bool;
// Provided methods
fn encrypt_file(
&mut self,
recipients: &Recipients,
plaintext: Plaintext,
path: &Path,
) -> Result<()> { ... }
fn decrypt_file(&mut self, path: &Path) -> Result<Plaintext> { ... }
fn can_decrypt_file(&mut self, path: &Path) -> Result<bool> { ... }
fn get_public_key(&mut self, fingerprint: &str) -> Result<Key> { ... }
fn find_public_keys(&mut self, fingerprints: &[&str]) -> Result<Vec<Key>> { ... }
fn import_key_file(&mut self, path: &Path) -> Result<()> { ... }
fn export_key_file(&mut self, key: Key, path: &Path) -> Result<()> { ... }
}Expand description
Defines generic crypto context.
Implemented on backend specific cryptography contexcts, makes using it possible through a single simple interface.
Required Methods§
Sourcefn encrypt(
&mut self,
recipients: &Recipients,
plaintext: Plaintext,
) -> Result<Ciphertext>
fn encrypt( &mut self, recipients: &Recipients, plaintext: Plaintext, ) -> Result<Ciphertext>
Encrypt plaintext for recipients.
Sourcefn decrypt(&mut self, ciphertext: Ciphertext) -> Result<Plaintext>
fn decrypt(&mut self, ciphertext: Ciphertext) -> Result<Plaintext>
Decrypt ciphertext.
Sourcefn can_decrypt(&mut self, ciphertext: Ciphertext) -> Result<bool>
fn can_decrypt(&mut self, ciphertext: Ciphertext) -> Result<bool>
Check whether we can decrypt ciphertext.
Sourcefn keys_public(&mut self) -> Result<Vec<Key>>
fn keys_public(&mut self) -> Result<Vec<Key>>
Obtain all public keys from keychain.
Sourcefn keys_private(&mut self) -> Result<Vec<Key>>
fn keys_private(&mut self) -> Result<Vec<Key>>
Obtain all public keys from keychain.
Sourcefn import_key(&mut self, key: &[u8]) -> Result<()>
fn import_key(&mut self, key: &[u8]) -> Result<()>
Import the given key from bytes into keychain.
Sourcefn export_key(&mut self, key: Key) -> Result<Vec<u8>>
fn export_key(&mut self, key: Key) -> Result<Vec<u8>>
Export the given key from the keychain as bytes.
Sourcefn supports_proto(&self, proto: Proto) -> bool
fn supports_proto(&self, proto: Proto) -> bool
Check whether this context supports the given protocol.
Provided Methods§
Sourcefn encrypt_file(
&mut self,
recipients: &Recipients,
plaintext: Plaintext,
path: &Path,
) -> Result<()>
fn encrypt_file( &mut self, recipients: &Recipients, plaintext: Plaintext, path: &Path, ) -> Result<()>
Encrypt plaintext and write it to the file.
Sourcefn decrypt_file(&mut self, path: &Path) -> Result<Plaintext>
fn decrypt_file(&mut self, path: &Path) -> Result<Plaintext>
Decrypt ciphertext from file.
Sourcefn can_decrypt_file(&mut self, path: &Path) -> Result<bool>
fn can_decrypt_file(&mut self, path: &Path) -> Result<bool>
Check whether we can decrypt ciphertext from file.
Sourcefn get_public_key(&mut self, fingerprint: &str) -> Result<Key>
fn get_public_key(&mut self, fingerprint: &str) -> Result<Key>
Obtain a public key from keychain for fingerprint.
Sourcefn find_public_keys(&mut self, fingerprints: &[&str]) -> Result<Vec<Key>>
fn find_public_keys(&mut self, fingerprints: &[&str]) -> Result<Vec<Key>>
Find public keys from keychain for fingerprints.
Skips fingerprints no key is found for.
Sourcefn import_key_file(&mut self, path: &Path) -> Result<()>
fn import_key_file(&mut self, path: &Path) -> Result<()>
Import the given key from a file into keychain.