Trait crypt_guard::CryptographicFunctions

source ·
pub trait CryptographicFunctions {
    // Required methods
    fn encrypt(
        &mut self,
        public_key: Vec<u8>
    ) -> Result<(Vec<u8>, Vec<u8>), CryptError>;
    fn decrypt(
        &mut self,
        secret_key: Vec<u8>,
        ciphertext: Vec<u8>
    ) -> Result<Vec<u8>, CryptError>;
}
Expand description

Defines the functionalities for cryptographic operations, providing abstract methods for encryption and decryption that need to be implemented by specific cryptographic algorithms.

Required Methods§

source

fn encrypt( &mut self, public_key: Vec<u8> ) -> Result<(Vec<u8>, Vec<u8>), CryptError>

Encrypts data using a public key, returning the encrypted data and potentially a new key.

§Parameters
  • public_key: The public key used for encryption.
§Returns

A result containing the encrypted data and a new key on success, or a CryptError on failure.

source

fn decrypt( &mut self, secret_key: Vec<u8>, ciphertext: Vec<u8> ) -> Result<Vec<u8>, CryptError>

Decrypts data using a secret key and a given ciphertext.

§Parameters
  • secret_key: The secret key used for decryption.
  • ciphertext: The ciphertext to be decrypted.
§Returns

A result containing the decrypted data on success, or a CryptError on failure.

Implementors§