xref: /PHP-8.0/ext/openssl/tests/bug70438.phpt (revision effa3b08)
1--TEST--
2Request #70438: Add IV parameter for openssl_seal and openssl_open
3--SKIPIF--
4<?php
5if (!extension_loaded("openssl")) print "skip";
6if (!in_array('AES-128-CBC', openssl_get_cipher_methods(true))) {
7    print "skip";
8}
9?>
10--FILE--
11<?php
12$data = "openssl_seal() test";
13$cipher = 'AES-128-CBC';
14$pub_key = "file://" . __DIR__ . "/public.key";
15$priv_key = "file://" . __DIR__ . "/private_rsa_1024.key";
16
17try {
18    openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), $cipher);
19} catch (\ValueError $e) {
20    echo $e->getMessage() . \PHP_EOL;
21}
22
23openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), 'sparkles', $iv);
24openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), $cipher, $iv);
25openssl_open($sealed, $decrypted, $ekeys[0], $priv_key, $cipher, $iv);
26echo $decrypted;
27?>
28--EXPECTF--
29openssl_seal(): Argument #6 ($iv) cannot be null for the chosen cipher algorithm
30
31Warning: openssl_seal(): Unknown cipher algorithm in %s on line %d
32openssl_seal() test
33