AES/CFB encryption with Crypto++ not working

▼魔方 西西 提交于 2019-12-04 06:17:47

问题


I have a simple console program that should encrypt files with AES CFB algorithm from Crypto++ library. For some reason it is not working. Encoding part:

byte data[16] = { 0x88, 0x44, 0x88, 0x44,
                  0x88, 0x44, 0x88, 0x44,
                  0x88, 0x44, 0x88, 0x44, 
                  0x88, 0x44, 0x88, 0x44 };

byte result[16] = { 0x88, 0x44, 0x88, 0x44,
                  0x88, 0x44, 0x88, 0x44,
                  0x88, 0x44, 0x88, 0x44, 
                  0x88, 0x44, 0x88, 0x44 };

//Sample key
byte key[16] = { 0x88, 0x44, 0x88, 0x44,
                 0x88, 0x44, 0x88, 0x44,
                 0x88, 0x44, 0x88, 0x44, 
                 0x88, 0x44, 0x88, 0x44 };

//Generate random Initialization Vector
byte iv[16];
CryptoPP::AutoSeededRandomPool rnd;
rnd.GenerateBlock(iv, CryptoPP::AES::BLOCKSIZE /*16*/);

//Through VisualStudio debug/watch functionality I have found out that Crypto++ randomizer works properly so at this point "iv" contains random values

CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption tmp(key, 16, iv, 1);
tmp.ProcessData(data, result, 16);

The problem is that after last line of code in this part (tmp.ProcessData(data, result, 16);) nothing in result changes. I was guided by this official tutorial: https://www.cryptopp.com/wiki/Advanced_Encryption_Standard

来源:https://stackoverflow.com/questions/43352882/aes-cfb-encryption-with-crypto-not-working

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