1
0
mirror of https://github.com/php/php-src.git synced 2026-03-28 10:12:18 +01:00
Commit Graph

208 Commits

Author SHA1 Message Date
Niels Dossche
af444f97e1 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix memory leaks in ext/sodium on failure of some functions
2024-05-23 22:40:54 +02:00
Niels Dossche
4da46107c4 Fix memory leaks in ext/sodium on failure of some functions
Infallible in practice right now, but should be fixed as infallible today does not mean infallible tomorrow:
- sodium_crypto_sign_publickey_from_secretkey
- sodium_crypto_kx_seed_keypair
- sodium_crypto_kx_keypair
- sodium_crypto_auth
- sodium_crypto_sign_ed25519_sk_to_curve25519
- sodium_pad

Fallible today:
- sodium_crypto_sign_ed25519_pk_to_curve25519

Closes GH-14309.
2024-05-23 22:40:28 +02:00
George Peter Banyard
d5ad75108e More usage of known zend_str instead of C string (#11381) 2023-06-08 13:03:29 +01:00
Ilija Tovilo
9d5f2f1343 Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Jorg Adam Sowa
77ee92a50c Remove unnecessary usage of CONST_CS
Closes GH-9685.
2022-11-28 17:12:07 +01:00
Tim Düsterhus
03fd405423 Use php_info_print_table_header for actual column headers only (#9485)
Using php_info_print_table_header() for "Foo: bar" looks odd and out of place,
because the whole line is colored. It is also questionable from a HTML
semantics point of view, because it does not described the columns that follow.

The use of this across extensions is inconsistent. It was part of the skeleton,
but ext/date or ext/json already use a regular row.
2022-09-06 08:48:22 +02:00
Máté Kocsis
b4ec3e9bc0 Do not generate CONST_CS when registering constants (#9439) 2022-08-28 08:27:19 +02:00
Máté Kocsis
4679805cd6 Declare ext/sodium constants in stubs (#9225) 2022-08-02 13:57:52 +02:00
Remi Collet
55a88f36b6 add SensitiveParameter as known string and use it in arginfo 2022-07-18 11:43:33 +02:00
Tim Düsterhus
342e18f105 Support the actual #[\SensitiveParameter] attribute in stubs (#8836) 2022-07-12 12:43:44 +02:00
Máté Kocsis
49d3dde211 Declare true return types (#8759) 2022-06-18 22:06:50 +02:00
Pierrick Charron
6fd2b39397 Indent with TAB in .h files generated by gen_stub 2022-06-13 08:55:54 -04:00
Tim Düsterhus
8f8243318d Mark parameter in ext/sodium as sensitive 2022-06-13 11:09:12 +02:00
Christoph M. Becker
d03a94a0a6 Use proper types in sodium_crypto_stream_xchacha20_xor_ic()
Most importantly, `ic` needs to be of type `zend_long`, not `zend_long*`.

Closes GH-8302.
2022-04-05 16:34:12 +02:00
George Peter Banyard
2fe35cf807 Regenerate optimized func infos
Using the --generate-optimizer-info option for ./build/gen_stubs.php
2022-04-05 13:36:14 +01:00
Paragon Initiative Enterprises
afd8f84c1a Add sodium_crypto_stream_xchacha20_xor_ic()
There are many use-cases where a PHP user is currently using sodium_compat's implementation of this low-level XChaCha20 API. For example, multi-part message processing (in low-memory settings) for a ciphertext that was encrypted with XChaCha20-Poly1305 (rather than the secretstream API).

Adding this function to ext/sodium offers better performance and lowers users' memory usage with the polyfill, and ensures that users coming from other languages that provide libsodium bindings have a more consistent experience with our bindings. This is a win-win.

This patch follows the libsodium precedent of adding functions instead of optional parameters to existing functions. The parameter order is also consistent with the C API.

https://doc.libsodium.org/advanced/stream_ciphers/xchacha20#usage

Closes GH-8276.
2022-04-04 15:43:42 +02:00
Máté Kocsis
f7d9594dbd Merge branch 'PHP-8.1'
* PHP-8.1:
  Remove extra space before return type
2021-10-18 14:29:35 +02:00
Máté Kocsis
10a2079b13 Remove extra space before return type
For consistency and searchability reasons
2021-10-18 14:28:46 +02:00
Nikita Popov
bce040ddf2 Merge branch 'PHP-8.1'
* PHP-8.1:
  Set opline before calling undef op helper
  Add more specific array return type hints for various extensions - part 6 (#7474)
2021-10-07 14:40:48 +02:00
Máté Kocsis
d9e5e63032 Add more specific array return type hints for various extensions - part 6 (#7474) 2021-10-07 14:29:29 +02:00
Máté Kocsis
ad471fb22d Merge branch 'PHP-8.1'
* PHP-8.1:
  Remove extra space before param default values
  Fix class synopsis generation for interfaces
2021-09-08 12:25:13 +02:00
Máté Kocsis
a5e5483439 Remove extra space before param default values 2021-09-08 12:24:47 +02:00
Máté Kocsis
a1a8e9032c Remove unnecessary PHP_FUNCTION() declarations (#7472) 2021-09-07 10:04:00 +02:00
Máté Kocsis
765aec8623 Generate optimizer func info from stubs for ext/sodium (#7404) 2021-08-26 10:44:38 +02:00
Nikita Popov
2addab1561 Comment out ristretto255 scalar invert test
This fails intermittently depending on which random scalar is
picked.
2021-08-10 12:04:47 +02:00
Nikita Popov
98184afd92 Improve ristretto255 scalarmult exception messages
These fail due to bad inputs, not internal errors.
2021-08-10 11:19:29 +02:00
Nikita Popov
f31db20956 Add missing parts of previous commit 2021-08-10 11:12:08 +02:00
Nikita Popov
9168aab381 Fix ristretto255 tests
Both tests were skipped because of a typo in the checked constant
name.

The scalarmult test was using illegal test vectors. The new test
is based on:
6d566070b4/test/default/scalarmult_ristretto255.c

The $L value contained one extra null byte. The number of "false"
return values was too small.

scalar_invert() doesn't return a valid point -- not sure on that
one.
2021-08-10 11:10:55 +02:00
Nikita Popov
6600ad6067 Add some missing EXTENSIONS sections to misc tests 2021-06-14 14:52:44 +02:00
Nikita Popov
39131219e8 Migrate more SKIPIF -> EXTENSIONS (#7139)
This is a mix of more automated and manual migration. It should remove all applicable extension_loaded() checks outside of skipif.inc files.
2021-06-11 12:58:44 +02:00
Nikita Popov
a9695aa155 Merge branch 'PHP-8.0'
* PHP-8.0:
  Correct the argument names for ext/sodium functions
2021-05-10 17:22:41 +02:00
Paragon Initiative Enterprises
0c57ebb116 Correct the argument names for ext/sodium functions
Closes GH-6969.
2021-05-10 17:22:02 +02:00
P.I.E. Security Team
9b794f8e5e Expose libsodium's Ristretto255 API (#6922) 2021-05-07 17:43:00 -05:00
KsaR
01b3fc03c3 Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
6adfe9da98 Fix error messages for sodium_crypto_stream_xchacha20
And test them. Also adjust the constant check in the test so that
it actually runs.
2021-04-19 11:10:37 +02:00
P.I.E. Security Team
f7f1f7fce2 Add crypto_stream_xchacha20 to ext/sodium (#6868)
Paragon Initiative Enterprises is aware of PHP applications that use sodium_compat's ParagonIE\Sodium\Core\XChaCha20 class directly for stream encryption.

Greater performance and security assurance is offered by exposing libsodium's crypto_stream_xchacha20 API to PHP users.

It's acceptable to only include this change in PHP 8.1+; the offending applications are more than welcome to either install ext/sodium from PECL or upgrade to 8.1 when it comes out later this year.

Ref: https://github.com/jedisct1/libsodium-php/pull/211
2021-04-19 11:04:29 +02:00
Max Semenik
6c9a05667b run-tests: use the EXTENSIONS section for skipping
Currently, most skip checks are just for making sure an extension is
available. Even with recent addition of skip caching, this makes tests
needlessly slow:
* Checks for the same extension in its tests can have small differences
  impacting cacheability.
* Even identical skip checks in two tests can still be executed twice if
  they're run by different workers.

To remedy this, I'm repurposing the existing --EXTENSIONS-- section of
.phpt files to specify wjich extensions are required for current test to
run. Current behavior:
1) If the extension is already visible to PHP, all is good
2) If it isn't, assume it's present as a shared module and attempt to add
   it via a command line parameter
3) If that works, all is good
4) If it doesn't, PHP fails with a cryptic error message trying to
   execute the test itself

After this commit:
1) and 2) are kept unchanged
3) Check if shared extension file from 2) is actually present
4) Skip the test if it isn't

Other benefits include clear skip reasons (vs. sometimes none in many
current skip checks) and moving test information from code to metadata,
opening more opportunities for search and analysis.

Since --EXTENSIONS-- is barely ever used, this change poses no risk of
hidden failures.

As a demonstration of the new approach, this commit migrates one
extension to it. If merged, I will migrate other extensions in
subsequent PRs.

Closes GH-6787.
2021-03-22 09:53:38 +01:00
Máté Kocsis
bf0f6aaf18 Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Máté Kocsis
a730dc0cf9 Generate class entries for snmp, soap, sockets, sodium, sqlite3, sysv*, tidy
Closes GH-6696
2021-02-15 11:45:26 +01:00
Nikita Popov
b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Closes GH-6475.
2021-02-11 21:46:13 +01:00
Christoph M. Becker
042e0d89bd Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing stub for SodiumException
2021-01-28 23:26:26 +01:00
Christoph M. Becker
49ef8bc026 Add missing stub for SodiumException
Closes GH-6649.
2021-01-28 23:25:59 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
19eb1b8602 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update ext/sodium parameter names
2020-10-13 10:41:43 +02:00
Nikita Popov
8c68745f43 Update ext/sodium parameter names
Closes GH-6279.
2020-10-13 10:41:35 +02:00
George Peter Banyard
3c84f65683 Add -Wno-logical-op compiler flag to Sodium extension 2020-10-10 17:26:49 +01:00
Máté Kocsis
c37a1cd650 Promote a few remaining errors in ext/standard
Closes GH-6110
2020-09-15 14:26:16 +02:00
Máté Kocsis
9975986b7e Improve error messages mentioning parameters instead of arguments
Closes GH-5999
2020-09-09 10:47:43 +02:00
Nikita Popov
124260c165 Merge branch 'PHP-7.4'
* PHP-7.4:
  Null terminate the sodium_crypto_kx_keypair() result
2020-08-14 15:52:31 +02:00
Nikita Popov
5885eecf23 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Null terminate the sodium_crypto_kx_keypair() result
2020-08-14 15:52:15 +02:00