Cipher

Trait Cipher 

Source
pub trait Cipher:
    Debug
    + Send
    + Sync {
    // Required methods
    fn encrypt(
        &self,
        ino: u64,
        device_offset: u64,
        file_offset: u64,
        buffer: &mut [u8],
    ) -> Result<(), Error>;
    fn decrypt(
        &self,
        ino: u64,
        device_offset: u64,
        file_offset: u64,
        buffer: &mut [u8],
    ) -> Result<(), Error>;
    fn encrypt_filename(
        &self,
        object_id: u64,
        buffer: &mut Vec<u8>,
    ) -> Result<(), Error>;
    fn decrypt_filename(
        &self,
        object_id: u64,
        buffer: &mut Vec<u8>,
    ) -> Result<(), Error>;
    fn hash_code(&self, _raw_filename: &[u8], filename: &str) -> u32;
    fn hash_code_casefold(&self, _filename: &str) -> u32;
    fn supports_inline_encryption(&self) -> bool;
    fn crypt_ctx(&self, ino: u64, file_offset: u64) -> Option<(u32, u8)>;
}
Expand description

Trait defining common methods shared across all ciphers.

Required Methods§

Source

fn encrypt( &self, ino: u64, device_offset: u64, file_offset: u64, buffer: &mut [u8], ) -> Result<(), Error>

Encrypts data in the buffer.

  • offset is the byte offset within the file.
  • buffer is mutated in place.

buffer must be 16 byte aligned.

Source

fn decrypt( &self, ino: u64, device_offset: u64, file_offset: u64, buffer: &mut [u8], ) -> Result<(), Error>

Decrypt the data in buffer.

  • offset is the byte offset within the file.
  • buffer is mutated in place.

buffer must be 16 byte aligned.

Source

fn encrypt_filename( &self, object_id: u64, buffer: &mut Vec<u8>, ) -> Result<(), Error>

Encrypts the filename contained in buffer.

Source

fn decrypt_filename( &self, object_id: u64, buffer: &mut Vec<u8>, ) -> Result<(), Error>

Decrypts the filename contained in buffer.

Source

fn hash_code(&self, _raw_filename: &[u8], filename: &str) -> u32

Returns a hash_code to use. Note in the case of encrypted filenames, takes the raw encrypted bytes.

Source

fn hash_code_casefold(&self, _filename: &str) -> u32

Returns a case-folded hash_code to use for ‘filename’.

Source

fn supports_inline_encryption(&self) -> bool

True if supports inline encryption

Source

fn crypt_ctx(&self, ino: u64, file_offset: u64) -> Option<(u32, u8)>

If this cipher type supports inline encryption, returns the (dun, slot) value. Else returns None.

Implementors§