Fix GH-19369: openssl_sign() - support for alias digest algs broken

Closes GH-19436
This commit is contained in:
Jakub Zelenka 2025-08-09 20:07:23 +02:00
parent bc475ada13
commit c8d7318daf
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4
3 changed files with 34 additions and 0 deletions

4
NEWS
View file

@ -20,6 +20,10 @@ PHP NEWS
- MySQLi:
. The mysqli_execute() alias function has been deprecated. (timwolla)
- OpenSSL:
. Fixed bug GH-19369 (8.5 | Regression in openssl_sign() - support for alias
algorithms appears to be broken). (Jakub Zelenka)
- PDO:
. The "uri:" DSN scheme has been deprecated due to security concerns with
DSNs coming from remote URIs. (timwolla)

View file

@ -713,6 +713,12 @@ zend_string *php_openssl_dh_compute_key(EVP_PKEY *pkey, char *pub_str, size_t pu
const EVP_MD *php_openssl_get_evp_md_by_name(const char *name)
{
const EVP_MD *dp = (const EVP_MD *) OBJ_NAME_get(name, OBJ_NAME_TYPE_MD_METH);
if (dp != NULL) {
return dp;
}
return EVP_MD_fetch(PHP_OPENSSL_LIBCTX, name, PHP_OPENSSL_PROPQ);
}

View file

@ -0,0 +1,24 @@
--TEST--
GH-19369: openssl_sign with alias algorithms
--EXTENSIONS--
openssl
--SKIPIF--
<?php
if (!in_array('sha256WithRSAEncryption', openssl_get_md_methods(true))) {
die('skip sha256WithRSAEncryption alias not present');
}
?>
--FILE--
<?php
$digests = openssl_get_md_methods();
$digests_and_aliases = openssl_get_md_methods(true);
$digest_aliases = array_diff($digests_and_aliases, $digests);
$data = "Testing openssl_sign() with alias algorithm";
$privkey = "file://" . __DIR__ . "/private_rsa_1024.key";
var_dump(openssl_sign($data, $sign, $privkey, 'sha256WithRSAEncryption'));
?>
--EXPECT--
bool(true)