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