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§
Sourcefn encrypt(
&self,
ino: u64,
device_offset: u64,
file_offset: u64,
buffer: &mut [u8],
) -> Result<(), Error>
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.
Sourcefn decrypt(
&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>
Decrypt the data in buffer
.
offset
is the byte offset within the file.buffer
is mutated in place.
buffer
must be 16 byte aligned.
Sourcefn encrypt_filename(
&self,
object_id: u64,
buffer: &mut Vec<u8>,
) -> Result<(), Error>
fn encrypt_filename( &self, object_id: u64, buffer: &mut Vec<u8>, ) -> Result<(), Error>
Encrypts the filename contained in buffer
.
Sourcefn decrypt_filename(
&self,
object_id: u64,
buffer: &mut Vec<u8>,
) -> Result<(), Error>
fn decrypt_filename( &self, object_id: u64, buffer: &mut Vec<u8>, ) -> Result<(), Error>
Decrypts the filename contained in buffer
.
Sourcefn hash_code(&self, _raw_filename: &[u8], filename: &str) -> u32
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.
Sourcefn hash_code_casefold(&self, _filename: &str) -> u32
fn hash_code_casefold(&self, _filename: &str) -> u32
Returns a case-folded hash_code to use for ‘filename’.
Sourcefn supports_inline_encryption(&self) -> bool
fn supports_inline_encryption(&self) -> bool
True if supports inline encryption