[Cryptography-dev] CFB Modes
Paul Kehrer
paul.l.kehrer at gmail.com
Wed Sep 11 00:25:48 CEST 2013
I've been implementing some of the basic modes the past two days. I'm
going to be putting in a PR for CFB/OFB soon, but wanted to see if
people have any opinions about supporting the 1-bit and 8-bit CFB
modes.
There are two ways we can approach this. The easy way just means we
declare two additional mode classes (CFB1 and CFB8) and those will
correspond to 1-bit and 8-bit CFB modes that OpenSSL supports in
addition to the standard CFB mode (which has a bit length of the block
cipher's block size).
The alternate way would be to create a single class:
class CFB(object):
def __init__(self, initialization_vector, bit_length=None):
super(CFB, self).__init__()
self.initialization_vector = initialization_vector
self._determine_mode(bit_length)
def _determine_mode(self, bit_length):
if bit_length is None:
self.name = 'CFB'
elif int(bit_length) == 8
self.name = 'CFB8'
elif int(bit_length) == 1
self.name = 'CFB1'
else:
raise ValueError
According to NIST SP800-38A CFB can technically take an integer
parameter 1 <= s <= b where b is the block length, but OpenSSL only
supports 1, 8, and block length. Other backends we may choose to
implement might be more flexible, but the _determine_mode method above
is OpenSSL specific.
Which approach do we prefer/is there another path we should consider looking at?
More information about the Cryptography-dev
mailing list