Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ext/openssl/openssl_backend_v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
24 changes: 24 additions & 0 deletions ext/openssl/tests/gh19369.phpt
Original file line number Diff line number Diff line change
@@ -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)