Commit Graph

195 Commits

Author SHA1 Message Date
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
Nikita Popov
f6d7af21a3 Null terminate the sodium_crypto_kx_keypair() result 2020-08-14 15:51:31 +02:00
Nikita Popov
86072d60de Reduce cost factors in sodium password_hash tests
Drop the 4x factors to make these tests a bit less obscenely
slow.
2020-08-14 15:39:42 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Nikita Popov
978b7de244 Accept zend_object* in zend_get_exception_base 2020-08-07 16:40:27 +02:00
Nikita Popov
7991fc2753 Accept zend_object in zend_read_property 2020-08-07 16:40:27 +02:00
Máté Kocsis
bdacd2ae8f
Add a few missing types to stubs 2020-08-01 23:55:08 +02:00
Nikita Popov
c9b9f525a9 Include stub hash in generated arginfo files
The hash is used to check whether the arginfo file needs to be
regenerated. PHP-Parser will only be downloaded if this is actually
necessary.

This ensures that release artifacts will never try to regenerate
stubs and thus fetch PHP-Parser, as long as you do not modify any
files.

Closes GH-5739.
2020-06-24 09:55:19 +02:00
George Peter Banyard
a2a6c7f227 Add -Wno-type-limits compiler flag to Sodium extension
This may happen on 32bits
2020-04-14 22:22:33 +02:00
Máté Kocsis
3709e74b5e
Store default parameter values of internal functions in arg info
Closes GH-5353. From now on, PHP will have reflection information
about default values of parameters of internal functions.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-04-08 18:37:51 +02:00
Máté Kocsis
21cfa03f17
Generate function entries for another batch of extensions
Closes GH-5352
2020-04-05 21:15:30 +02:00
Máté Kocsis
a43bc33fb2
Annotate function aliases in stubs 2020-04-04 13:03:16 +02:00
Máté Kocsis
118b04bd6e
Improve argument error messages in ext/sodium
Closes GH-5197
2020-02-28 18:09:39 +01:00
Máté Kocsis
960318ed95
Change argument error message format
Closes GH-5211
2020-02-26 15:00:08 +01:00