libpso/src/crypto/mod.rs
jake edb6319189
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
how has libpso avoided the baleful eye of clippy
2023-11-14 22:05:13 -07:00

39 lines
689 B
Rust

pub mod pc;
pub mod bb;
#[derive(Debug)]
pub enum CipherError {
InvalidSize
}
pub trait PSOCipher {
fn encrypt(&mut self, data: &[u8]) -> Result<Vec<u8>, CipherError>;
fn decrypt(&mut self, data: &[u8]) -> Result<Vec<u8>, CipherError>;
fn header_size(&self) -> usize;
fn block_size(&self) -> usize {
self.header_size()
}
}
pub struct NullCipher {
}
impl PSOCipher for NullCipher {
fn encrypt(&mut self, data: &[u8]) -> Result<Vec<u8>, CipherError> {
Ok(data.to_vec())
}
fn decrypt(&mut self, data: &[u8]) -> Result<Vec<u8>, CipherError> {
Ok(data.to_vec())
}
fn header_size(&self) -> usize {
4
}
}