1--TEST--
2openssl_seal() tests
3--EXTENSIONS--
4openssl
5--FILE--
6<?php
7// simple tests
8$a = 1;
9$b = array(1);
10$c = array(1);
11$d = array(1);
12$method = "AES-128-ECB";
13
14var_dump(openssl_seal($a, $b, $c, $d, $method));
15
16try {
17    var_dump(openssl_seal($a, $a, $a, array(), $method));
18} catch (\ValueError $e) {
19    echo $e->getMessage() . \PHP_EOL;
20}
21
22// tests with cert
23$data = "openssl_open() test";
24$pub_key = "file://" . __DIR__ . "/public.key";
25$wrong = "wrong";
26
27var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key), $method));           // no output
28var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key), $method)); // no output
29var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key, $wrong), $method));
30
31try {
32    var_dump(openssl_seal($data, $sealed, $ekeys, array(), $method));
33} catch (\ValueError $e) {
34    echo $e->getMessage() . \PHP_EOL;
35}
36
37var_dump(openssl_seal($data, $sealed, $ekeys, array($wrong), $method));
38
39?>
40--EXPECTF--
41Warning: openssl_seal(): Not a public key (1th member of pubkeys) in %s on line %d
42bool(false)
43openssl_seal(): Argument #4 ($public_key) cannot be empty
44int(32)
45int(32)
46
47Warning: openssl_seal(): Not a public key (2th member of pubkeys) in %s on line %d
48bool(false)
49openssl_seal(): Argument #4 ($public_key) cannot be empty
50
51Warning: openssl_seal(): Not a public key (1th member of pubkeys) in %s on line %d
52bool(false)
53