pub trait Crypto {
// Required methods
fn decrypt_string(&self, ciphertext: &[u8]) -> Result<String>;
fn encrypt_string(
&self,
plaintext: &str,
recipients: &[Recipient]
) -> Result<Vec<u8>>;
fn sign_string(
&self,
to_sign: &str,
valid_gpg_signing_keys: &[[u8; 20]],
strategy: &FindSigningFingerprintStrategy
) -> Result<String>;
fn verify_sign(
&self,
data: &[u8],
sig: &[u8],
valid_signing_keys: &[[u8; 20]]
) -> Result<SignatureStatus, VerificationError>;
fn pull_keys(
&mut self,
recipients: &[Recipient],
config_path: &Path
) -> Result<String>;
fn import_key(&mut self, key: &str, config_path: &Path) -> Result<String>;
fn get_key(&self, key_id: &str) -> Result<Box<dyn Key>>;
fn get_all_trust_items(&self) -> Result<HashMap<[u8; 20], OwnerTrustLevel>>;
fn implementation(&self) -> CryptoImpl;
fn own_fingerprint(&self) -> Option<[u8; 20]>;
}
Expand description
All operations that can be done through pgp, either with gpgme or sequoia.
Required Methods§
sourcefn decrypt_string(&self, ciphertext: &[u8]) -> Result<String>
fn decrypt_string(&self, ciphertext: &[u8]) -> Result<String>
Reads a file and decrypts it
Errors
Will return Err
if decryption fails, for example if the current user isn’t the
recipient of the message.
sourcefn encrypt_string(
&self,
plaintext: &str,
recipients: &[Recipient]
) -> Result<Vec<u8>>
fn encrypt_string( &self, plaintext: &str, recipients: &[Recipient] ) -> Result<Vec<u8>>
Encrypts a string
Errors
Will return Err
if encryption fails, for example if the current users key
isn’t capable of encrypting.
sourcefn sign_string(
&self,
to_sign: &str,
valid_gpg_signing_keys: &[[u8; 20]],
strategy: &FindSigningFingerprintStrategy
) -> Result<String>
fn sign_string( &self, to_sign: &str, valid_gpg_signing_keys: &[[u8; 20]], strategy: &FindSigningFingerprintStrategy ) -> Result<String>
Returns a gpg signature for the supplied string. Suitable to add to a gpg commit.
Errors
Will return Err
if signing fails, for example if the current users key
isn’t capable of signing.
sourcefn verify_sign(
&self,
data: &[u8],
sig: &[u8],
valid_signing_keys: &[[u8; 20]]
) -> Result<SignatureStatus, VerificationError>
fn verify_sign( &self, data: &[u8], sig: &[u8], valid_signing_keys: &[[u8; 20]] ) -> Result<SignatureStatus, VerificationError>
sourcefn pull_keys(
&mut self,
recipients: &[Recipient],
config_path: &Path
) -> Result<String>
fn pull_keys( &mut self, recipients: &[Recipient], config_path: &Path ) -> Result<String>
Pull keys from the keyserver for those recipients.
Errors
Will return Err
on network errors and similar.
sourcefn get_key(&self, key_id: &str) -> Result<Box<dyn Key>>
fn get_key(&self, key_id: &str) -> Result<Box<dyn Key>>
Return a key corresponding to the given key id.
Errors
Will return Err
if key_id
didn’t correspond to a key.
sourcefn get_all_trust_items(&self) -> Result<HashMap<[u8; 20], OwnerTrustLevel>>
fn get_all_trust_items(&self) -> Result<HashMap<[u8; 20], OwnerTrustLevel>>
Returns a map from key fingerprints to OwnerTrustLevel’s
Errors
Will return Err
on failure to obtain trust levels.
sourcefn implementation(&self) -> CryptoImpl
fn implementation(&self) -> CryptoImpl
Returns the type of this CryptoImpl
, useful for serializing the store config
sourcefn own_fingerprint(&self) -> Option<[u8; 20]>
fn own_fingerprint(&self) -> Option<[u8; 20]>
Returns the fingerprint of the user using ripasso