diff -r bd595ad770fc -r 1c2f13fd785c web/enmi/Zend/InfoCard/Cipher/Symmetric/Adapter/Aes256cbc.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/enmi/Zend/InfoCard/Cipher/Symmetric/Adapter/Aes256cbc.php Thu Jan 20 19:30:54 2011 +0100 @@ -0,0 +1,111 @@ + 0) { + $mcrypt_iv = substr($encryptedData, 0, $iv_length); + $encryptedData = substr($encryptedData, $iv_length); + } + + $decrypted = mcrypt_decrypt(self::MCRYPT_CIPHER, $decryptionKey, $encryptedData, self::MCRYPT_MODE, $mcrypt_iv); + + if(!$decrypted) { + require_once 'Zend/InfoCard/Cipher/Exception.php'; + throw new Zend_InfoCard_Cipher_Exception("Failed to decrypt data using AES256CBC Algorithm"); + } + + $decryptedLength = strlen($decrypted); + $paddingLength = substr($decrypted, $decryptedLength -1, 1); + $decrypted = substr($decrypted, 0, $decryptedLength - ord($paddingLength)); + + return rtrim($decrypted, "\0"); + } +}