2008-07-19 07:52:01 +08:00
|
|
|
--TEST--
|
|
|
|
openssl_encrypt() error tests
|
|
|
|
--SKIPIF--
|
|
|
|
<?php if (!extension_loaded("openssl")) print "skip"; ?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
$data = "openssl_encrypt() tests";
|
|
|
|
$method = "AES-128-CBC";
|
|
|
|
$password = "openssl";
|
2016-01-10 01:25:53 +08:00
|
|
|
$iv = str_repeat("\0", openssl_cipher_iv_length($method));
|
2008-07-19 07:52:01 +08:00
|
|
|
$wrong = "wrong";
|
|
|
|
$object = new stdclass;
|
|
|
|
$arr = array(1);
|
|
|
|
|
2018-02-05 08:16:50 +08:00
|
|
|
// wrong parameters tests
|
2008-07-19 07:52:01 +08:00
|
|
|
var_dump(openssl_encrypt($data, $wrong, $password));
|
2016-01-10 01:25:53 +08:00
|
|
|
|
|
|
|
// invalid using of an authentication tag
|
|
|
|
var_dump(openssl_encrypt($data, $method, $password, 0, $iv, $wrong));
|
2017-06-26 01:08:50 +08:00
|
|
|
|
|
|
|
// padding of the key is disabled
|
|
|
|
var_dump(openssl_encrypt($data, $method, $password, OPENSSL_DONT_ZERO_PAD_KEY, $iv));
|
2008-07-19 07:52:01 +08:00
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
Warning: openssl_encrypt(): Unknown cipher algorithm in %s on line %d
|
|
|
|
bool(false)
|
|
|
|
|
2016-01-10 01:25:53 +08:00
|
|
|
Warning: openssl_encrypt(): The authenticated tag cannot be provided for cipher that doesn not support AEAD in %s on line %d
|
|
|
|
string(44) "iPR4HulskuaP5Z6me5uImk6BqVyJG73+63tkPauVZYk="
|
2017-06-26 01:08:50 +08:00
|
|
|
|
|
|
|
Warning: openssl_encrypt(): Key length cannot be set for the cipher method in %s on line %d
|
|
|
|
bool(false)
|