php-src/ext/openssl/tests/bug37820.phpt

35 lines
740 B
Plaintext
Raw Normal View History

2006-07-30 06:27:55 +08:00
--TEST--
2018-10-14 23:45:48 +08:00
openssl_sign/verify: accept different algos
2006-07-30 06:27:55 +08:00
--SKIPIF--
2018-10-14 23:45:48 +08:00
<?php
if (!extension_loaded("openssl")) die("skip");
2006-07-30 06:27:55 +08:00
?>
--FILE--
2018-10-14 23:45:48 +08:00
<?php
2006-07-30 06:27:55 +08:00
$dir = dirname(__FILE__);
$file_pub = $dir . '/bug37820cert.pem';
$file_key = $dir . '/bug37820key.pem';
$priv_key = file_get_contents($file_key);
$priv_key_id = openssl_get_privatekey($priv_key);
$pub_key = file_get_contents($file_pub);
$pub_key_id = openssl_get_publickey($pub_key);
$data = "some custom data";
if (!openssl_sign($data, $signature, $priv_key_id, OPENSSL_ALGO_MD5)) {
echo "openssl_sign failed.";
2006-07-30 06:27:55 +08:00
}
$ok = openssl_verify($data, $signature, $pub_key_id, OPENSSL_ALGO_MD5);
if ($ok == 1) {
echo "Ok";
2006-07-30 06:27:55 +08:00
} elseif ($ok == 0) {
echo "openssl_verify failed.";
2006-07-30 06:27:55 +08:00
}
?>
--EXPECT--
2006-07-30 06:27:55 +08:00
Ok