xref: /PHP-8.1/ext/openssl/tests/bug41033.phpt (revision 500b28ad)
1--TEST--
2#41033, enable signing with DSA keys
3--EXTENSIONS--
4openssl
5--SKIPIF--
6<?php
7if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
8?>
9--FILE--
10<?php
11$prv = 'file://' . __DIR__ . '/' . 'bug41033.pem';
12$pub = 'file://' . __DIR__ . '/' . 'bug41033pub.pem';
13
14
15$prkeyid = openssl_get_privatekey($prv, "1234");
16$ct = "Hello I am some text!";
17openssl_sign($ct, $signature, $prkeyid, OPENSSL_ALGO_SHA256);
18echo "Signature: ".base64_encode($signature) . "\n";
19
20$pukeyid = openssl_get_publickey($pub);
21$valid = openssl_verify($ct, $signature, $pukeyid, OPENSSL_ALGO_SHA256);
22echo "Signature validity: " . $valid . "\n";
23
24
25?>
26--EXPECTF--
27Signature: %s
28Signature validity: 1
29