Hey Folks,
I'm trying to use Crypto++ in conjunction with php's mcrypt on a server.
I'm using Rijndael 128 bit with CBC in both crypto++ and mcrypt. Using the
same key and IV, I can encrypt a message in crypto++, pass the encrypted
string to my php script and have mcrypt decrypt it just fine. However,
taking a plain string in php, encrypting it, and passing it to crypto++
causes crypto++ crashes, looks like it's trying to access a bad pointer or
unallocated memory.
The base64 encoded IV matches in both php and c++, however if I encrypt the
same string via both crypto++ and mcrypt, the respective base64 encoded
encrypted strings do not match. I suspect this may be a symptom of my
problem.
Does anyone know where the incompatibility between taking an mcrypt
encrypted string and decrypting it with crypto++ comes from? I find it
strange that it works from crypto++ to mcrypt but not vice versa... On a
side note, I can take an mcrypt encrypted string and decrypt it in C#, so
I'm assuming there's some odd issue with my crypto++ setup.
Without posting too much code, in PHP, I'm encrypting using:
$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $decrypted,
MCRYPT_MODE_CBC, $iv);
In C++ I'm encrypting using:
this->cbcDecryption = new CryptoPP::CBC_Mode< CryptoPP::Rijndael
>::Decryption( key, CryptoPP::Rijndael::DEFAULT_KEYLENGTH, iv );
CryptoPP::StreamTransformationFilter stfDecryptor((*this->cbcDecryption),
new CryptoPP::StringSink( decryptedString ) );
stfDecryptor.Put( reinterpret_cast<const unsigned char*>(
encryptedString.c_str() ), encryptedString.size() );
stfDecryptor.MessageEnd();
Can anyone offer any advice/insight?
Thanks,
André
--
--
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.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.