Hi, I had the following code working well in crypto++ 4.2 on Mac/PPC (compiled with CodeWarrior):
SecByteBlock cipherText(dataSize); err = FSRead(refNum, &dataSize, cipherText.Begin()); FSClose(refNum); // I keep the IV at the end of the file, read it in memcpy(outIV, cipherText.Begin() + cipherText.Size() - kIVSize, kIVSize); RijndaelDecryption rijnDecryption(inKey, kKeySize); CBCPaddedDecryptor cbcDecryptor(rijnDecryption, outIV); cbcDecryptor.PutMessageEnd(cipherText, cipherText.Size() - kIVSize); long retrievable = cbcDecryptor.MaxRetrievable(); outData.Resize(retrievable); cbcDecryptor.Get(routData.Begin(), retrievable); Now I'm trying to update the same code to work with 5.5.2, and I now do this: SecBlock<char> ciphertext(len); fread(ciphertext.begin(), sizeof(char), len, file); fclose(file); // Read the IV from the end of the file size_t ivSize = sizeof(iv); memcpy(iv, ciphertext.begin() + ciphertext.size() - ivSize, ivSize); ciphertext.resize(ciphertext.size() - ivSize); RijndaelDecryption decryption(key, Rijndael::DEFAULT_KEYLENGTH); CBC_Mode_ExternalCipher::Decryption cbcDecryptor(decryption, iv); string decryptedtext; StreamTransformationFilter stf(cbcDecryptor, new StringSink (decryptedtext)); stf.Put(ciphertext.BytePtr(), ciphertext.size()); stf.MessageEnd(); In stf.MessageEnd(), I get an exception: StreamTransformationFilter: invalid PKCS #7 block padding found I'm guessing it might have something to do with byte ordering, since the original data was generated on PPC, and now I am running on Intel. Do I need to do any byte reversing myself on the key, iv or other data? If so, do I reverse word16 or word32? Thanks for your help, - Aparajita --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~---
