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:
. Fixed bug GH-9064 (PHP fails to build if openssl was built with --no-ec).
(Jakub Zelenka)
. Fixed bug GH-10000 (OpenSSL test failures when OpenSSL compiled with
no-dsa). (Jakub Zelenka)
- Pcntl:
. 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 */
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);
#endif
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) {
case OPENSSL_KEYTYPE_RSA:
return EVP_PKEY_RSA;
#if !defined(NO_DSA)
#if !defined(OPENSSL_NO_DSA)
case OPENSSL_KEYTYPE_DSA:
return EVP_PKEY_DSA;
#endif
@ -3811,7 +3811,7 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req
}
switch (type) {
#if !defined(NO_DSA)
#if !defined(OPENSSL_NO_DSA)
case EVP_PKEY_DSA:
if (EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, req->priv_key_bits) <= 0) {
php_openssl_store_errors();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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