Re: Problem CipherMode.CFB in symmetric encryption

From: Valery Pryamikov (
Date: 10/14/05

Date: Fri, 14 Oct 2005 21:57:06 +0200

That's not exactly right. Only 1 bit OFB as per old FIPS 81 is totally plain
text length-indifferent. But both CFB and Full Block Feedback OFB (as per
ISO 10116) generate keystream that is exact multiple of block length. Of
course, you can truncate last block of keystream wherever you want without
affecting decryption, but that doesn't change the fact that it is generated
by blocksize.
And using OFB on cipher with short block size (such as 3DES) is really a bad
idea (unless you are aware what you are doing). OFB acts as random mapping
that has cycle length of size about sqrt(Pi*BlockSize/8)(ie. approx. ~3 GB
for DES/3DES).


"Markus Stoeger" <> wrote in message
> Hello!
> Why do I get the exception:
> "Length of the data to encrypt is invalid."
> ... even when I use the CFB or OFB cipher modes?
> These cipher modes should not care about the length of the encrypted data
> even without padding!
> I have to encrypt a stream of data but cannot wait until each block is
> full and ready to be encrypted. That's why I wanted to use CFB or OFB
> modes.
> Some example code that produces the exception:
> byte[] input = Encoding.ASCII.GetBytes("TestABCDTest");
> TripleDES tdes = TripleDES.Create();
> tdes.Mode = CipherMode.CFB;
> tdes.Padding = PaddingMode.None;
> ICryptoTransform ct = tdes.CreateEncryptor();
> byte[] output = ct.TransformFinalBlock(input, 0, input.Length);
> thanks,
> Max

Relevant Pages