2019-06-23 15:52:09 -07:00
|
|
|
pub mod pc;
|
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>;
|
2019-07-14 00:43:05 -07:00
|
|
|
fn header_size(&self) -> usize;
|
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())
|
|
|
|
}
|
2019-07-14 00:43:05 -07:00
|
|
|
|
|
|
|
fn header_size(&self) -> usize {
|
|
|
|
4
|
|
|
|
}
|
2019-06-23 15:52:09 -07:00
|
|
|
}
|