xref: /PHP-5.4/ext/openssl/tests/015.phpt (revision 15823900)
1--TEST--
2openssl_public_encrypt() tests
3--SKIPIF--
4<?php if (!extension_loaded("openssl")) print "skip"; ?>
5--FILE--
6<?php
7$data = "Testing openssl_public_encrypt()";
8$privkey = "file://" . dirname(__FILE__) . "/private.key";
9$pubkey = "file://" . dirname(__FILE__) . "/public.key";
10$wrong = "wrong";
11class test {
12        function __toString() {
13                return "test";
14        }
15}
16$obj = new test;
17
18var_dump(openssl_public_encrypt($data, $encrypted, $pubkey));
19var_dump(openssl_public_encrypt($data, $encrypted, $privkey));
20var_dump(openssl_public_encrypt($data, $encrypted, $wrong));
21var_dump(openssl_public_encrypt($data, $encrypted, $obj));
22var_dump(openssl_public_encrypt($obj, $encrypted, $pubkey));
23openssl_private_decrypt($encrypted, $output, $privkey);
24var_dump($output);
25?>
26--EXPECTF--
27bool(true)
28
29Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d
30bool(false)
31
32Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d
33bool(false)
34
35Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d
36bool(false)
37bool(true)
38string(4) "test"
39
40