Commit Graph

195 Commits

Author SHA1 Message Date
Nikita Popov
7fc29c9924 Merge branch 'PHP-7.4'
* PHP-7.4:
  Enable ext/sodium in CI
  Add skipif for argon2id in test
2020-02-24 12:41:49 +01:00
Nikita Popov
6c0a33f2dc Add skipif for argon2id in test
If argon2i is provided by libargon, then argon2id may not be
available here.
2020-02-24 12:41:24 +01:00
Máté Kocsis
ac0853eb26
Make type error messages more consistent
Closes GH-5092
2020-02-17 14:22:17 +01:00
Nikita Popov
f8d795820e Reindent phpt files 2020-02-03 22:52:20 +01:00
Máté Kocsis
01a50778d1
Use RETURN_THROWS() after zend_throw_exception() in most of the extensions 2020-01-02 10:56:18 +01:00
Máté Kocsis
817605917b
Use RETURN_THROWS() during ZPP in the remaining extensions
In reflection, sodium, and SPL
2019-12-31 16:33:02 +01:00
Máté Kocsis
37c1171451
Promote warnings to exceptions in password_*() functions 2019-12-12 12:14:53 +01:00
Máté Kocsis
27e83d0fb8
Add union return types for function stubs 2019-11-11 14:54:55 +01:00
Christoph M. Becker
4008704f62 zend_parse_parameters_throw() is obsolete
Since `zend_parse_parameters()` throws now, there is no reason to
explicitly call `zend_parse_parameters_throw()` anymore, and since both
have actually the same implementation, we redefine the latter as macro.
2019-11-01 16:47:15 +01:00
Christoph M. Becker
f7c61c070f Add ext/sodium arginfo stubs 2019-10-21 10:19:57 +02:00
Christoph M. Becker
ed2c13ab07 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix wrong function name in SKIPIF
2019-09-27 23:02:51 +02:00
Fabien Villepinte
8c7b8d75db Fix wrong function name in SKIPIF 2019-09-27 23:01:48 +02:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Christoph M. Becker
145ffd93fc Fix #78516: password_hash(): Memory cost is not in allowed range
libsodium measures the memory cost in bytes, while password_hash() and
friends expect kibibyte values.  We have to properly map between these
scales not only when calling libsodium functions, but also when
checking for allowed values.

We also refactor to rid the code duplication.
2019-09-16 14:58:39 +02:00
Christoph M. Becker
280e40fadd Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Drop regression test
2019-09-10 10:08:42 +02:00
Christoph M. Becker
318b92dc12 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Drop regression test
2019-09-10 10:08:07 +02:00
Christoph M. Becker
bca66002f1 Drop regression test
The state returned by `sodium_crypto_generichash_init()` has to be
regarded as opaque byte string; neither its size nor its exact
structure are fixed, and actually vary for diffent libsodium versions.
Therefore we drop the test altogether.
2019-09-10 10:07:39 +02:00
Christoph M. Becker
167ea6307b Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78510: Partially uninitialized buffer returned by sodium_crypto_generichash_init()
2019-09-09 15:33:02 +02:00
Christoph M. Becker
af2033b1cd Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #78510: Partially uninitialized buffer returned by sodium_crypto_generichash_init()
2019-09-09 15:31:15 +02:00
Christoph M. Becker
8ead77936e Fix #78510: Partially uninitialized buffer returned by sodium_crypto_generichash_init()
Backport jedisct1/libsodium.php@28d13bf437.
2019-09-09 15:30:28 +02:00
Peter Kokot
1b969a74d0 Remove some unused HAVE_* symbols
- HAVE_NET_SNMP removed via cab643f615
- HAVE_CRYPTO_AEAD_AES256GCM ad120c5ae9
- Remove HAVE_FREETDS and HAVE_LIBDNET_STUB (not used in current
  extension; copy paste from other removed extensions)

Closes GH-4448
2019-07-21 11:34:18 +02:00
Sara Golemon
f65956e4fb
Relax argon2 mem_cost down to 64k, bump time_cost to 4 2019-07-09 11:36:48 -04:00
Sara Golemon
0ba1db7a4a Provide argon2i(d) password hashing from sodium when needed 2019-07-07 21:53:43 -04:00
Christoph M. Becker
b2b528b973 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78114: segfault when calling sodium_* functions from eval
2019-06-06 10:01:12 +02:00
Christoph M. Becker
22a3fa0b2e Fix #78114: segfault when calling sodium_* functions from eval
We must not follow the NULL pointer.
2019-06-06 10:00:15 +02:00
Remi Collet
9ef03a94ba sodium: fix shared build 2019-05-21 16:14:52 +02:00
Peter Kokot
75fb74860d Normalize comments in *nix build system m4 files
Normalization include:
- Use dnl for everything that can be ommitted when configure is built in
  favor of the shell comment character # which is visible in the output.
- Line length normalized to 80 columns
- Dots for most of the one line sentences
- Macro definitions include similar pattern header comments now
2019-05-12 18:43:03 +02:00
Peter Kokot
99b94fbb5c Remove redundant example/test libsodium.php file 2019-05-08 22:00:22 +02:00
Hugh McMaster
4bce02898d Use PKG_CHECK_MODULES to detect the libsodium library 2019-04-29 14:16:16 +02:00
Hugh McMaster
c9ee822bb6 Always use pkg-config from the host architecture 2019-04-29 14:16:16 +02:00
Sara Golemon
7e7fa77a2e
Validate interoperability between libsodium and libargon for argon2i(d) hashing 2019-03-27 00:36:36 -04:00
Peter Kokot
9df6a1e4dd Add AS_HELP_STRING to *nix build configure options
The Autoconf's default AS_HELP_STRING macro can properly format help
strings [1] so watching out if columns are aligned manually is not
anymore.

[1] https://www.gnu.org/software/autoconf/manual/autoconf.html#Pretty-Help-Strings
2019-03-07 20:36:59 +01:00
Frank Denis
08089b575b Fix bug #77646 2019-02-21 16:33:03 +01:00
Frank Denis
9609950331 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix bug #77646
2019-02-21 16:19:44 +01:00
Frank Denis
e7ca69f1fa Fix bug #77646 2019-02-21 16:14:33 +01:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Christoph M. Becker
cde2e35bf0 Merge branch 'PHP-7.3'
* PHP-7.3:
  Fix #77297: SodiumException segfaults on PHP 7.3
2018-12-16 16:37:15 +01:00
Scott
e0e08d376e Fix #77297: SodiumException segfaults on PHP 7.3
Instead of trying to clean the argument arrays from the backtrace, we
overwrite them with empty arrays.
2018-12-16 16:36:47 +01:00
Frank Denis
333f985163 Merge branch 'PHP-7.3'
* PHP-7.3:
  ext/sodium: remove redundant code
  ext/sodium: Correct base64 decoding with unpadded variants
2018-11-24 17:57:23 +01:00
Frank Denis
8e5381915b Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  ext/sodium: remove redundant code
  ext/sodium: Correct base64 decoding with unpadded variants
2018-11-24 17:56:33 +01:00
Frank Denis
ff02d50909 ext/sodium: remove redundant code 2018-11-24 17:55:36 +01:00
Frank Denis
542d0bce50 ext/sodium: Correct base64 decoding with unpadded variants
Backports 0eee0b957a3b75f8175cdd30b306c15e372685e8 from the PECL extension
2018-11-24 17:53:08 +01:00
Peter Kokot
0e60b812c0 Move all testing docs to qa.php.net
The qa.php.net currently includes nice collection of information about
tests and how to run them. Instead of maintaining two locations of this
information, this patch removes the README.TESTING from the php-src
repo. Patch for qa.php.net has been sent separately to that repo.
2018-10-18 08:01:22 +02:00
Peter Kokot
d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00
Peter Kokot
b746e69887 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:32:30 +02:00
Peter Kokot
f1d7e3ca0b Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:31:31 +02:00
Peter Kokot
1ad08256f3 Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:56:38 +02:00
Peter Kokot
1c850bfcca Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:55:24 +02:00
Peter Kokot
60a69daec6 Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:54:08 +02:00
Frank Denis
c4ea98455d Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  ext/sodium: sodium_pad(): do not copy any bytes if the string is empty
  ext/sodium: Fix sodium_pad() with blocksize >= 256
  ext/sodium: Use a correct max output size for base64 decoding
  ext/sodium: Avoid shifts wider than 32 bits on size_t values
2018-10-14 11:01:53 +02:00
Frank Denis
82a93c1794 ext/sodium: sodium_pad(): do not copy any bytes if the string is empty
Spotted by San Zhang, thanks!

Backport from PECL libsodium-php 2.0.13
2018-10-14 10:43:21 +02:00
Frank Denis
bf48d0c475 ext/sodium: Fix sodium_pad() with blocksize >= 256
Backport from PECL libsodium-php 2.0.12
2018-10-14 10:37:37 +02:00
Frank Denis
15ba7df224 ext/sodium: Use a correct max output size for base64 decoding
Also handle the case where the function is not available in test.

Backport from PECL libsodium-php 2.0.12
2018-10-14 10:37:18 +02:00
Frank Denis
d057458166 ext/sodium: Avoid shifts wider than 32 bits on size_t values
Backport from PECL libsodium-php 2.0.10
2018-10-14 10:21:29 +02:00
Nikita Popov
b617a5b2ea Merge branch 'PHP-7.2' into PHP-7.3 2018-09-29 21:20:01 +02:00
James Titcumb
950c338f80 Fix reflection arguments for sodium_memzero function 2018-09-29 21:19:42 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Nikita Popov
fc8f5b0f09 Merge branch 'PHP-7.2' 2018-06-08 23:02:25 +02:00
Keyur Govande
695b8192c7 Avoid leaking the urandom fd
When Apache is reloaded, it unloads the extension, but the open file descriptor to /dev/urandom is left hanging around and is leaked. This fixes the bug.

Duplicate of https://github.com/jedisct1/libsodium-php/pull/173
2018-06-08 23:01:57 +02:00
Dmitry Stogov
524f5245c5 Avoid useless checks, using zend_string_efree(), in cases where the string is known to be a temporary allocated zend_string. 2018-05-08 17:30:15 +03:00
Tom Van Looy
7672f8be0b
Fix: follow the indent of the other configure options 2018-02-15 08:49:58 +01:00
Gabriel Caruso
ce1d69a1f6 Use int instead of integer in type errors
PHP requires integer typehints to be written "int" and does not
allow "integer" as an alias. This changes type error messages to
match the actual type name and avoids confusing messages like
"must be of the type integer, integer given".
2018-02-04 19:08:23 +01:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Dmitry Stogov
9e709e2fa0 Move constants into read-only data segment 2017-12-14 18:43:44 +03:00
Frank Denis
fc8793499a Revert "Revert "ext/sodium: pwhash: do not warn on low parameters""
This reverts commit a1845b7fdb.

Revert "Revert "ext/sodium: throw exceptions instead of errors""
This reverts commit 31d221f9c7.
2017-11-29 13:19:56 +01:00
Frank Denis
a1845b7fdb Revert "ext/sodium: pwhash: do not warn on low parameters"
This reverts commit c219991c77.
2017-11-29 01:22:59 +01:00
Frank Denis
31d221f9c7 Revert "ext/sodium: throw exceptions instead of errors"
This reverts commit c05cbd1e77.
2017-11-28 23:30:21 +01:00
Frank Denis
c05cbd1e77 ext/sodium: throw exceptions instead of errors 2017-11-28 13:56:11 +01:00
Frank Denis
c219991c77 ext/sodium: pwhash: do not warn on low parameters
but raise an explicit error if these are too low
2017-11-28 11:24:49 +01:00
Anatol Belski
0e44c980f9 Fix uninitialized vars 2017-10-23 12:02:41 +02:00
Frank Denis
9d236d63f9 ext/sodium: untab tests 2017-10-02 22:28:46 +02:00
Frank Denis
1dc47286d1 ext/sodium: import secretstream test 2017-10-02 22:28:33 +02:00
Frank Denis
6de12a5f1e ext/sodium: sodium_compare() is always available 2017-10-02 22:23:53 +02:00
Frank Denis
40ab4c9d4e ext/sodium: fix funky indentation 2017-10-02 22:22:22 +02:00
Frank Denis
7fc396c15d ext/sodium: move pwhash_scrypt() after pwhash() 2017-10-02 22:19:55 +02:00
Frank Denis
986a9e879a ext/sodium: checks for crypto_box_SEALBYTES are not required 2017-10-02 22:11:29 +02:00
Frank Denis
4d1707b764 ext/sodium: explicitly include <string.h> 2017-10-02 22:10:30 +02:00
Frank Denis
0726d0be9f ext/sodium: zend_parse_parameters -> zend_parse_parameters_throw 2017-10-02 22:05:59 +02:00
Frank Denis
e4917d141a ext/sodium: fix funky indent on zend_parse_parameters_throw() calls 2017-10-02 22:02:47 +02:00
Frank Denis
72f7d0b184 ext/sodium: import bindings for secretstream 2017-10-02 21:59:51 +02:00
Frank Denis
7d53e65125 ext/sodium: add crypto_pwhash_str_needs_rehash()
Also properly define xchacha20poly1305_ietf_keygen()
2017-10-02 21:54:50 +02:00
Frank Denis
e22094eb13 ext/sodium: +base64 codecs (timing-safe) 2017-10-02 21:43:54 +02:00
Frank Denis
ad120c5ae9 ext/sodium: add arginfo definitions that will be required later
Don't check for existence of aesgcm symbols, since we only support
libsodium >= 1.0.8
2017-10-02 21:40:38 +02:00
Frank Denis
519ca1d53b ext/sodium: sort prototypes 2017-10-02 21:36:35 +02:00
Frank Denis
0663ca135d ext/sodium: fix pwhash_argon2i test 2017-10-01 16:00:41 +02:00
Frank Denis
33b4405d84 ext/sodium: call crypto_pwhash_argon2id() explicitly if required 2017-09-26 18:09:00 +02:00
Frank Denis
47d75394c9 ext/sodium: avoid tautological comparisons 2017-09-26 17:58:16 +02:00
Frank Denis
f64d00d684 ext/sodium: signing empty messages is fine 2017-09-26 17:37:04 +02:00
Frank Denis
8a52a61e3a ext/sodium: avoid negations on unsigned values 2017-09-21 17:46:01 +02:00
Frank Denis
fd86fdd7b8 ext/sodium: throw an exception if only the prefix of a hex string is valid 2017-09-19 14:37:21 +02:00
Sammy Kaye Powers
b786e1b45c Improve sodium "invalid parameters" error messages 2017-09-07 22:18:48 +02:00
Sammy Kaye Powers
a8862d215c Fix a few places where ZPP throw got reverted to ZPP 2017-09-05 16:39:24 +02:00
Anatol Belski
752fc86f2b Fix symbol name 2017-08-30 01:11:19 +02:00
Frank Denis
04c87ea815 ext/sodium: the second parameter of sodium_hex2bin() is optional 2017-08-29 19:25:01 +02:00
Frank Denis
b1a7885dd7 ext/sodium: AI_StringRef_And_String -> AI_StringRefAndString for consistency 2017-08-29 19:23:22 +02:00
Frank Denis
6383c6e3d0 ext/sodium: sort functions list 2017-08-29 19:22:17 +02:00
Sammy Kaye Powers
56a999885a Fix constant references in error messages in ext/sodium 2017-08-28 22:16:35 -04:00
Frank Denis
48907e57ff sodium ext: if it's a length, call it "length"! 2017-08-24 16:17:41 +02:00