Hi Jeff,

Here is a sample program using StreamTransformationFilter with CBC-
CTS.

code:
----------------------------------------------------------------------------------------------
#include <iostream>
#include <cryptopp/aes.h>
#include <cryptopp/modes.h>
#include <cryptopp/filters.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";
    string ciphertext;
    string messageRecovered;

    typedef AES CipherType;

    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));

    CBC_CTS_Mode<CipherType>::Encryption encryptor(key,
CipherType::DEFAULT_KEYLENGTH, iv);
    StringSource(message, true, new StreamTransformationFilter(
        encryptor, new StringSink(ciphertext)));

    cout << "Ciphertext (" << ciphertext.size() << " bytes):\n\t";
    StringSource(ciphertext, true, new HexEncoder(new
FileSink(cout)));
    cout << '\n';

    CBC_CTS_Mode<CipherType>::Decryption decryptor(key,
CipherType::DEFAULT_KEYLENGTH, iv);
    StringSource(ciphertext, true, new StreamTransformationFilter(
        decryptor, new StringSink(messageRecovered)));

    cout << "Plaintext recovered (" << messageRecovered.size() << "
bytes):\n\t";
    cout << messageRecovered << endl;

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

result  (VC9 + Crypto++5.5.1):
-----------------------------------------------------------------------------------------
Plaintext (29 bytes):
        this is a message for testing
Ciphertext (29 bytes):
        8383CA42A94C7781D0ACA5BECB663F7CFA8DE5CB20080DCB329C96825B
Plaintext recovered (29 bytes):
        this is a message for testing
-----------------------------------------------------------------------------------------

Note that the length of the plaintext is not multiple of the block
size,
and the length of the ciphertext is the same with it,
which conforms to the definition of CBC-CTS mode,
but the prior example did not behavior like this.

Yongce

On 8月12日, 上午1时06分, "Jeffrey Walton" <[EMAIL PROTECTED]> wrote:
> Hi ,
>
> Your program results are what I would expect from CBC\CTS mode using
> the StreamTransformationFilter. Though I don't have any test vectors
> handy to really scrutinize Crypto++ in AES\CBC-CTS, I don't expect a
> problem.
>
> This leaves the code where blocking and stealing of the last two
> cipher text blocks is manually fed ito the encryptor. Can you post
> your code?
>
> Jeff

--~--~---------~--~----~------------~-------~--~----~
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