Browse Source

have cipher specify header size

Really it is more about mimimum cipher block size.

 Please enter the commit message for your changes. Lines starting
pull/3/head
Jake Probst 5 years ago
parent
commit
222f3c38da
  1. 5
      src/crypto/mod.rs
  2. 4
      src/crypto/pc.rs

5
src/crypto/mod.rs

@ -11,6 +11,7 @@ pub enum CipherError {
pub trait PSOCipher {
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;
}
@ -26,4 +27,8 @@ impl PSOCipher for NullCipher {
fn decrypt(&mut self, data: &Vec<u8>) -> Result<Vec<u8>, CipherError> {
Ok(data.clone())
}
fn header_size(&self) -> usize {
4
}
}

4
src/crypto/pc.rs

@ -111,6 +111,10 @@ impl PSOCipher for PSOPCCipher {
fn decrypt(&mut self, data: &Vec<u8>) -> Result<Vec<u8>, CipherError> {
self.encrypt(data)
}
fn header_size(&self) -> usize {
4
}
}

Loading…
Cancel
Save