IsContext

Trait IsContext 

Source
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§

Source

fn encrypt( &mut self, recipients: &Recipients, plaintext: Plaintext, ) -> Result<Ciphertext>

Encrypt plaintext for recipients.

Source

fn decrypt(&mut self, ciphertext: Ciphertext) -> Result<Plaintext>

Decrypt ciphertext.

Source

fn can_decrypt(&mut self, ciphertext: Ciphertext) -> Result<bool>

Check whether we can decrypt ciphertext.

Source

fn keys_public(&mut self) -> Result<Vec<Key>>

Obtain all public keys from keychain.

Source

fn keys_private(&mut self) -> Result<Vec<Key>>

Obtain all public keys from keychain.

Source

fn import_key(&mut self, key: &[u8]) -> Result<()>

Import the given key from bytes into keychain.

Source

fn export_key(&mut self, key: Key) -> Result<Vec<u8>>

Export the given key from the keychain as bytes.

Source

fn supports_proto(&self, proto: Proto) -> bool

Check whether this context supports the given protocol.

Provided Methods§

Source

fn encrypt_file( &mut self, recipients: &Recipients, plaintext: Plaintext, path: &Path, ) -> Result<()>

Encrypt plaintext and write it to the file.

Source

fn decrypt_file(&mut self, path: &Path) -> Result<Plaintext>

Decrypt ciphertext from file.

Source

fn can_decrypt_file(&mut self, path: &Path) -> Result<bool>

Check whether we can decrypt ciphertext from file.

Source

fn get_public_key(&mut self, fingerprint: &str) -> Result<Key>

Obtain a public key from keychain for fingerprint.

Source

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.

Source

fn import_key_file(&mut self, path: &Path) -> Result<()>

Import the given key from a file into keychain.

Source

fn export_key_file(&mut self, key: Key, path: &Path) -> Result<()>

Export the given key from the keychain to a file.

Implementors§

Source§

impl IsContext for prs_lib::crypto::backend::gnupg_bin::context::Context

Source§

impl IsContext for prs_lib::crypto::backend::gpgme::context::Context

Source§

impl IsContext for prs_lib::crypto::backend::rpgpie::context::Context

Source§

impl IsContext for prs_lib::crypto::Context