Skip to content

Commit 09afa0a

Browse files
author
Philippe Teuwen
committed
No more arbitrary default value for segment_size in CFB mode (thanks Adam Laurie)
1 parent 51af313 commit 09afa0a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/CryptoPlus/Cipher/blockcipher.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ def __init__(self,key,mode,IV,counter,cipher_module,segment_size,args={}):
5555
self.IV = '\x00'*self.blocksize
5656
else:
5757
self.IV = IV
58-
59-
if segment_size == None:
60-
segment_size = 8
6158

6259
if mode <> MODE_XTS:
6360
self.cipher = cipher_module(self.key,**args)
@@ -70,6 +67,8 @@ def __init__(self,key,mode,IV,counter,cipher_module,segment_size,args={}):
7067
elif mode == MODE_CFB:
7168
if len(self.IV) <> self.blocksize:
7269
raise Exception,"the IV length should be %i bytes"%self.blocksize
70+
if segment_size == None:
71+
raise ValueError,"segment size must be defined explicitely for CFB mode"
7372
if segment_size > self.blocksize*8 or segment_size%8 <> 0:
7473
# current CFB implementation doesn't support bit level acces => segment_size should be multiple of bytes
7574
raise ValueError,"segment size should be a multiple of 8 bits between 8 and %i"%(self.blocksize*8)

0 commit comments

Comments
 (0)