Hi Jeff,

Here is a sample program.

code:
-----------------------------------------------------------------------------------------
#include <iostream>
#include <algorithm>
#include <cryptopp/aes.h>
#include <cryptopp/modes.h>
#include <cryptopp/hex.h>
#include <cryptopp/files.h>

using namespace std;
using namespace CryptoPP;

int main()
{
    string message = "this is a message for testing";
    SecByteBlock ciphertext(message.size());
    SecByteBlock messageRecovered(message.size());

    typedef AES CipherType;

    // print plaintext
    cout << "Plaintext (" << message.size() << " bytes):\n\t" <<
message << '\n';

    byte key[CipherType::DEFAULT_KEYLENGTH],
iv[CipherType::BLOCKSIZE];
    ::memset(key, 0x01, sizeof(key));
    ::memset(iv, 0x11, sizeof(iv));

    // encrypt message
    CBC_CTS_Mode<CipherType>::Encryption encryptor(key,
CipherType::DEFAULT_KEYLENGTH, iv);
    encryptor.ProcessData(ciphertext.begin(), reinterpret_cast<const
byte*>(message.c_str()), message.size());

    // print ciphertext encoded by encoding base16
    cout << "Ciphertext (" << ciphertext.size() << " bytes):\n\t";
    HexEncoder(new FileSink(cout)).Put(ciphertext.begin(),
ciphertext.size());
    cout << '\n';

    // decrypt ciphertext
    CBC_CTS_Mode<CipherType>::Decryption decryptor(key,
CipherType::DEFAULT_KEYLENGTH, iv);
    decryptor.ProcessData(messageRecovered.begin(),
ciphertext.begin(), ciphertext.size());

    cout << "Plaintext recovered (" << messageRecovered.size() << "
bytes):\n\t";
    copy(messageRecovered.begin(), messageRecovered.end(),
ostream_iterator<char>(cout));
    cout << endl;

    return 0;
}
-----------------------------------------------------------------------------------------

result  (VC9 + Crypto++5.5.1):
-----------------------------------------------------------------------------------------
Plaintext (29 bytes):
        this is a message for testing
Assertion failed: length % s == 0, file .\modes.cpp, line 101
-----------------------------------------------------------------------------------------

Yongce

On 8月8日, 上午5时55分, "Jeffrey Walton" <[EMAIL PROTECTED]> wrote:
> Hi Yongce,
>
> I have not encountered the issue. Can you send me a sample which
> demonstrates the issue. I'll see if anything jumps out at me.
>
> Jeff
>
> > On 8/6/08, Yongce <[EMAIL PROTECTED]> wrote:
>
> > > Hi All,
>
> > > I found that using CBC_CTS_Mode directly can only process
> > > data with length of multiple block size.
> > > And result of using CBC_CTS_Mode directly was different from that of
> > > using
> > > StreamTransformationFilter wapping CBC_CTS_Mode.
>
> > > I thought that CBC_CTS_Mode could process data with arbitrary length
> > > and result of the two using of CBC_CTS_Mode should be the same.
> > > What's wrong?
>
> > > Regards,
> > > Yongce
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to