I have an existing data format that has parts of it encrypted in what seems to be AES in CFB mode. The length of the text data and the length of the encrypted data are the same.
In C #, almost every angle I took seems to expect the encrypted length to be a multiple of the block size ... so I get an exception trying to decrypt the data.
When researching solutions, I used Crypto ++ and wrote a quick C ++ application that successfully decrypts the data, so I'm sure I use the correct algorithm, key and IV. This works great, but I would like to keep everything inside C #, if at all possible. Any suggestions?
The working C ++ code is below:
unsigned char key[16];
unsigned char iv[16];
std::ifstream inFile;
inFile.open("file.aes",ios::binary );
inFile.seekg(0,ios::end);
int fileSize = (int) inFile.tellg();
inFile.seekg(offset, ios::beg);
char* inBytes = new char[fileSize];
inFile.read(inBytes,fileSize);
inFile.close();
CFB_Mode<AES>::Decryption cfbDecryption(key, 16, iv);
char* outBytes = new char[fileSize];
cfbDecryption.ProcessData((byte*) outBytes,(byte*) inBytes,fileSize);
std::ofstream outFile;
outFile.open("out.dec");
outFile.write(outBytes,fileSize);
outFile.close();
delete[] inBytes;