summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2015-10-27 10:08:05 +0100
committerRemi Collet <fedora@famillecollet.com>2015-10-27 10:08:05 +0100
commit5e13413472537ef4747ec781232ddd6c22e185df (patch)
treed21d2741e2d55fb8373e7e023a03e022ac24f4a3
parent8f93032e7bc1df11c16056a604bb08fc4eddc82a (diff)
php-pecl-libsodium: 1.0.1 + upstream patches
-rw-r--r--REFLECTION56
-rw-r--r--libsodium-pr62.patch38
-rw-r--r--libsodium-pr63.patch88
-rw-r--r--php-pecl-libsodium.spec29
4 files changed, 204 insertions, 7 deletions
diff --git a/REFLECTION b/REFLECTION
index 1d06cf3..c546d38 100644
--- a/REFLECTION
+++ b/REFLECTION
@@ -1,6 +1,10 @@
-Extension [ <persistent> extension #117 libsodium version 1.0.0 ] {
+Extension [ <persistent> extension #117 libsodium version 1.0.1 ] {
- - Constants [41] {
+ - Constants [46] {
+ Constant [ integer Sodium\CRYPTO_AEAD_AES256GCM_KEYBYTES ] { 32 }
+ Constant [ integer Sodium\CRYPTO_AEAD_AES256GCM_NSECBYTES ] { 0 }
+ Constant [ integer Sodium\CRYPTO_AEAD_AES256GCM_NPUBBYTES ] { 12 }
+ Constant [ integer Sodium\CRYPTO_AEAD_AES256GCM_ABYTES ] { 16 }
Constant [ integer Sodium\CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES ] { 32 }
Constant [ integer Sodium\CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES ] { 0 }
Constant [ integer Sodium\CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES ] { 8 }
@@ -13,6 +17,7 @@ Extension [ <persistent> extension #117 libsodium version 1.0.0 ] {
Constant [ integer Sodium\CRYPTO_BOX_KEYPAIRBYTES ] { 64 }
Constant [ integer Sodium\CRYPTO_BOX_MACBYTES ] { 16 }
Constant [ integer Sodium\CRYPTO_BOX_NONCEBYTES ] { 24 }
+ Constant [ integer Sodium\CRYPTO_BOX_SEEDBYTES ] { 32 }
Constant [ integer Sodium\CRYPTO_KX_BYTES ] { 32 }
Constant [ integer Sodium\CRYPTO_KX_PUBLICKEYBYTES ] { 32 }
Constant [ integer Sodium\CRYPTO_KX_SECRETKEYBYTES ] { 32 }
@@ -45,6 +50,29 @@ Extension [ <persistent> extension #117 libsodium version 1.0.0 ] {
}
- Functions {
+ Function [ <internal:libsodium> function Sodium\crypto_aead_aes256gcm_is_available ] {
+
+ - Parameters [0] {
+ }
+ }
+ Function [ <internal:libsodium> function Sodium\crypto_aead_aes256gcm_decrypt ] {
+
+ - Parameters [4] {
+ Parameter #0 [ <required> $string ]
+ Parameter #1 [ <required> $ad ]
+ Parameter #2 [ <required> $nonce ]
+ Parameter #3 [ <required> $key ]
+ }
+ }
+ Function [ <internal:libsodium> function Sodium\crypto_aead_aes256gcm_encrypt ] {
+
+ - Parameters [4] {
+ Parameter #0 [ <required> $string ]
+ Parameter #1 [ <required> $ad ]
+ Parameter #2 [ <required> $nonce ]
+ Parameter #3 [ <required> $key ]
+ }
+ }
Function [ <internal:libsodium> function Sodium\crypto_aead_chacha20poly1305_decrypt ] {
- Parameters [4] {
@@ -91,6 +119,12 @@ Extension [ <persistent> extension #117 libsodium version 1.0.0 ] {
- Parameters [0] {
}
}
+ Function [ <internal:libsodium> function Sodium\crypto_box_seed_keypair ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $key ]
+ }
+ }
Function [ <internal:libsodium> function Sodium\crypto_box_keypair_from_secretkey_and_publickey ] {
- Parameters [2] {
@@ -245,6 +279,18 @@ Extension [ <persistent> extension #117 libsodium version 1.0.0 ] {
Parameter #1 [ <required> $keypair ]
}
}
+ Function [ <internal:libsodium> function Sodium\crypto_sign_ed25519_pk_to_curve25519 ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $key ]
+ }
+ }
+ Function [ <internal:libsodium> function Sodium\crypto_sign_ed25519_sk_to_curve25519 ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $key ]
+ }
+ }
Function [ <internal:libsodium> function Sodium\crypto_sign_keypair ] {
- Parameters [0] {
@@ -335,6 +381,12 @@ Extension [ <persistent> extension #117 libsodium version 1.0.0 ] {
Parameter #0 [ <required> $string ]
}
}
+ Function [ <internal:libsodium> function Sodium\compare ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $string ]
+ }
+ }
Function [ <internal:libsodium> function Sodium\hex2bin ] {
- Parameters [2] {
diff --git a/libsodium-pr62.patch b/libsodium-pr62.patch
new file mode 100644
index 0000000..0a08cd5
--- /dev/null
+++ b/libsodium-pr62.patch
@@ -0,0 +1,38 @@
+From 3d2f71927f26c65ce7a631793ece893a86bc818a Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora@famillecollet.com>
+Date: Tue, 27 Oct 2015 08:02:26 +0100
+Subject: [PATCH] don't zero interned string
+
+---
+ libsodium.c | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/libsodium.c b/libsodium.c
+index bc03b49..8bd1036 100644
+--- a/libsodium.c
++++ b/libsodium.c
+@@ -396,15 +396,21 @@ PHP_FUNCTION(sodium_memzero)
+ return;
+ }
+ ZVAL_DEREF(buf_zv);
++ if (Z_TYPE_P(buf_zv) != IS_STRING) {
++ zend_error(E_ERROR, "memzero: a PHP string is required");
++ }
+ #if PHP_MAJOR_VERSION >= 7
+- if (Z_REFCOUNTED_P(buf_zv) == 0 || Z_REFCOUNT(*buf_zv) > 1) {
++ if (IS_INTERNED(Z_STR(*buf_zv)) || Z_REFCOUNTED_P(buf_zv) == 0 || Z_REFCOUNT(*buf_zv) > 1) {
+ convert_to_null(buf_zv);
+ return;
+ }
+ #endif
+- if (Z_TYPE_P(buf_zv) != IS_STRING) {
+- zend_error(E_ERROR, "memzero: a PHP string is required");
++#if PHP_MAJOR_VERSION < 7 && defined(IS_INTERNED)
++ if (IS_INTERNED(Z_STRVAL(*buf_zv))) {
++ convert_to_null(buf_zv);
++ return;
+ }
++#endif
+ buf = Z_STRVAL(*buf_zv);
+ buf_len = Z_STRLEN(*buf_zv);
+ if (buf_len > 0) {
diff --git a/libsodium-pr63.patch b/libsodium-pr63.patch
new file mode 100644
index 0000000..3d28573
--- /dev/null
+++ b/libsodium-pr63.patch
@@ -0,0 +1,88 @@
+From fbecbcfcbe819a1fae9663689e9c34b9d904502a Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora@famillecollet.com>
+Date: Tue, 27 Oct 2015 08:28:00 +0100
+Subject: [PATCH 1/2] fix build with old libsodium
+
+---
+ libsodium.c | 3 +++
+ tests/crypto_aead.phpt | 5 ++++-
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/libsodium.c b/libsodium.c
+index bc03b49..f9f12f7 100644
+--- a/libsodium.c
++++ b/libsodium.c
+@@ -2033,6 +2033,8 @@ PHP_FUNCTION(crypto_sign_ed25519_pk_to_curve25519)
+ RETURN_STR(ecdhkey);
+ }
+
++#if SODIUM_LIBRARY_VERSION_MAJOR > 7 || \
++ (SODIUM_LIBRARY_VERSION_MAJOR == 7 && SODIUM_LIBRARY_VERSION_MINOR >= 6)
+ PHP_FUNCTION(sodium_compare)
+ {
+ char *buf1;
+@@ -2054,3 +2056,4 @@ PHP_FUNCTION(sodium_compare)
+ (const unsigned char *) buf2, (size_t) len1));
+ }
+ }
++#endif
+\ No newline at end of file
+diff --git a/tests/crypto_aead.phpt b/tests/crypto_aead.phpt
+index c2a5ff1..96029aa 100644
+--- a/tests/crypto_aead.phpt
++++ b/tests/crypto_aead.phpt
+@@ -1,7 +1,10 @@
+ --TEST--
+ Check for libsodium AEAD
+ --SKIPIF--
+-<?php if (!extension_loaded("libsodium")) print "skip"; ?>
++<?php
++if (!extension_loaded("libsodium")) print "skip extension not loaded";
++if (!defined('Sodium\CRYPTO_AEAD_AES256GCM_NPUBBYTES')) print "skip libsodium without AESGCM";
++?>
+ --FILE--
+ <?php
+ $msg = \Sodium\randombytes_buf(\Sodium\randombytes_uniform(1000));
+
+From dddee3245f58a424151d901c3085806529e67503 Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora@famillecollet.com>
+Date: Tue, 27 Oct 2015 09:18:18 +0100
+Subject: [PATCH 2/2] add check for crypto_aead_aes256gcm_encrypt symbol
+
+---
+ config.m4 | 8 +++++++-
+ libsodium.c | 2 +-
+ 2 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/config.m4 b/config.m4
+index 2a7fe2e..eb11468 100644
+--- a/config.m4
++++ b/config.m4
+@@ -38,7 +38,13 @@ if test "$PHP_LIBSODIUM" != "no"; then
+ ],[
+ -L$LIBSODIUM_DIR/$PHP_LIBDIR
+ ])
+-
++ PHP_CHECK_LIBRARY($LIBNAME,crypto_aead_aes256gcm_encrypt,
++ [
++ AC_DEFINE(HAVE_CRYPTO_AEAD_AES256GCM,1,[ ])
++ ],[],[
++ -L$LIBSODIUM_DIR/$PHP_LIBDIR
++ ])
++
+ PHP_SUBST(LIBSODIUM_SHARED_LIBADD)
+
+ PHP_NEW_EXTENSION(libsodium, libsodium.c, $ext_shared)
+diff --git a/libsodium.c b/libsodium.c
+index f9f12f7..f73e62f 100644
+--- a/libsodium.c
++++ b/libsodium.c
+@@ -148,7 +148,7 @@ ZEND_END_ARG_INFO()
+ # define PHP_FE_END { NULL, NULL, NULL }
+ #endif
+
+-#if defined(crypto_aead_aes256gcm_KEYBYTES) && \
++#if defined(HAVE_CRYPTO_AEAD_AES256GCM) && defined(crypto_aead_aes256gcm_KEYBYTES) && \
+ (defined(__amd64) || defined(__amd64__) || defined(__x86_64__) || defined(__i386__) || \
+ defined(_M_AMD64) || defined(_M_IX86))
+ # define HAVE_AESGCM 1
diff --git a/php-pecl-libsodium.spec b/php-pecl-libsodium.spec
index b280536..bda8ec9 100644
--- a/php-pecl-libsodium.spec
+++ b/php-pecl-libsodium.spec
@@ -21,22 +21,28 @@
%global with_zts 0%{?__ztsphp:1}
%global pecl_name libsodium
-%global with_tests %{?_without_tests:0}%{!?_without_tests:1}
+%global with_tests 0%{!?_without_tests:1}
%if "%{php_version}" < "5.6"
%global ini_name %{pecl_name}.ini
%else
%global ini_name 40-%{pecl_name}.ini
%endif
+%global buildver %(pkg-config --silence-errors --modversion libsodium 2>/dev/null || echo 65536)
Summary: Wrapper for the Sodium cryptographic library
Name: %{?sub_prefix}php-pecl-%{pecl_name}
-Version: 1.0.0
-Release: 3%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
+Version: 1.0.1
+Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
License: PHP
Group: Development/Languages
URL: http://pecl.php.net/package/%{pecl_name}
Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
+# https://github.com/jedisct1/libsodium-php/pull/62 don't zero interned string
+Patch0: %{pecl_name}-pr62.patch
+# https://github.com/jedisct1/libsodium-php/pull/63 build with old libsodium
+Patch1: %{pecl_name}-pr63.patch
+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%if "%{?vendor}" == "Remi Collet"
# Ensure libsodium-last is used
@@ -47,9 +53,12 @@ BuildRequires: libsodium-devel >= 0.6.0
%endif
BuildRequires: %{?scl_prefix}php-devel > 5.2
BuildRequires: %{?scl_prefix}php-pear
+BuildRequires: %{?scl_prefix}php-json
+BuildRequires: pkgconfig
Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api}
Requires: %{?scl_prefix}php(api) = %{php_core_api}
+Requires: libsodium%{?_isa} >= %{buildver}
%{?_sclreq:Requires: %{?scl_prefix}runtime%{?_sclreq}%{?_isa}}
Provides: %{?scl_prefix}php-%{pecl_name} = %{version}
@@ -96,6 +105,8 @@ mv %{pecl_name}-%{version} NTS
sed -e '/role="test"/d' -i package.xml
cd NTS
+%patch0 -p1 -b .pr62
+%patch1 -p1 -b .pr63
# Sanity check, really often broken
extver=$(sed -n '/#define PHP_LIBSODIUM_VERSION/{s/.* "//;s/".*$//;p}' php_libsodium.h)
@@ -184,7 +195,7 @@ cd NTS
%if %{with_tests}
: Upstream test suite for NTS extension
TEST_PHP_EXECUTABLE=%{__php} \
-TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{pecl_name}.so" \
+TEST_PHP_ARGS="-n -d extension=json.so -d extension=$PWD/modules/%{pecl_name}.so" \
NO_INTERACTION=1 \
REPORT_EXIT_STATUS=1 \
%{__php} -n run-tests.php --show-diff
@@ -200,7 +211,7 @@ cd ../ZTS
%if %{with_tests}
: Upstream test suite for ZTS extension
TEST_PHP_EXECUTABLE=%{_bindir}/zts-php \
-TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{pecl_name}.so" \
+TEST_PHP_ARGS="-n -d extension=json.so -d extension=$PWD/modules/%{pecl_name}.so" \
NO_INTERACTION=1 \
REPORT_EXIT_STATUS=1 \
%{_bindir}/zts-php -n run-tests.php --show-diff
@@ -228,6 +239,14 @@ rm -rf %{buildroot}
%changelog
+* Tue Oct 27 2015 Remi Collet <remi@fedoraproject.org> - 1.0.1-1
+- Update to 1.0.1
+- fix for old libsodium
+ https://github.com/jedisct1/libsodium-php/pull/63
+- don't zero interned string
+ https://github.com/jedisct1/libsodium-php/pull/62
+- add dependency on libsodium version used at build time
+
* Tue Oct 13 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-3
- rebuild for PHP 7.0.0RC5 new API version