From 222f3c38da50a1fbfbf80ad2b3f227ab266fcc50 Mon Sep 17 00:00:00 2001 From: Jake Probst Date: Sun, 14 Jul 2019 00:43:05 -0700 Subject: [PATCH] have cipher specify header size Really it is more about mimimum cipher block size. Please enter the commit message for your changes. Lines starting --- src/crypto/mod.rs | 5 +++++ src/crypto/pc.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/crypto/mod.rs b/src/crypto/mod.rs index 82e0ea1..e3f1390 100644 --- a/src/crypto/mod.rs +++ b/src/crypto/mod.rs @@ -11,6 +11,7 @@ pub enum CipherError { pub trait PSOCipher { fn encrypt(&mut self, data: &Vec) -> Result, CipherError>; fn decrypt(&mut self, data: &Vec) -> Result, CipherError>; + fn header_size(&self) -> usize; } @@ -26,4 +27,8 @@ impl PSOCipher for NullCipher { fn decrypt(&mut self, data: &Vec) -> Result, CipherError> { Ok(data.clone()) } + + fn header_size(&self) -> usize { + 4 + } } diff --git a/src/crypto/pc.rs b/src/crypto/pc.rs index 19701ab..6df6b09 100644 --- a/src/crypto/pc.rs +++ b/src/crypto/pc.rs @@ -111,6 +111,10 @@ impl PSOCipher for PSOPCCipher { fn decrypt(&mut self, data: &Vec) -> Result, CipherError> { self.encrypt(data) } + + fn header_size(&self) -> usize { + 4 + } }