xref: /php-src/ext/openssl/tests/bug37820.phpt (revision 74859783)
1--TEST--
2openssl_sign/verify: accept different algos
3--EXTENSIONS--
4openssl
5--FILE--
6<?php
7$dir = __DIR__;
8$file_pub = $dir . '/bug37820cert.pem';
9$file_key = $dir . '/bug37820key.pem';
10
11$priv_key = file_get_contents($file_key);
12$priv_key_id = openssl_get_privatekey($priv_key);
13
14
15$pub_key = file_get_contents($file_pub);
16$pub_key_id = openssl_get_publickey($pub_key);
17$data = "some custom data";
18if (!openssl_sign($data, $signature, $priv_key_id, OPENSSL_ALGO_MD5)) {
19    echo "openssl_sign failed.";
20}
21
22$ok = openssl_verify($data, $signature, $pub_key_id, OPENSSL_ALGO_MD5);
23if ($ok == 1) {
24    echo "Ok";
25} elseif ($ok == 0) {
26    echo "openssl_verify failed.";
27}
28
29
30?>
31--EXPECT--
32Ok
33