256位Rijndael块大小?

时间:2013-03-16 13:18:51

标签: c++ encryption aes crypto++

我正在尝试使用cryptopp将解密例程从C#程序移植到C ++,但我遇到了问题。在C#程序中,密钥和IV都是256位。所以我试着做这样的事情:

    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:密文长度不是块大小的倍数。

我试图像这样传递IV大小:

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

但后来我得到了:

  

IV长度32超过最大值16。

那么,当数据加密时,我如何解密数据,长度= 32?

1 个答案:

答案 0 :(得分:3)

查看实现,crypto ++的当前迭代仅支持块大小为16字节的Rijndael。由于IV必须恰好是CBC模式的单个模块,因此Rijndael的256位块大小似乎不可能。

相关问题