At 07:24 PM 4/8/2003 +0530, you wrote:
Hi,
I've got terrible problems with cryptlib.
I have two seperate applications, one is a general purpose key generator and the other is an application that uses cryptlib.
After some trouble I managed to get the keygen to puke out the same output given an input and vice versa.
I did the same to the application.
Now the trouble is when I use the output from the keygen as an input to the application, it doesn't give me the correct result.
Here's what the code looks like:
bool Obfuscate(char * szSrc, BYTE * sEncrypted, int * iBufferSize) { try { CryptoPP::RijndaelEncryption rEnc(ENCRYPTIONKEY); memset(sEncrypted, 0, *iBufferSize); int iSize = strlen(szSrc); if(iSize > *iBufferSize) { return false; }
if(iSize < *iBufferSize && (*iBufferSize - iSize - 1) > 0)
memset(&szSrc[iSize], 0, *iBufferSize - iSize - 1); // ensure rest of array is empty
// compute no of 16 byte blocks
int nBlocks;
if(iSize % 16 == 0)
nBlocks = iSize/16;
else
nBlocks = iSize/16 + 1; // last block will be padded with 0s
for(int i = 0; i < nBlocks; i++) { rEnc.ProcessBlock((BYTE *)&szSrc[i*16], (BYTE *)&sEncrypted[i*16]); } *iBufferSize = nBlocks * 16; } catch(CryptoPP::Exception &e) { return false; } catch(std::exception &e) { return false; } catch(...) { return false; } return true; }
Now, what is the problem??
Why should two different programs including the _same_copy_ of the library be unable to yield the same result?
The only difference is that one of the apps uses the above code as a member function (of a class) and the other uses it as a raw function (no class).
I picture myself as going bald trying to solve the problem... and I'm only 25!! :)
I can provide the project settings if required, but they're absolutely the same.
