libpso/src/crypto/mod.rs

39 lines
699 B
Rust
Raw Normal View History

2019-06-23 15:52:09 -07:00
pub mod pc;
2019-07-14 00:43:54 -07:00
pub mod bb;
2019-06-08 18:06:10 -07:00
#[derive(Debug)]
pub enum CipherError {
InvalidSize
}
2019-06-23 15:52:09 -07:00
pub trait PSOCipher {
2019-06-08 18:06:10 -07:00
fn encrypt(&mut self, data: &Vec<u8>) -> Result<Vec<u8>, CipherError>;
fn decrypt(&mut self, data: &Vec<u8>) -> Result<Vec<u8>, CipherError>;
fn header_size(&self) -> usize;
2019-08-21 17:22:21 -07:00
fn block_size(&self) -> usize {
self.header_size()
}
2019-06-08 18:06:10 -07:00
}
2019-06-23 15:52:09 -07:00
pub struct NullCipher {
}
impl PSOCipher for NullCipher {
fn encrypt(&mut self, data: &Vec<u8>) -> Result<Vec<u8>, CipherError> {
Ok(data.clone())
}
fn decrypt(&mut self, data: &Vec<u8>) -> Result<Vec<u8>, CipherError> {
Ok(data.clone())
}
fn header_size(&self) -> usize {
4
}
2019-06-23 15:52:09 -07:00
}