Annotation of embedaddon/php/ext/openssl/tests/017.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: openssl_private_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.key";
! 9: $pubkey = "file://" . dirname(__FILE__) . "/public.key";
! 10: $wrong = "wrong";
! 11:
! 12: openssl_public_encrypt($data, $encrypted, $pubkey);
! 13: var_dump(openssl_private_decrypt($encrypted, $output, $privkey));
! 14: var_dump($output);
! 15: var_dump(openssl_private_decrypt($encrypted, $output2, $wrong));
! 16: var_dump($output2);
! 17: var_dump(openssl_private_decrypt($wrong, $output3, $privkey));
! 18: var_dump($output3);
! 19: var_dump(openssl_private_decrypt($encrypted, $output4, array($privkey)));
! 20: var_dump($output4);
! 21: var_dump(openssl_private_decrypt($encrypted, $output5, array($privkey, "")));
! 22: var_dump($output5);
! 23: ?>
! 24: --EXPECTF--
! 25: bool(true)
! 26: string(32) "Testing openssl_public_decrypt()"
! 27:
! 28: Warning: openssl_private_decrypt(): key parameter is not a valid private key in %s on line %d
! 29: bool(false)
! 30: NULL
! 31: bool(false)
! 32: NULL
! 33:
! 34: Warning: openssl_private_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d
! 35:
! 36: Warning: openssl_private_decrypt(): key parameter is not a valid private key in %s on line %d
! 37: bool(false)
! 38: NULL
! 39: bool(true)
! 40: string(32) "Testing openssl_public_decrypt()"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>