256位Rijndael块大小? [英] 256-bit Rijndael blocksize?

查看:285
本文介绍了256位Rijndael块大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用cryptopp从C#程序端口解密程序到C + +,但我有一个问题。在C#程序中,键和IV都是256位。所以我试着做这样的事情:

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();

我获得


StreamTransformationFilter:密文长度不是块大小的倍数。

StreamTransformationFilter: ciphertext length is not a multiple of block size.

我试图通过IV大小, / p>

I tried to pass IV size like this:

    CryptoPP::CBC_Mode<CryptoPP::Rijndael >::Decryption decr;
    decr.SetKeyWithIV(key, 32, iv, 32);

但是我得到:


IV length 32超过最大值16。

IV length 32 exceeds the maximum of 16.

看看实现,crypto ++的当前迭代仅支持Rijndael,其块大小为(大小),它的长度为32,它的长度为32。

So, how can I decrypt data, when it was encrypted by IV with length = 32?

推荐答案

16字节。由于IV必须恰好是CBC模式的单个块,具有256位块大小的Rijndael似乎不可能。

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.

这篇关于256位Rijndael块大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆