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 paramters tests 16var_dump(openssl_encrypt($data, $wrong, $password)); 17var_dump(openssl_encrypt($object, $method, $password)); 18var_dump(openssl_encrypt($data, $object, $password)); 19var_dump(openssl_encrypt($data, $method, $object)); 20var_dump(openssl_encrypt($arr, $method, $object)); 21var_dump(openssl_encrypt($data, $arr, $object)); 22var_dump(openssl_encrypt($data, $method, $arr)); 23 24// invalid using of an authentication tag 25var_dump(openssl_encrypt($data, $method, $password, 0, $iv, $wrong)); 26 27// padding of the key is disabled 28var_dump(openssl_encrypt($data, $method, $password, OPENSSL_DONT_ZERO_PAD_KEY, $iv)); 29?> 30--EXPECTF-- 31Warning: openssl_encrypt(): Unknown cipher algorithm in %s on line %d 32bool(false) 33 34Warning: openssl_encrypt() expects parameter 1 to be string, object given in %s on line %d 35NULL 36 37Warning: openssl_encrypt() expects parameter 2 to be string, object given in %s on line %d 38NULL 39 40Warning: openssl_encrypt() expects parameter 3 to be string, object given in %s on line %d 41NULL 42 43Warning: openssl_encrypt() expects parameter 1 to be string, array given in %s on line %d 44NULL 45 46Warning: openssl_encrypt() expects parameter 2 to be string, array given in %s on line %d 47NULL 48 49Warning: openssl_encrypt() expects parameter 3 to be string, array given in %s on line %d 50NULL 51 52Warning: openssl_encrypt(): The authenticated tag cannot be provided for cipher that doesn not support AEAD in %s on line %d 53string(44) "iPR4HulskuaP5Z6me5uImk6BqVyJG73+63tkPauVZYk=" 54 55Warning: openssl_encrypt(): Key length cannot be set for the cipher method in %s on line %d 56bool(false) 57