From 09afa0aa6fb3f52b50b692665f86c471ac85b935 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 16 Sep 2012 16:19:06 +0200 Subject: [PATCH] No more arbitrary default value for segment_size in CFB mode (thanks Adam Laurie) --- src/CryptoPlus/Cipher/blockcipher.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/CryptoPlus/Cipher/blockcipher.py b/src/CryptoPlus/Cipher/blockcipher.py index 6d2ca01..b7b10d9 100644 --- a/src/CryptoPlus/Cipher/blockcipher.py +++ b/src/CryptoPlus/Cipher/blockcipher.py @@ -55,9 +55,6 @@ class BlockCipher(): self.IV = '\x00'*self.blocksize else: self.IV = IV - - if segment_size == None: - segment_size = 8 if mode <> MODE_XTS: self.cipher = cipher_module(self.key,**args) @@ -70,6 +67,8 @@ class BlockCipher(): elif mode == MODE_CFB: if len(self.IV) <> self.blocksize: raise Exception,"the IV length should be %i bytes"%self.blocksize + if segment_size == None: + raise ValueError,"segment size must be defined explicitely for CFB mode" if segment_size > self.blocksize*8 or segment_size%8 <> 0: # current CFB implementation doesn't support bit level acces => segment_size should be multiple of bytes raise ValueError,"segment size should be a multiple of 8 bits between 8 and %i"%(self.blocksize*8) -- 2.11.4.GIT