I'm converting some code from old Crypto++ (this code has worked with 3.2 
through 4.2) to use Crypto++ 5.0, and I have become confused about the 
StreamTransformation interface in CTS mode.

First of all, is there any documentation that would contain the answer to my 
question?  I've looked at the FAQ and googled.  I can't read the "compiled 
html format" user's guide.

The previous code did this:

DES_XEX3_Encryption encryption(self->key);
CBC_CTS_Encryptor encrypter(encryption, iv);
encrypter.Put(text, textlength);
encrypter.Close();
encrypter.Get(ciphertext, textlength);

The new code does this, which is much nicer looking:

CBC_CTS_Mode<DES_XEX3>::Encryption encryptor;
encryptor.SetKeyWithIV(self->key, 24, iv);
encryptor.ProcessData(ciphertext, text, textlength);

... except that it fails an assertion which seems to indicate that this isn't 
the way to use CTS mode:

modes.cpp:108: virtual void CryptoPP::BlockOrientedCipherModeBase::ProcessData(byte*, 
const byte*, unsigned int): Assertion `length % s == 0' failed.

In modes.cpp at that line, `s' does indeed contain the block size.

So I've tried a for-loop like this:

for (unsigned int offset = 0; offset < textlength; offset += 
encryptor.MandatoryBlockSize()) {
        encryptor.ProcessData(ciphertext+offset, text+offset, 
MIN(encryptor.MinLastBlockSize(), textlength - offset));
}

but this yields the same error.

The features of StreamTransformation which are included for CTS purposes, like 
ProcessLastBlock and MinLastBlockSize give me a compile error when I try to 
use them, which is confusing:

/home/zooko/playground/mnet/extsrc-HEAD/cryptopp/modes.h: In function
   `PyObject* tripledescbc_decrypt(tripledescbc*, PyObject*)':
/home/zooko/playground/mnet/extsrc-HEAD/cryptopp/modes.h:241: `virtual unsigned
   int CryptoPP::CBC_CTS_Decryption::MinLastBlockSize() const' is private
tripledescbc.cpp:201: within this context


Okay, thanks in advance for your help.

Regards,

Zooko

http://zooko.com/

P.S.
uname -a: Linux pion 2.4.19 #1 Tue Sep 17 11:05:26 EDT 2002 i686 unknown unknown 
GNU/Linux
gcc -v: HACK pion:~/playground/mnet/mnet-HEAD$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.1/specs
Configured with: /mnt/data/gcc-3.1/gcc-3.2-3.2.1ds2/src/configure -v 
--enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared 
--with-system-zlib --enable-nls --without-included-gettext --enable-java-gc=boehm 
--enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.1 20020924 (Debian prerelease)

Reply via email to