When I try to decrypt a packet, I find there are something wrong if the packet
is decrypted twice. Does anyone know the reason?
Thanks!
Sample code:
byte* convData; // store the original packet
uint convSize; // store the size of original packet
CryptoPP:: StreamTransformation* m_cipher = new
CBC_Mode<DES_EDE3>::Decryption;
CryptoPP::Filter* m_coder = new StreamTransformationFilter(*m_cipher,
NULL, CryptoPP::StreamTransformationFilter::DEFAULT_PADDING);
m_coder->PutMessageEnd(convData, convSize);
m_coder->PutMessageEnd(convData, convSize);
unsigned int outputLength = m_coder->MaxRetrievable();
unsigned char* outbuff = (unsigned char*) cryptopp_new(sizeof(unsigned
char)*(outputLength+1));
//Here, the output packet is correct
m_coder->Get((byte*)outbuff, outputLength);
m_coder->GetNextMessage();
//while here the output packet is wrong
m_coder->Get((byte*)outbuff, outputLength);
m_coder->GetNextMessage();