Annotation of embedaddon/php/ext/openssl/tests/bug37820.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: openssl_sign/verify: accept different algos
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded("openssl")) die("skip");
! 6: if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: $dir = dirname(__FILE__);
! 11: $file_pub = $dir . '/bug37820cert.pem';
! 12: $file_key = $dir . '/bug37820key.pem';
! 13:
! 14: $priv_key = file_get_contents($file_key);
! 15: $priv_key_id = openssl_get_privatekey($priv_key);
! 16:
! 17:
! 18:
! 19: $pub_key = file_get_contents($file_pub);
! 20: $pub_key_id = openssl_get_publickey($pub_key);
! 21: $data = "some custom data";
! 22: if (!openssl_sign($data, $signature, $priv_key_id, OPENSSL_ALGO_MD5)) {
! 23: echo "openssl_sign failed.";
! 24: }
! 25:
! 26: $ok = openssl_verify($data, $signature, $pub_key_id, OPENSSL_ALGO_MD5);
! 27: if ($ok == 1) {
! 28: echo "Ok";
! 29: } elseif ($ok == 0) {
! 30: echo "openssl_verify failed.";
! 31: }
! 32:
! 33:
! 34: ?>
! 35: --EXPECTF--
! 36: Ok
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>