Skip to content

Commit c8d7318

Browse files
committed
Fix GH-19369: openssl_sign() - support for alias digest algs broken
Closes GH-19436
1 parent bc475ad commit c8d7318

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ PHP NEWS
2020
- MySQLi:
2121
. The mysqli_execute() alias function has been deprecated. (timwolla)
2222

23+
- OpenSSL:
24+
. Fixed bug GH-19369 (8.5 | Regression in openssl_sign() - support for alias
25+
algorithms appears to be broken). (Jakub Zelenka)
26+
2327
- PDO:
2428
. The "uri:" DSN scheme has been deprecated due to security concerns with
2529
DSNs coming from remote URIs. (timwolla)

ext/openssl/openssl_backend_v3.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,12 @@ zend_string *php_openssl_dh_compute_key(EVP_PKEY *pkey, char *pub_str, size_t pu
713713

714714
const EVP_MD *php_openssl_get_evp_md_by_name(const char *name)
715715
{
716+
const EVP_MD *dp = (const EVP_MD *) OBJ_NAME_get(name, OBJ_NAME_TYPE_MD_METH);
717+
718+
if (dp != NULL) {
719+
return dp;
720+
}
721+
716722
return EVP_MD_fetch(PHP_OPENSSL_LIBCTX, name, PHP_OPENSSL_PROPQ);
717723
}
718724

ext/openssl/tests/gh19369.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-19369: openssl_sign with alias algorithms
3+
--EXTENSIONS--
4+
openssl
5+
--SKIPIF--
6+
<?php
7+
if (!in_array('sha256WithRSAEncryption', openssl_get_md_methods(true))) {
8+
die('skip sha256WithRSAEncryption alias not present');
9+
}
10+
?>
11+
--FILE--
12+
<?php
13+
$digests = openssl_get_md_methods();
14+
$digests_and_aliases = openssl_get_md_methods(true);
15+
$digest_aliases = array_diff($digests_and_aliases, $digests);
16+
17+
$data = "Testing openssl_sign() with alias algorithm";
18+
$privkey = "file://" . __DIR__ . "/private_rsa_1024.key";
19+
20+
var_dump(openssl_sign($data, $sign, $privkey, 'sha256WithRSAEncryption'));
21+
22+
?>
23+
--EXPECT--
24+
bool(true)

0 commit comments

Comments
 (0)