xref: /PHP-8.0/ext/openssl/tests/bug60632.phpt (revision fa5a25b8)
1--TEST--
2Bug #60632: openssl_seal fails with AES
3--SKIPIF--
4<?php
5if (!extension_loaded("openssl")) die("skip openssl not loaded");
6?>
7--FILE--
8<?php
9
10$pkey = openssl_pkey_new(array(
11    'digest_alg' => 'sha256',
12    'private_key_bits' => 1024,
13    'private_key_type' => OPENSSL_KEYTYPE_RSA,
14    'encrypt_key' => false,
15    'config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf',
16));
17$details = openssl_pkey_get_details($pkey);
18$test_pubkey = $details['key'];
19$pubkey = openssl_pkey_get_public($test_pubkey);
20$encrypted = null;
21$ekeys = array();
22
23try {
24    $result = openssl_seal('test phrase', $encrypted, $ekeys, array($pubkey), 'AES-256-CBC');
25} catch (\ValueError $e) {
26    echo $e->getMessage() . \PHP_EOL;
27}
28?>
29--EXPECT--
30openssl_seal(): Argument #6 ($iv) cannot be null for the chosen cipher algorithm
31