Commit Graph

165 Commits

Author SHA1 Message Date
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
Frank Denis
3691f36913 sodium ext: add bindings for sodium_pad() and sodium_unpad() 2017-08-24 16:12:18 +02:00
Frank Denis
cf6f25bd37 sodium ext: restore sodium_remove_param_values_from_backtrace() call 2017-08-24 11:01:08 +02:00
Frank Denis
a966d21aa8 sodium ext: sync sodium_crypto_kdf_derive_from_key() with the standalone ext
Use libsodium's native function if available, use correct constant names
in error messages
2017-08-24 10:59:02 +02:00
Frank Denis
271f0c4f90 sodium ext: Constants were renamed SODIUM_*
Adjust error messages accordingly.
2017-08-24 10:50:34 +02:00
Frank Denis
3fff74aab5 sodium ext: If sodium_init() returns 1, this is fine.
We actually want to do this so that multiple extensions using libsodium
can be loaded simultaneously.
2017-08-22 09:40:38 +02:00
Sammy Kaye Powers
e8f552aeba Remove param values from backtrace in exception thrown from ZPP throw 2017-08-19 15:18:41 +02:00
Sammy Kaye Powers
0591fe2494 Change zend_parse_parameters() to zend_parse_parameters_throw() in ext/sodium 2017-08-19 15:16:45 +02:00
Frank Denis
ef0bd7b215 sodium ext: Use _ietf_ vs _IETF_ consistently 2017-08-08 17:50:17 +02:00
Frank Denis
03314e3f69 sodium ext: No need for #ifdef crypto_aead_chacha20poly1305_IETF_
chacha20poly1305_ietf was implemented in libsodium 1.0.4 which is way earlier
than the minimum version we support.
2017-08-08 17:42:38 +02:00
Frank Denis
596a892c5e Sodium ext: Isolate a return statement for consistency 2017-08-08 17:38:13 +02:00
Frank Denis
a0d1e0915c sodium ext: The default password hashing function is not supposed to be Argon2i 2017-08-08 17:37:06 +02:00
Frank Denis
631fc3c9c1 sodium ext: long -> zend_long 2017-08-08 17:36:06 +02:00
Frank Denis
3140d40421 sodium ext: Add missing "return" statements after zend_throw_exception() 2017-08-08 17:34:20 +02:00
Frank Denis
34df3cdafa sodium ext: skip scrypt if it is not available
scrypt was removed from minimal libsodium builds in version 1.0.13
2017-07-30 15:41:34 +02:00
Frank Denis
650f68c36e sodium ext: fix tests/pwhash_argon2i description 2017-07-30 15:05:21 +02:00
Frank Denis
74d7f1d04e sodium ext: check hash length for scrypt 2017-07-30 15:00:03 +02:00
Frank Denis
85895b2e5b sodium ext: no need for #ifdef crypto_aead_chacha20poly1305_IETF_NPUBBYTES
chacha20poly1305_ietf was implemented in libsodium 1.0.4 which is way earlier
than the minimum version we support.
2017-07-30 14:47:49 +02:00
Frank Denis
1d7e1f845f sodium ext: check that message sizes are safe, to avoid hitting abort() in libsodium 2017-07-30 14:45:06 +02:00
Frank Denis
ae99959986 sodium ext: use unexpand -t 4 --first-only to convert from spaces to tabs
No actual code changes.

Fun fact: macOS' unexpand(1) tool doesn't work as documented, and always
converts everything to tabs, regardless of the -a switch.
2017-07-30 14:34:55 +02:00
Frank Denis
613c8dd7b0 sodium ext: let crypto_pwhash() accept an optional algorithm identifier 2017-07-29 13:04:54 +02:00
Sammy Kaye Powers
66729aeeeb
Fix ext/sodium display in phpinfo() 2017-07-25 06:35:40 +01:00
Frank Denis
742895f60c sodium ext: don't reinvent sodium_increment() and sodium_add() 2017-07-24 14:26:05 +02:00
Frank Denis
401188cbf9 sodium ext: require libsodium >= 1.0.8
(but really, 1.0.9 should be the bare minimum)
2017-07-22 22:07:53 +02:00
Frank Denis
c499bd12f7 sodium ext: define crypto_aead_chacha20poly1305_ietf_KEYBYTES if needed
Some old libsodium versions didn't had a dedicated constant for the
IETF version of this construction.
2017-07-22 19:57:44 +02:00
Frank Denis
8a2e747a7b sodium ext: remove redundant and obsolete macros 2017-07-22 17:50:22 +02:00
Frank Denis
f8ffc9622b sodium ext: delete copypasta from sodium_crypto_kdf_derive_from_key()
/via @fredemmott
2017-07-21 18:25:25 +02:00
Frank Denis
0e2a7fc829 sodium ext: use crypto_scalarmult_BYTES for points coordinates
Just for consistency.
2017-07-21 14:02:33 +02:00
Frank Denis
557029e8e6 sodium ext: clear the hash state after we're done hashing 2017-07-21 14:02:26 +02:00
Frank Denis
d8a14e2aad sodium ext: drop unused code
/via @remicollet
2017-07-21 14:02:18 +02:00
Frank Denis
09b15e4f30 sodium ext: implement sodium_crypto_kdf()
Also add zend_parse_parameters_none() statements where appropriate.
2017-07-18 14:42:15 +02:00