Hello All,
I have been beating around this problem for over a month now. I have figured 
out that I have to break data up into blocks of 
128 bytes or smaller and feeding them into the encryptor and then check the 
other end of the pipe and get each block and cat
them into a string etc etc.

But the problem I have now seems to be that each block of data is getting 
padded by the encryptor and then breaks
when trying to decrypt it, in other words I end up with tons of garbage in the 
decrypted output.
for small amounts of data everything works fine.


Could someone please show me an example of how to take a string of varying 
length (~2000k) and feed it into the 
encryptor and then retrieve it properly. I would really like to use a 
StringSink.

I have found the following code by Weidai but its a bit vague.

>For ECB and CBC mode, you must process data in multiples of the block size. 
>Alternatively, you can wrap 
>StreamTransformationFilter around the mode object and use it as a Filter 
>object. StreamTransformationFilter will take care   >buffering data into 
>blocks for you when needed.
>
>        std::string ciphertext;
>        StreamTransformationFilter cfbEncryptor(cfbEncryption, new 
> StringSink(ciphertext));
>        cfbEncryptor.Put(plaintext, 100);
>        // input more plaintext here if needed
>        cfbEncryptor.MessageEnd();
>        return ciphertext;
>
>2002-Oct-12 1:22pm weidai

for larger amounts of data should the StringSink ciphertext
be appended to another string and then cleared while iterating each block?

or will the StringSink see that MessageEnd() has not been called yet and wont 
pad til the end?
or will it pad each block (what I'm seeing now )?
the example speaks of ECB and CBC mode, but then uses CFB for the example, will 
StreamTransformationFilter in ECB or CBC mode not pad data for you?

A.J. Mayorga
US NAVY FIWC~RT/R&D
[EMAIL PROTECTED]



Reply via email to