/** * Raw unauthenticated decryption (insecure on its own). * * @param string $ciphertext * @param string $key * @param string $iv * @param string $cipherMethod * * @throws Ex\EnvironmentIsBrokenException * * @return string */ protected static function plainDecrypt($ciphertext, $key, $iv, $cipherMethod) { Core::ensureConstantExists('OPENSSL_RAW_DATA'); Core::ensureFunctionExists('openssl_decrypt'); $plaintext = \openssl_decrypt($ciphertext, $cipherMethod, $key, OPENSSL_RAW_DATA, $iv); if ($plaintext === false) { throw new Ex\EnvironmentIsBrokenException('openssl_decrypt() failed.'); } return $plaintext; }
/** * You MUST NOT call this method directly. * * Unauthenticated message deryption. * * @param string $ciphertext * @param string $key * @param string $iv * @param array $config * @return string * @throws Ex\CannotPerformOperationException */ protected static function plainDecrypt($ciphertext, $key, $iv, $config) { Core::ensureConstantExists("OPENSSL_RAW_DATA"); Core::ensureFunctionExists("openssl_decrypt"); $plaintext = \openssl_decrypt($ciphertext, $config->cipherMethod(), $key, OPENSSL_RAW_DATA, $iv); if ($plaintext === false) { throw new Ex\CannotPerformOperationException("openssl_decrypt() failed."); } return $plaintext; }