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
|
2007-05-28 21:55:30 +08:00
|
|
|
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)) {
|
2018-06-21 23:38:19 +08:00
|
|
|
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) {
|
2018-06-21 23:38:19 +08:00
|
|
|
echo "Ok";
|
2006-07-30 06:27:55 +08:00
|
|
|
} elseif ($ok == 0) {
|
2018-06-21 23:38:19 +08:00
|
|
|
echo "openssl_verify failed.";
|
2006-07-30 06:27:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
2018-02-19 16:59:41 +08:00
|
|
|
--EXPECT--
|
2006-07-30 06:27:55 +08:00
|
|
|
Ok
|