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