256-bit Rijndael blocksize?

会有一股神秘感。 提交于 2019-12-20 01:44:13

问题


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?


回答1:


Looking at the implementation, the current iterations of crypto++ only support Rijndael with a block size of 16 bytes. As the IV has to be precisely a single block for CBC mode, Rijndael with a 256 bit block size does not seem to be possible.



来源:https://stackoverflow.com/questions/15449756/256-bit-rijndael-blocksize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!