rajkosto
unread,Jul 3, 2009, 12:10:51 PM7/3/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Crypto++ Users
Hello, i use crypto++ for encrypting/decrypting with Twofish.
The problem i have is, that after encrypting data, then decrypting
that exact data, the padding remains.
This is how i encrypt and decrypt
string input = { some hex bytes };
CryptoPP::CBC_Mode<CryptoPP::Twofish>::Encryption TFEncryptGTC;
//Set IV
TFEncryptGTC.Resynchronize(vector);
//encrypt
string encrypted;
CryptoPP::StringSource(input, true, new
CryptoPP::StreamTransformationFilter(TFEncryptGTC, new
CryptoPP::StringSink(encrypted)));
//After that, i do the reverse with the data i got after encrypting
CryptoPP::CBC_Mode<CryptoPP::Twofish>::Decryption TFDecryptGTC;
//Set IV (same as the one used for encryption ofcourse)
TFDecryptGTC.Resynchronize(vector);
//decrypt
string output;
CryptoPP::StringSource(encrypted, true, new
CryptoPP::StreamTransformationFilter(TFDecryptGTC, new
CryptoPP::StringSink(output)));
the output i get isnt the same as the input i put in ! instead, it's
input + some bytes like 0x00 0xcd 0xcd 0xcd or 0x00 0xfd 0xfd 0xfd...
if i run this output through encryption and decryption again, i will
get another trailing padding ! so it would have 2 times 0x00 0xcd 0xcd
0xcd at the end...
why isnt decryption removing the padding that streamtransformation
added to perform encryption properly ?