note 89419 rejected from function.mcrypt-decrypt by danbrown

From: Date: Sat, 07 Mar 2009 00:07:20 +0000
Subject: note 89419 rejected from function.mcrypt-decrypt by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151576@lists.php.net to get a copy of this message
Note Submitter: bbroerman at bbroerman dot net ---- I am trying to use PHP decode to decrypt a message that was encrypted using the BSD implementation of Rijndael in CBC mode with a zero filled IV, with the data encoded in base64. I implemented the program using the BSD source for the crypt/rijndael library. The key was in hex, so I converted it to binary with a call to pack('H*', $key) in the call to mcrypt_encrypt. the php code is: $decoded = base64_decode($cryptext); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); // split the input into the iv and the message. $iv = substr($decoded,0,$iv_size); $string = substr($decoded,$iv_size); // decrypt it. $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, pack('H*', $key), $string, MCRYPT_MODE_CBC, $iv); $plaintext = utf8_decode($decrypted); When I decrypt a message/key produced by PHP it works fine. When I decrypt a message/key produced by the C program, I get garbage back. I also tried doing different things with the iv block, as I noticed that PHP needs 32 characters, and the C methods need 16. Thanks in advance...

« previous php.notes (#151576) next »