Trait ripasso::crypto::Crypto

source ·
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§

source

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.

source

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.

source

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.

source

fn verify_sign( &self, data: &[u8], sig: &[u8], valid_signing_keys: &[[u8; 20]] ) -> Result<SignatureStatus, VerificationError>

Verifies is a signature is valid

Errors

Will return Err if the verifican fails.

source

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.

source

fn import_key(&mut self, key: &str, config_path: &Path) -> Result<String>

Import a key from text.

Errors

Will return Err if the text wasn’t able to be imported as a key.

source

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.

source

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.

source

fn implementation(&self) -> CryptoImpl

Returns the type of this CryptoImpl, useful for serializing the store config

source

fn own_fingerprint(&self) -> Option<[u8; 20]>

Returns the fingerprint of the user using ripasso

Implementors§