1--TEST-- 2openssl_public_decrypt() tests 3--SKIPIF-- 4<?php if (!extension_loaded("openssl")) print "skip"; ?> 5--FILE-- 6<?php 7$data = "Testing openssl_public_decrypt()"; 8$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key"; 9$pubkey = "file://" . dirname(__FILE__) . "/public.key"; 10$wrong = "wrong"; 11 12openssl_private_encrypt($data, $encrypted, $privkey); 13var_dump(openssl_public_decrypt($encrypted, $output, $pubkey)); 14var_dump($output); 15var_dump(openssl_public_decrypt($encrypted, $output2, $wrong)); 16var_dump($output2); 17var_dump(openssl_public_decrypt($wrong, $output3, $pubkey)); 18var_dump($output3); 19var_dump(openssl_public_decrypt($encrypted, $output4, array())); 20var_dump($output4); 21var_dump(openssl_public_decrypt($encrypted, $output5, array($pubkey))); 22var_dump($output5); 23var_dump(openssl_public_decrypt($encrypted, $output6, array($pubkey, ""))); 24var_dump($output6); 25?> 26--EXPECTF-- 27bool(true) 28string(32) "Testing openssl_public_decrypt()" 29 30Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d 31bool(false) 32NULL 33bool(false) 34NULL 35 36Warning: openssl_public_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d 37 38Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d 39bool(false) 40NULL 41 42Warning: openssl_public_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d 43 44Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d 45bool(false) 46NULL 47bool(true) 48string(32) "Testing openssl_public_decrypt()" 49