Hello,

I made a little decryption program for AES-CBC. The code of the program 
looks like this


//the object 'decryptor' is defined as AES CBC Decryption with specified 
key and iv

//filter for decryption and writing to file /tmp/myfile WITH PADDING
CryptoPP::StreamTransformationFilter *filter = new CryptoPP::
StreamTransformationFilter(decryptor,new CryptoPP::FileSink("/tmp/myfile"),
CryptoPP::StreamTransformationFilter::PKCS_PADDING);
    
    total = 0;
    while (...) //until file ends
    {
        buffer = ...//read from some other file (f.read(...))
        total += data.size();
        filter->Put((const byte*)buffer.data(),buffer.size()); //write to 
filter
        filter->Flush(true);
    }

    //finished
    filter->MessageEnd();


I got the error Message


terminate called after throwing an instance of 'CryptoPP::InvalidCiphertext'
  what():  StreamTransformationFilter: ciphertext length is not a multiple 
of block size


I don't understand, why I got the error. the encrypted source file and the 
destination file are 1.122.928 bytes long, which is divisable by 16. The 
variable total from the code has the same value.


As a result I got the file /tmp/myfile which is a correct decrypted file, 
but there are 4 bytes padding left and I don't know why.


Greetings

-- 
-- 
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.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to