1

This is how the code look likes. Is there anything wrong with this. The recover text does not match.

AES::Encryption aes1(key, key.size());
CFB_Mode_ExternalCipher::Encryption cfbEncryption(aes1, iv);
AES::Decryption aes2(key, key.size());
CFB_Mode_ExternalCipher::Decryption cfbDecryption(aes2, iv);

ArraySink cipherSink(cipher, data_size);
ArraySource ss1(plain, data_size, true, new StreamTransformationFilter(cfbEncryption, new Redirector(cipherSink)));

ArraySink recoverSink(recover, data_size);
ArraySource ss2(cipher, data_size, true, new StreamTransformationFilter(cfbDecryption, new Redirector(recoverSink)));
Jinto Jose
  • 21
  • 4

1 Answers1

1

When using CTR Mode External Cipher in transformation, encryption is used for decryption as well.

https://www.codeproject.com/Articles/21877/Applied-Crypto-Block-Ciphers

Jinto Jose
  • 21
  • 4
  • An assert should fire in Debug builds to alert you of the problem: `CRYPTOPP_ASSERT(m_cipher->IsForwardTransformation());`. Also see [`modes.cpp : 35`](https://github.com/weidai11/cryptopp/blob/master/modes.cpp#L33). – jww Oct 03 '19 at 23:24