1--TEST-- 2openssl_private_decrypt() tests 3--EXTENSIONS-- 4openssl 5--FILE-- 6<?php 7$data = "Testing openssl_public_decrypt()"; 8$privkey = "file://" . __DIR__ . "/private_rsa_1024.key"; 9$pubkey = "file://" . __DIR__ . "/public.key"; 10$wrong = "wrong"; 11 12openssl_public_encrypt($data, $encrypted, $pubkey, OPENSSL_PKCS1_OAEP_PADDING); 13var_dump(openssl_private_decrypt($encrypted, $output, $privkey, OPENSSL_PKCS1_OAEP_PADDING)); 14var_dump($output); 15var_dump(openssl_private_decrypt($encrypted, $output2, $wrong, OPENSSL_PKCS1_OAEP_PADDING)); 16var_dump($output2); 17var_dump(openssl_private_decrypt($wrong, $output3, $privkey, OPENSSL_PKCS1_OAEP_PADDING)); 18var_dump($output3); 19 20try { 21 var_dump(openssl_private_decrypt($encrypted, $output4, array($privkey), OPENSSL_PKCS1_OAEP_PADDING)); 22 var_dump($output4); 23} catch (\ValueError $e) { 24 echo $e->getMessage() . \PHP_EOL; 25} 26 27var_dump(openssl_private_decrypt($encrypted, $output5, array($privkey, ""), OPENSSL_PKCS1_OAEP_PADDING)); 28var_dump($output5); 29?> 30--EXPECTF-- 31bool(true) 32string(32) "Testing openssl_public_decrypt()" 33 34Warning: openssl_private_decrypt(): key parameter is not a valid private key in %s on line %d 35bool(false) 36NULL 37bool(false) 38NULL 39Key array must be of the form array(0 => key, 1 => phrase) 40bool(true) 41string(32) "Testing openssl_public_decrypt()" 42