I am trying to port a decryption routine from C# program to C++ using cryptopp, but I have a problem. In the C# program, the key and IV are both 256 bits. So I tried to do something like this:
char *hash1 = "......";
std::string hash2;
CryptoPP::StringSource(hash1, true,new CryptoPP::Base64Decoder(new CryptoPP::StringSink(hash2)));
CryptoPP::Rijndael::Decryption decryptor(key, 32);
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( decryptor, iv);
CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, (new CryptoPP::StringSink( decryptedData ) ));
stfDecryptor.Put( reinterpret_cast<const unsigned char*>( hash2.c_str() ), hash2.size() );
stfDecryptor.MessageEnd();
and I am getting
StreamTransformationFilter: ciphertext length is not a multiple of block size.
I tried to pass IV size like this:
CryptoPP::CBC_Mode<CryptoPP::Rijndael >::Decryption decr;
decr.SetKeyWithIV(key, 32, iv, 32);
But then I get:
IV length 32 exceeds the maximum of 16.
So, how can I decrypt data, when it was encrypted by IV with length = 32?
FixedBlockSize<16>? - Maarten BodewesRijindael_Info32as an extension ofpublic FixedBlockSize<32>, public VariableKeyLength<16, 16, 32, 8>, or even apublic FixedBlockSize<32>, public FixedKeyLength<32>and the rest of the algorithm would just take hold and work, as I'm not familiar enough with CryptoPP to make that call. The pessimist in me says it isn't bloody likely. - WhozCraig