rustic_core/
crypto.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::RusticResult;

pub(crate) mod aespoly1305;
pub(crate) mod hasher;

/// A trait for encrypting and decrypting data.
pub trait CryptoKey: Clone + Copy + Sized + Send + Sync + 'static {
    /// Decrypt the given data.
    ///
    /// # Arguments
    ///
    /// * `data` - The data to decrypt.
    ///
    /// # Returns
    ///
    /// A vector containing the decrypted data.
    fn decrypt_data(&self, data: &[u8]) -> RusticResult<Vec<u8>>;

    /// Encrypt the given data.
    ///
    /// # Arguments
    ///
    /// * `data` - The data to encrypt.
    ///
    /// # Returns
    ///
    /// A vector containing the encrypted data.
    fn encrypt_data(&self, data: &[u8]) -> RusticResult<Vec<u8>>;
}