summaryrefslogtreecommitdiff
path: root/ext/openssl/tests/bug70438.phpt
blob: 5d493e99a26ac9788da2db6f2641cb2e0c93b732 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--TEST--
Request #70438: Add IV parameter for openssl_seal and openssl_open
--SKIPIF--
<?php
if (!extension_loaded("openssl")) print "skip";
if (!in_array('AES-128-CBC', openssl_get_cipher_methods(true))) {
    print "skip";
}
?>
--FILE--
<?php
$data = "openssl_seal() test";
$cipher = 'AES-128-CBC';
$pub_key = "file://" . __DIR__ . "/public.key";
$priv_key = "file://" . __DIR__ . "/private_rsa_1024.key";

try {
    openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), $cipher);
} catch (\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}

openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), 'sparkles', $iv);
openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), $cipher, $iv);
openssl_open($sealed, $decrypted, $ekeys[0], $priv_key, $cipher, $iv);
echo $decrypted;
?>
--EXPECTF--
openssl_seal(): Argument #6 ($initialization_vector) cannot be null for the chosen cipher algorithm

Warning: openssl_seal(): Unknown cipher algorithm in %s on line %d
openssl_seal() test