Commit graph

1992 commits

Author SHA1 Message Date
Niels Dossche
5a19e25347
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix inverted call to php_openssl_store_errors()
  Fix openssl_random_pseudo_bytes() always setting strong_result to true
2025-04-02 20:30:44 +02:00
Niels Dossche
a6e76ac010
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix inverted call to php_openssl_store_errors()
  Fix openssl_random_pseudo_bytes() always setting strong_result to true
2025-04-02 20:25:32 +02:00
Niels Dossche
5e68671f88
Fix inverted call to php_openssl_store_errors()
This calls php_openssl_store_errors() in the success path right now,
change it to call php_openssl_store_errors() in the error path.
2025-04-02 20:25:21 +02:00
Niels Dossche
0dc600c69a
Fix openssl_random_pseudo_bytes() always setting strong_result to true
This regressed in 62c7432f, prior to that commit the value was set to
false in case random number generation failed, but now even if an
exception is thrown it is set to true. This likely does not _really_
matter as the user will handle the exception, still the value in
$strong_result is observable.
2025-04-02 20:25:21 +02:00
Niels Dossche
a39725b793
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak in openssl_sign() when passing invalid algorithm
2025-04-02 20:24:13 +02:00
Niels Dossche
d689ff63e8
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak in openssl_sign() when passing invalid algorithm
2025-04-02 20:18:57 +02:00
Niels Dossche
74720a22f3
Fix memory leak in openssl_sign() when passing invalid algorithm
Closes GH-18185.
2025-04-02 20:15:53 +02:00
Jakub Zelenka
0d10f7bfe5
Remove OpenSSL 1.0.2 related code (#18032)
This also removes old LibreSSL checks as minimum that compiles is 3.5.0
2025-03-13 10:59:26 +01:00
Jakub Zelenka
2e7b6dac31
Merge branch 'PHP-8.4' 2025-02-28 14:52:37 +01:00
Jakub Zelenka
4936c32772
Merge branch 'PHP-8.3' into PHP-8.4 2025-02-28 14:51:52 +01:00
Jakub Zelenka
6bb56fe0cf
Change openssl_x509_verify test to use cert generator (#17882)
This also prevents verifying cert with SHA1 signature
2025-02-28 14:51:12 +01:00
Gina Peter Banyard
78714d0fc5
ext/openssl: Use zend_result return type instead of int where applicable (#17721) 2025-02-06 16:59:43 +00:00
Jakub Zelenka
d662ab5f08
Introduce openssl backend for v1 and v3 API separation (#16918)
The main purpose of this is to better handle the API difference and add
an inital work to separate PHP and OpenSSL logic. This is really just
the first step and further changes are coming after that.

Closes GH-16918
2025-02-06 15:50:05 +01:00
Christoph M. Becker
107bd080a5
Fix Clang style nits (GH-17685)
This addresses all `-Wlogical-op-parentheses` and `-Wmissing-braces`
warnings across the whole code base (all Windows specific code).
2025-02-05 14:13:56 +01:00
Christoph M. Becker
aa76127d01
Address more Clang warnings (GH-17506)
We prefer clean solutions (such as declaring the proper type in the
first place, or introducing a portable format specifier) where easily
possible, but resort to casts otherwise.

We also port f1480ab14b.
2025-01-21 20:05:29 +01:00
Jakub Zelenka
b072206313
Merge branch 'PHP-8.4' 2024-12-31 15:25:17 +01:00
Jakub Zelenka
d2977b026f
Merge branch 'PHP-8.3' into PHP-8.4 2024-12-31 15:20:06 +01:00
Jakub Zelenka
e0dabe326f
Merge branch 'PHP-8.2' into PHP-8.3 2024-12-31 15:05:18 +01:00
Jakub Zelenka
37504f123d
Port OpenSSL gh10495, gh13860 and gh9310 test to use ephemeral ports 2024-12-31 15:02:08 +01:00
Jakub Zelenka
44a9154e75
Merge branch 'PHP-8.1' into PHP-8.2 2024-12-31 14:39:59 +01:00
Jakub Zelenka
b8731767d8
Fix GH-16955: Use empheral ports for OpenSSL server client tests
And refactor some client server tests.

Closes GH-17180
2024-12-31 14:25:19 +01:00
Christoph M. Becker
300811f1e2
Remove support for unsupported MSVC versions (GH-17128)
As of PHP 8.4.0, MSVC >= 1920 (aka. Visual Studio 2019 RTW 16.0) is
required anyway[1], so we can clean up a bit.

[1] <b3d6414b87>
2024-12-12 19:50:14 +01:00
Niels Dossche
ef1e1868ed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix wrong merge
2024-11-09 11:49:16 +01:00
Niels Dossche
80dd5a0306
Fix wrong merge 2024-11-09 11:49:08 +01:00
Niels Dossche
fd68e9ba2c
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak in php_openssl_pkey_from_zval()
  Fix various memory leaks related to openssl exports
  Prevent unexpected array entry conversion when reading key
2024-11-09 11:01:29 +01:00
Niels Dossche
591fe92724
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix memory leak in php_openssl_pkey_from_zval()
  Fix various memory leaks related to openssl exports
  Prevent unexpected array entry conversion when reading key
2024-11-09 11:01:21 +01:00
Niels Dossche
994e866cf2
Fix memory leak in php_openssl_pkey_from_zval()
Closes GH-16691.
2024-11-09 10:58:44 +01:00
Niels Dossche
2f4f09f7e6
Fix various memory leaks related to openssl exports
Closes GH-16692.
2024-11-09 10:58:17 +01:00
Niels Dossche
ac8d0e57d9
Prevent unexpected array entry conversion when reading key
When passing an array, the key entry can get converted to a string if it
is an object, but this actually modifies the original array entry.
The test originally outputted:

```
array(2) {
  [0]=>
  string(...) => ...
  [1]=>
  string(0) ""
}
```

This is unexpected. Use zval_try_get_string() to prevent this behaviour.

Closes GH-16693.
2024-11-09 10:57:50 +01:00
Niels Dossche
faef0dfb49
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix various memory leaks on error conditions in openssl_x509_parse()
2024-11-04 20:04:51 +01:00
Niels Dossche
673e8d1011
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix various memory leaks on error conditions in openssl_x509_parse()
2024-11-04 20:04:18 +01:00
Niels Dossche
5ddb75660d
Fix various memory leaks on error conditions in openssl_x509_parse()
Closes GH-16690.
2024-11-04 20:03:53 +01:00
Christoph M. Becker
ef1c3b82ff
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16433: Large values for openssl_csr_sign() $days overflow
2024-10-16 11:10:12 +02:00
Christoph M. Becker
931762c626
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16433: Large values for openssl_csr_sign() $days overflow
2024-10-16 11:09:00 +02:00
Christoph M. Becker
2bdf2f9100
Fix GH-16433: Large values for openssl_csr_sign() $days overflow
The `offset_sec` parameter of `X509_gmtime_adj()` expects a `long`, but
the `$days` parameter of `openssl_csr_sign()` a `zend_long`.  We must
avoid signed integer overflow (UB), but also must not silently truncate.
Thus we check the given `$days` for the permissible range, and bail out
otherwise.

Closes GH-16437.
2024-10-16 11:08:02 +02:00
Christoph M. Becker
33fab73730
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16357: openssl may modify member types of certificate arrays
2024-10-12 16:07:50 +02:00
Christoph M. Becker
76a819e7d1
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16357: openssl may modify member types of certificate arrays
2024-10-12 16:06:44 +02:00
Christoph M. Becker
549bcdb7fb
Fix GH-16357: openssl may modify member types of certificate arrays
We must not use `try_convert_to_string()` on members of unseparated
array arguments; instead of separating, we use `zval_try_get_string()`.

Closes GH-16370.
2024-10-12 16:05:31 +02:00
Jakub Zelenka
53cc92c85c
Fix failing openssl_private_decrypt tests
We backport 11caf094f1af6b47ea2138c5fa907838911ebe01[1] as a step to
get back to a green CI.

[1] <11caf094f1>
2024-10-07 01:06:04 +02:00
Jakub Zelenka
e05121563f
Merge branch 'PHP-8.3' into PHP-8.4 2024-09-28 16:29:18 +01:00
Jakub Zelenka
37a73a83c3
Merge branch 'PHP-8.2' into PHP-8.3 2024-09-28 16:24:01 +01:00
Jakub Zelenka
dce0d97640
Fix stub for openssl_csr_new 2024-09-28 16:22:08 +01:00
Christoph M. Becker
5121acaa66
Support --with-openssl-argon2 on Windows (GH-15713)
We change the error for ZTS builds to a warning, to not break snapshot
builds which automatically will try to enable OpenSSL password hashing.

We also change some messages to better fit building on Windows.

And of course, we cannot easily check whether `OSSL_set_max_threads()`
is actually available; instead we're looking up the function declaration
in its header file.

Co-authored-by: Peter Kokot <peterkokot@gmail.com>
2024-09-15 17:06:50 +02:00
DanielEScherzer
db545767e5
Rename ZEND_STR_DEPRECATED to ZEND_STR_DEPRECATED_CAPITALIZED (#15831)
To match other capitalized strings like `ZEND_STR_UNKNOWN_CAPITALIZED` and
`ZEND_STR_ARRAY_CAPITALIZED`. Since this known string was only added in PHP
8.4, no backwards compatibility alias is needed.
2024-09-10 22:45:23 +01:00
Christoph M. Becker
6732b8892d
Support --openssl-legacy-providers on Windows, too (GH-15747)
This is not necessarily useful for Windows (few use custom builds on
that platform), but for feature parity with other platforms it seems
reasonable to support it on Windows.

We make sure, though, that the feature is not enabled for snapshot
builds by adding the option to the build exclusions.
2024-09-05 10:49:16 +02:00
DanielEScherzer
5dd0575698
Generated arginfo header files: combine preprocessor conditional blocks (#15736)
When functions' or class methods' availability is based on some preprocessor
condition, the generated arginfo header files wrap the declarations in the
preprocessor `#if` conditional blocks, one per declaration, even if they are in
the same conditional block based on comments in the stub file. Instead of
having multiple conditional blocks one after the other with the same condition,
combine them into a single conditional block.
2024-09-04 13:04:22 +02:00
DanielEScherzer
53cb89670c
Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
When a class (or enum) has no methods, rather than using an array that only
contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of
class registration for internal classes, `do_register_internal_class()` in
zend_API.c, already skips classes where the functions are `NULL`. By removing
these unneeded arrays, we can reduce the size of the header files, while also
removing an unneeded call to zend_register_functions() for each internal class
with no extra methods.
2024-09-03 23:19:53 +02:00
Peter Kokot
45ebe47569
Autotools: Sync CS in ext/openssl 2024-09-02 18:39:11 +02:00
Remi Collet
32c5ce3451
Implement GH-13514 PASSWORD_ARGON2 from OpenSSL 3.2 (#13635)
* Implement GH-13514 PASSWORD_ARGON2 from OpenSSL 3.2

* simplify init/shutdown

* use php_base64_encode_ex

* - rename macros - use openssl RAND_bytes - CS

* add --with-openssl-argon2 build option

* check OSSL_KDF_PARAM_ARGON2_LANES instead of OSSL_set_max_threads

* Cleanup and CS

* save/restore old threads config + CS

* remove unneeded check
2024-09-02 13:01:09 +02:00
Máté Kocsis
8d12f666ae
Fix registration of internal readonly child classes (#15459)
Currently, internal classes are registered with the following code:

INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;

This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.

The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
2024-08-24 12:36:54 +02:00