1--TEST--
2openssl_encrypt() error tests
3--SKIPIF--
4<?php if (!extension_loaded("openssl")) print "skip"; ?>
5--FILE--
6<?php
7$data = "openssl_encrypt() tests";
8$method = "AES-128-CBC";
9$password = "openssl";
10$iv = str_repeat("\0", openssl_cipher_iv_length($method));
11$wrong = "wrong";
12$object = new stdclass;
13$arr = array(1);
14
15// wrong parameters tests
16var_dump(openssl_encrypt($data, $wrong, $password));
17
18// padding of the key is disabled
19var_dump(openssl_encrypt($data, $method, $password, OPENSSL_DONT_ZERO_PAD_KEY, $iv));
20?>
21--EXPECTF--
22Warning: openssl_encrypt(): Unknown cipher algorithm in %s on line %d
23bool(false)
24
25Warning: openssl_encrypt(): Key length cannot be set for the cipher algorithm in %s on line %d
26bool(false)
27