Fix GH-10000: Test failures when OpenSSL compiled with no-dsa

This commit is contained in:
Jakub Zelenka 2022-11-25 14:02:03 +00:00
parent 4987e65a70
commit 500b28ad04
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4
11 changed files with 40 additions and 4 deletions

2
NEWS
View file

@ -29,6 +29,8 @@ PHP NEWS
- OpenSSL: - OpenSSL:
. Fixed bug GH-9064 (PHP fails to build if openssl was built with --no-ec). . Fixed bug GH-9064 (PHP fails to build if openssl was built with --no-ec).
(Jakub Zelenka) (Jakub Zelenka)
. Fixed bug GH-10000 (OpenSSL test failures when OpenSSL compiled with
no-dsa). (Jakub Zelenka)
- Pcntl: - Pcntl:
. Fixed bug GH-9298 (Signal handler called after rshutdown leads to crash). . Fixed bug GH-9298 (Signal handler called after rshutdown leads to crash).

View file

@ -1347,7 +1347,7 @@ PHP_MINIT_FUNCTION(openssl)
/* Values for key types */ /* Values for key types */
REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_RSA", OPENSSL_KEYTYPE_RSA, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_RSA", OPENSSL_KEYTYPE_RSA, CONST_CS|CONST_PERSISTENT);
#ifndef NO_DSA #ifndef OPENSSL_NO_DSA
REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_DSA", OPENSSL_KEYTYPE_DSA, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_DSA", OPENSSL_KEYTYPE_DSA, CONST_CS|CONST_PERSISTENT);
#endif #endif
REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_DH", OPENSSL_KEYTYPE_DH, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_DH", OPENSSL_KEYTYPE_DH, CONST_CS|CONST_PERSISTENT);
@ -3759,7 +3759,7 @@ static int php_openssl_get_evp_pkey_type(int key_type) {
switch (key_type) { switch (key_type) {
case OPENSSL_KEYTYPE_RSA: case OPENSSL_KEYTYPE_RSA:
return EVP_PKEY_RSA; return EVP_PKEY_RSA;
#if !defined(NO_DSA) #if !defined(OPENSSL_NO_DSA)
case OPENSSL_KEYTYPE_DSA: case OPENSSL_KEYTYPE_DSA:
return EVP_PKEY_DSA; return EVP_PKEY_DSA;
#endif #endif
@ -3811,7 +3811,7 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req
} }
switch (type) { switch (type) {
#if !defined(NO_DSA) #if !defined(OPENSSL_NO_DSA)
case EVP_PKEY_DSA: case EVP_PKEY_DSA:
if (EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, req->priv_key_bits) <= 0) { if (EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, req->priv_key_bits) <= 0) {
php_openssl_store_errors(); php_openssl_store_errors();

View file

@ -2,6 +2,10 @@
#41033, enable signing with DSA keys #41033, enable signing with DSA keys
--EXTENSIONS-- --EXTENSIONS--
openssl openssl
--SKIPIF--
<?php
if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
?>
--FILE-- --FILE--
<?php <?php
$prv = 'file://' . __DIR__ . '/' . 'bug41033.pem'; $prv = 'file://' . __DIR__ . '/' . 'bug41033.pem';

View file

@ -2,6 +2,10 @@
Bug #73711: Segfault in openssl_pkey_new when generating DSA or DH key Bug #73711: Segfault in openssl_pkey_new when generating DSA or DH key
--EXTENSIONS-- --EXTENSIONS--
openssl openssl
--SKIPIF--
<?php
if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
?>
--FILE-- --FILE--
<?php <?php
$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'; $config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';

View file

@ -1,8 +1,10 @@
--TEST-- --TEST--
Bug #81713 (OpenSSL functions null byte injection) Bug #81713 (OpenSSL functions null byte injection)
--EXTENSIONS--
openssl
--SKIPIF-- --SKIPIF--
<?php <?php
if (!extension_loaded("openssl")) die("skip openssl not loaded"); if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -2,6 +2,10 @@
openssl_csr_export() tests openssl_csr_export() tests
--EXTENSIONS-- --EXTENSIONS--
openssl openssl
--SKIPIF--
<?php
if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
?>
--FILE-- --FILE--
<?php <?php
$wrong = "wrong"; $wrong = "wrong";

View file

@ -2,6 +2,10 @@
openssl_csr_export_to_file() tests openssl_csr_export_to_file() tests
--EXTENSIONS-- --EXTENSIONS--
openssl openssl
--SKIPIF--
<?php
if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
?>
--FILE-- --FILE--
<?php <?php
$csrfile = __DIR__ . "/openssl_csr_export_to_file_csr.tmp"; $csrfile = __DIR__ . "/openssl_csr_export_to_file_csr.tmp";

View file

@ -2,6 +2,10 @@
openssl_csr_get_public_key() tests openssl_csr_get_public_key() tests
--EXTENSIONS-- --EXTENSIONS--
openssl openssl
--SKIPIF--
<?php
if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
?>
--FILE-- --FILE--
<?php <?php
$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'; $config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';

View file

@ -2,6 +2,10 @@
openssl_csr_get_subject() tests openssl_csr_get_subject() tests
--EXTENSIONS-- --EXTENSIONS--
openssl openssl
--SKIPIF--
<?php
if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
?>
--FILE-- --FILE--
<?php <?php
$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'; $config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';

View file

@ -2,6 +2,10 @@
openssl_csr_sign() tests openssl_csr_sign() tests
--EXTENSIONS-- --EXTENSIONS--
openssl openssl
--SKIPIF--
<?php
if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
?>
--FILE-- --FILE--
<?php <?php
$cert = "file://" . __DIR__ . "/cert.crt"; $cert = "file://" . __DIR__ . "/cert.crt";

View file

@ -2,6 +2,10 @@
openssl_pkey_new() basic usage tests openssl_pkey_new() basic usage tests
--EXTENSIONS-- --EXTENSIONS--
openssl openssl
--SKIPIF--
<?php
if (!defined("OPENSSL_KEYTYPE_DSA")) die("skip DSA disabled");
?>
--FILE-- --FILE--
<?php <?php
function openssl_pkey_test_cmp($expected, $bin_key) { function openssl_pkey_test_cmp($expected, $bin_key) {