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