summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--0001-Fix-Wincompatible-pointer-types.patch50
-rw-r--r--0001-fix-for-PHP-8.4.patch64
-rw-r--r--0001-use-zend_ce_exception-instead-of-zend_exception_get_.patch29
-rw-r--r--4.patch37
-rw-r--r--PHPINFO7
-rw-r--r--php-pecl-crypto.spec81
6 files changed, 232 insertions, 36 deletions
diff --git a/0001-Fix-Wincompatible-pointer-types.patch b/0001-Fix-Wincompatible-pointer-types.patch
new file mode 100644
index 0000000..2c2fa40
--- /dev/null
+++ b/0001-Fix-Wincompatible-pointer-types.patch
@@ -0,0 +1,50 @@
+From 3b841b78f00acbd8bef95d8ebcd0fefe9a0f0bfa Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Fri, 16 Feb 2024 15:58:45 +0100
+Subject: [PATCH] Fix [-Wincompatible-pointer-types]
+
+---
+ crypto_stream.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/crypto_stream.c b/crypto_stream.c
+index 4e0758c..f208b34 100644
+--- a/crypto_stream.c
++++ b/crypto_stream.c
+@@ -133,13 +133,21 @@ typedef struct {
+ } php_crypto_stream_data;
+
+ /* {{{ php_crypto_stream_write */
++#if PHP_VERSION_ID < 70400
+ static size_t php_crypto_stream_write(php_stream *stream,
++#else
++static ssize_t php_crypto_stream_write(php_stream *stream,
++#endif
+ const char *buf, size_t count TSRMLS_DC)
+ {
+ php_crypto_stream_data *data = (php_crypto_stream_data *) stream->abstract;
+ int bytes_written = BIO_write(data->bio, buf, count > INT_MAX ? INT_MAX : count);
+
++#if PHP_VERSION_ID < 70400
+ return bytes_written <= 0 ? 0 : (size_t) bytes_written;
++#else
++ return bytes_written;
++#endif
+ }
+ /* }}} */
+
+@@ -256,7 +264,11 @@ static void php_crypto_stream_auth_save_result(php_stream *stream, int ok)
+ /* }}} */
+
+ /* {{{ php_crypto_stream_read */
++#if PHP_VERSION_ID < 70400
+ static size_t php_crypto_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
++#else
++static ssize_t php_crypto_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
++#endif
+ {
+ php_crypto_stream_data *data = (php_crypto_stream_data *) stream->abstract;
+ int bytes_read = BIO_read(data->bio, buf, count > INT_MAX ? INT_MAX : count);
+--
+2.43.0
+
diff --git a/0001-fix-for-PHP-8.4.patch b/0001-fix-for-PHP-8.4.patch
new file mode 100644
index 0000000..89eb499
--- /dev/null
+++ b/0001-fix-for-PHP-8.4.patch
@@ -0,0 +1,64 @@
+From 6137150915431a59edb993a008eb3b21fc2d02e0 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Wed, 25 Sep 2024 15:06:03 +0200
+Subject: [PATCH] fix for PHP 8.4
+
+---
+ crypto_cipher.c | 12 ++++++++++++
+ crypto_hash.c | 4 ++++
+ 2 files changed, 16 insertions(+)
+
+diff --git a/crypto_cipher.c b/crypto_cipher.c
+index a0465c1..fb3e410 100644
+--- a/crypto_cipher.c
++++ b/crypto_cipher.c
+@@ -497,7 +497,11 @@ PHP_MINIT_FUNCTION(crypto_cipher)
+ static inline void php_crypto_cipher_set_algorithm_name(zval *object,
+ char *algorithm, phpc_str_size_t algorithm_len TSRMLS_DC)
+ {
++#if PHP_VERSION_ID < 80400
+ php_strtoupper(algorithm, algorithm_len);
++#else
++ zend_str_toupper(algorithm, algorithm_len);
++#endif
+ zend_update_property_stringl(php_crypto_cipher_ce, PHPC_OBJ_FOR_PROP(object),
+ "algorithm", sizeof("algorithm")-1, algorithm, algorithm_len TSRMLS_CC);
+ }
+@@ -513,10 +517,18 @@ PHP_CRYPTO_API const EVP_CIPHER *php_crypto_get_cipher_algorithm(
+ return NULL;
+ }
+
++#if PHP_VERSION_ID < 80400
+ php_strtoupper(algorithm, algorithm_len);
++#else
++ zend_str_toupper(algorithm, algorithm_len);
++#endif
+ cipher = EVP_get_cipherbyname(algorithm);
+ if (!cipher) {
++#if PHP_VERSION_ID < 80400
+ php_strtolower(algorithm, algorithm_len);
++#else
++ zend_str_tolower(algorithm, algorithm_len);
++#endif
+ cipher = EVP_get_cipherbyname(algorithm);
+ }
+ return cipher;
+diff --git a/crypto_hash.c b/crypto_hash.c
+index 8015aa4..9c4f182 100644
+--- a/crypto_hash.c
++++ b/crypto_hash.c
+@@ -319,7 +319,11 @@ PHP_MINIT_FUNCTION(crypto_hash)
+ static inline void php_crypto_hash_set_algorithm_name(zval *object,
+ char *algorithm, phpc_str_size_t algorithm_len TSRMLS_DC)
+ {
++#if PHP_VERSION_ID < 80400
+ php_strtoupper(algorithm, algorithm_len);
++#else
++ zend_str_toupper(algorithm, algorithm_len);
++#endif
+ zend_update_property_stringl(php_crypto_hash_ce, PHPC_OBJ_FOR_PROP(object),
+ "algorithm", sizeof("algorithm")-1, algorithm, algorithm_len TSRMLS_CC);
+ }
+--
+2.46.1
+
diff --git a/0001-use-zend_ce_exception-instead-of-zend_exception_get_.patch b/0001-use-zend_ce_exception-instead-of-zend_exception_get_.patch
new file mode 100644
index 0000000..dc8c9b7
--- /dev/null
+++ b/0001-use-zend_ce_exception-instead-of-zend_exception_get_.patch
@@ -0,0 +1,29 @@
+From 5eec12d0995c683c1910487602db0bf4db022074 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Thu, 17 Jul 2025 10:59:20 +0200
+Subject: [PATCH] use zend_ce_exception instead of zend_exception_get_default()
+ for 8.5
+
+---
+ crypto.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/crypto.c b/crypto.c
+index d841831..fd8df42 100644
+--- a/crypto.c
++++ b/crypto.c
+@@ -76,7 +76,11 @@ PHP_MINIT_FUNCTION(crypto)
+ zend_class_entry ce;
+
+ /* Register base exception */
++#if PHP_VERSION_ID < 70000
+ PHP_CRYPTO_EXCEPTION_REGISTER_CE(ce, Crypto, zend_exception_get_default(TSRMLS_C));
++#else
++ PHP_CRYPTO_EXCEPTION_REGISTER_CE(ce, Crypto, zend_ce_exception);
++#endif
+
+ /* Init OpenSSL algorithms */
+ OpenSSL_add_all_algorithms();
+--
+2.50.1
+
diff --git a/4.patch b/4.patch
new file mode 100644
index 0000000..0c9f1f9
--- /dev/null
+++ b/4.patch
@@ -0,0 +1,37 @@
+From e9ad43262a6b036bf2f81013f23783eec619a537 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Wed, 30 Jul 2025 14:02:25 +0200
+Subject: [PATCH] use Zend/zend_smart_string.h
+
+---
+ phpc.h | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/phpc.h b/phpc.h
+index 93d5cca..075bbad 100644
+--- a/phpc.h
++++ b/phpc.h
+@@ -266,7 +266,11 @@ typedef int phpc_str_size_t;
+
+ /* Smart string */
+ #if defined(PHPC_SMART_STR_INCLUDE) || defined(PHPC_SMART_CSTR_INCLUDE)
++#if PHP_VERSION_ID < 70200
+ #include "ext/standard/php_smart_str.h"
++#else
++#include "Zend/zend_smart_str.h"
++#endif
+
+ #ifdef PHPC_SMART_CSTR_INCLUDE
+ /* smart_str for C string has been renamed in PHP 7 so we have to wrap it */
+@@ -929,7 +933,11 @@ typedef size_t phpc_str_size_t;
+ #endif /* PHPC_SMART_STR_INCLUDE */
+
+ #ifdef PHPC_SMART_CSTR_INCLUDE
++#if PHP_VERSION_ID < 70200
+ #include "ext/standard/php_smart_string.h"
++#else
++#include "Zend/zend_smart_string.h"
++#endif
+ /* smart_str for C string has been renamed in PHP 7 so we have to wrap it */
+ #define phpc_smart_cstr smart_string
+ #define phpc_smart_cstr_alloc smart_string_alloc
diff --git a/PHPINFO b/PHPINFO
new file mode 100644
index 0000000..ca789d1
--- /dev/null
+++ b/PHPINFO
@@ -0,0 +1,7 @@
+
+crypto
+
+Crypto Support => enabled
+Crypto Version => 0.3.2
+OpenSSL Library Version => OpenSSL 3.0.9 30 May 2023
+OpenSSL Header Version => OpenSSL 3.0.5 5 Jul 2022
diff --git a/php-pecl-crypto.spec b/php-pecl-crypto.spec
index c82beed..cf79f9d 100644
--- a/php-pecl-crypto.spec
+++ b/php-pecl-crypto.spec
@@ -1,8 +1,8 @@
# remirepo spec file for php-pecl-crypto
#
-# Copyright (c) 2013-2023 Remi Collet
-# License: CC-BY-SA-4.0
-# http://creativecommons.org/licenses/by-sa/4.0/
+# SPDX-FileCopyrightText: Copyright 2013-2025 Remi Collet
+# SPDX-License-Identifier: CECILL-2.1
+# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
#
# Please, preserve the changelog entries
#
@@ -12,22 +12,23 @@
%bcond_without tests
%global with_zts 0%{!?_without_zts:%{?__ztsphp:1}}
%global pecl_name crypto
-%if "%{php_version}" < "5.6"
-%global ini_name %{pecl_name}.ini
-%else
%global ini_name 40-%{pecl_name}.ini
-%endif
%global sources %{pecl_name}-%{version}
%global _configure ../%{sources}/configure
Summary: Wrapper for OpenSSL Crypto Library
Name: %{?scl_prefix}php-pecl-%{pecl_name}
Version: 0.3.2
-Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
+Release: 6%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
License: PHP-3.01
URL: https://pecl.php.net/package/%{pecl_name}
Source0: https://pecl.php.net/get/%{sources}.tgz
+Patch0: 0001-Fix-Wincompatible-pointer-types.patch
+Patch1: 0001-fix-for-PHP-8.4.patch
+Patch2: 0001-use-zend_ce_exception-instead-of-zend_exception_get_.patch
+Patch3: 4.patch
+
BuildRequires: make
BuildRequires: %{?dtsprefix}gcc
BuildRequires: %{?scl_prefix}php-devel
@@ -55,10 +56,17 @@ Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSIO
# Don't install/register tests
sed -e 's/role="test"/role="src"/' \
- %{?_licensedir:-e '/LICENSE/s/role="doc"/role="src"/' } \
+ -e '/LICENSE/s/role="doc"/role="src"/' \
-i package.xml
cd %{sources}
+%patch -P0 -p1
+%patch -P1 -p1
+%patch -P2 -p1
+cd phpc
+%patch -P3 -p1
+cd ..
+
# Sanity check, really often broken
extver=$(sed -n '/#define PHP_CRYPTO_VERSION/{s/.* "//;s/".*$//;p}' php_crypto.h)
if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then
@@ -84,26 +92,30 @@ EOF
cd %{sources}
%{__phpize}
+[ -f Makefile.global ] && GLOBAL=Makefile.global || GLOBAL=build/Makefile.global
+sed -e 's/INSTALL_ROOT/DESTDIR/' -i $GLOBAL
cd ../NTS
%configure \
--with-crypto \
--with-php-config=%{__phpconfig}
-make %{?_smp_mflags}
+
+%make_build
%if %{with_zts}
cd ../ZTS
%configure \
--with-crypto \
--with-php-config=%{__ztsphpconfig}
-make %{?_smp_mflags}
+
+%make_build
%endif
%install
%{?dtsenable}
-make -C NTS install INSTALL_ROOT=%{buildroot}
+%make_install -C NTS
# install config file
install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name}
@@ -112,7 +124,7 @@ install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name}
install -D -m 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml
%if %{with_zts}
-make -C ZTS install INSTALL_ROOT=%{buildroot}
+%make_install -C ZTS
install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name}
%endif
@@ -123,33 +135,13 @@ do install -Dpm 644 %{sources}/$i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i
done
-%if 0%{?fedora} < 24 && 0%{?rhel} < 8
-# when pear installed alone, after us
-%triggerin -- %{?scl_prefix}php-pear
-if [ -x %{__pecl} ] ; then
- %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || :
-fi
-
-# posttrans as pear can be installed after us
-%posttrans
-if [ -x %{__pecl} ] ; then
- %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || :
-fi
-
-%postun
-if [ $1 -eq 0 -a -x %{__pecl} ] ; then
- %{pecl_uninstall} %{pecl_name} >/dev/null || :
-fi
-%endif
-
-
%check
cd %{sources}
: Minimal load test for NTS extension
%{__php} --no-php-ini \
--define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \
- --modules | grep %{pecl_name}
+ --modules | grep '^%{pecl_name}$'
%if %{with tests}
: Upstream test suite for NTS extension
@@ -163,7 +155,7 @@ REPORT_EXIT_STATUS=1 \
: Minimal load test for ZTS extension
%{__ztsphp} --no-php-ini \
--define extension=%{buildroot}%{php_ztsextdir}//%{pecl_name}.so \
- --modules | grep %{pecl_name}
+ --modules | grep '^%{pecl_name}$'
%if %{with tests}
: Upstream test suite for ZTS extension
@@ -176,7 +168,7 @@ REPORT_EXIT_STATUS=1 \
%files
-%{?_licensedir:%license %{sources}/LICENSE}
+%license %{sources}/LICENSE
%doc %{pecl_docdir}/%{pecl_name}
%{pecl_xmldir}/%{name}.xml
%config(noreplace) %{php_inidir}/%{ini_name}
@@ -190,6 +182,23 @@ REPORT_EXIT_STATUS=1 \
%changelog
+* Wed Jul 30 2025 Remi Collet <remi@remirepo.net> - 0.3.2-6
+- fix build with PHP 8.5.0alpha3 using patch from
+ https://github.com/bukka/phpc/pull/4
+
+* Thu Jul 17 2025 Remi Collet <remi@remirepo.net> - 0.3.2-5
+- fix build with PHP 8.5.0alpha2 using patch from
+ https://github.com/bukka/php-crypto/pull/42
+- re-license spec file to CECILL-2.1
+
+* Wed Sep 25 2024 Remi Collet <remi@remirepo.net> - 0.3.2-4
+- fix build with PHP 8.4 using patch from
+ https://github.com/bukka/php-crypto/pull/42
+
+* Fri Feb 16 2024 Remi Collet <remi@remirepo.net> - 0.3.2-3
+- fix [-Wincompatible-pointer-types] using patch from
+ https://github.com/bukka/php-crypto/pull/40
+
* Thu Aug 31 2023 Remi Collet <remi@remirepo.net> - 0.3.2-2
- build out of sources tree