diff options
author | Andy Postnikov <apostnikov@gmail.com> | 2018-11-08 00:40:26 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2019-01-09 07:34:16 +0000 |
commit | 4a7ccf578f5caf82b4c9120ac266ff49f245549a (patch) | |
tree | c4a923f54fbb4887bb114b68f9048040589518e3 /community/php5 | |
parent | 96e8cf0319ba5e6bf58f4cb6141582c66985af70 (diff) | |
download | aports-4a7ccf578f5caf82b4c9120ac266ff49f245549a.tar.bz2 aports-4a7ccf578f5caf82b4c9120ac266ff49f245549a.tar.xz |
community/php5: remove aport
Diffstat (limited to 'community/php5')
-rw-r--r-- | community/php5/APKBUILD | 538 | ||||
-rw-r--r-- | community/php5/gd-iconv.patch | 45 | ||||
-rw-r--r-- | community/php5/openssl-1.1.patch | 1309 | ||||
-rw-r--r-- | community/php5/php-fpm.initd | 93 | ||||
-rw-r--r-- | community/php5/php-install-pear-xml.patch | 15 | ||||
-rw-r--r-- | community/php5/php5-module.conf | 13 | ||||
-rw-r--r-- | community/php5/php5.post-upgrade | 11 |
7 files changed, 0 insertions, 2024 deletions
diff --git a/community/php5/APKBUILD b/community/php5/APKBUILD deleted file mode 100644 index 40313fe7b7..0000000000 --- a/community/php5/APKBUILD +++ /dev/null @@ -1,538 +0,0 @@ -# Contributor: Andy Blyler <andy@blyler.cc> -# Contributor: Ćukasz Jendrysik <scadu@yandex.com> -# Contributor: Carlo Landmeter <clandmeter@gmail.com> -# Maintainer: Matt Smith <mcs@darkregion.net> -pkgname=php5 -pkgver=5.6.39 -pkgrel=0 -pkgdesc="The PHP language runtime engine" -url="http://www.php.net/" -arch="all" -license="PHP-3.0" -depends="$pkgname-cli" -depends_dev="$pkgname-cli pcre-dev" -install="$pkgname.post-upgrade" -provides="php" -makedepends=" - $depends_dev - apache2-dev - apr-dev - apr-util-dev - aspell-dev - bzip2-dev - curl-dev - db-dev - enchant-dev - expat-dev - freetds-dev - freetype-dev - gdbm-dev - gettext-dev - gmp-dev - icu-dev - imap-dev - libevent-dev - libgcrypt-dev - libjpeg-turbo-dev - libmcrypt-dev - libpng-dev - libtool - libxml2-dev - libxslt-dev - mariadb-connector-c-dev - net-snmp-dev - openldap-dev - openssl-dev - postgresql-dev - readline-dev - sqlite-dev - unixodbc-dev - zlib-dev - autoconf - bison - " -subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-common::noarch $pkgname-cgi - $pkgname-cli $pkgname-fpm $pkgname-apache2 $pkgname-embed - $pkgname-phpdbg - - $pkgname-pear::noarch - $pkgname-bcmath - $pkgname-bz2 - $pkgname-calendar - $pkgname-ctype - $pkgname-curl:_curl - $pkgname-dba - $pkgname-dom - $pkgname-enchant - $pkgname-exif - $pkgname-ftp - $pkgname-gd - $pkgname-gettext - $pkgname-gmp - $pkgname-iconv - $pkgname-imap - $pkgname-intl - $pkgname-json - $pkgname-ldap - $pkgname-mcrypt - $pkgname-mysql - $pkgname-mysqli - $pkgname-odbc - $pkgname-openssl - $pkgname-pcntl - $pkgname-pdo - $pkgname-pdo_mysql - $pkgname-pdo_odbc - $pkgname-pdo_pgsql - $pkgname-pdo_sqlite - $pkgname-pgsql - $pkgname-phar - $pkgname-posix - $pkgname-pspell - $pkgname-shmop - $pkgname-snmp - $pkgname-soap - $pkgname-sockets - $pkgname-sqlite3 - $pkgname-sysvmsg - $pkgname-sysvsem - $pkgname-sysvshm - $pkgname-xml - $pkgname-xmlreader - $pkgname-xmlrpc - $pkgname-xsl - $pkgname-zip - $pkgname-mssql - $pkgname-pdo_dblib - $pkgname-wddx - $pkgname-opcache - " - -source="https://php.net/distributions/php-$pkgver.tar.bz2 - php-fpm.initd - php5-module.conf - php-install-pear-xml.patch - gd-iconv.patch - openssl-1.1.patch - " - -_apiver="20131106" -_extdir="/usr/lib/$pkgname/modules" -_srcdir="$srcdir"/php-$pkgver -_confdir=/etc/$pkgname - -# seems like pear hardcode /usr/share/pear directory -_peardir=/usr/share/pear - -# secfixes: -# 5.6.38-r0: -# - CVE-2018-17082 -# 5.6.37-r0: -# - CVE-2018-14851 -# - CVE-2018-14883 -# 5.6.36-r0: -# - CVE-2018-5712 -# 5.6.34-r0: -# - CVE-2018-7584 -# 5.6.33-r0: -# - CVE-2018-5711 -# - CVE-2018-5712 -# 5.6.31-r0: -# - CVE-2017-9224 -# - CVE-2017-9226 -# - CVE-2017-9227 -# - CVE-2017-9228 -# - CVE-2017-9229 - -prepare() { - cd "$_srcdir" - update_config_sub - for i in $source; do - case $i in - *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;; - esac - done - - # safty check for api changes - local vapi=$(sed -n '/#define PHP_API_VERSION/{s/.* //;p}' main/php.h) - if [ "$vapi" != "$_apiver" ]; then - error "Upstreram API version is now $vapi. Expecting $_vapi" - return 1 - fi - autoconf -} - -_do_build() { - local _flavor="$1" - shift - local _builddir="$srcdir"/build-$_flavor - mkdir -p "$_builddir" - cd "$_builddir" - export EXTENSION_DIR=$_extdir - export PEAR_INSTALLDIR="$_peardir" - - #http://source.icu-project.org/repos/icu/trunk/icu4c/readme.html#RecBuild - export CPPFLAGS="$CPPFLAGS -DU_USING_ICU_NAMESPACE=1" - - "$_srcdir"/configure $@ || return 1 - sed -ri "s/^(EXTRA_LDFLAGS[ ]*\=.*)/\1 -lpthread/" Makefile # see #183 - make || return 1 -} - -build() { - _phpconfig="\ - --build=$CBUILD \ - --host=$CHOST \ - --prefix=/usr \ - --sysconfdir=$_confdir \ - --localstatedir=/var \ - --with-layout=GNU \ - --with-config-file-path=$_confdir \ - --with-config-file-scan-dir=$_confdir/conf.d \ - --enable-inline-optimization \ - --disable-debug \ - --disable-rpath \ - --disable-static \ - --enable-shared \ - --mandir=/usr/share/man \ - --with-pic \ - --program-suffix=5 \ - " - - _phpextensions=" \ - --enable-bcmath=shared \ - --with-bz2=shared \ - --enable-calendar=shared \ - --with-cdb \ - --enable-ctype=shared \ - --with-curl=shared \ - --enable-dba=shared \ - --with-db4=shared \ - --enable-dom=shared \ - --with-enchant=shared \ - --enable-exif=shared \ - --with-freetype-dir=shared,/usr \ - --enable-ftp=shared \ - --with-gd=shared \ - --enable-gd-native-ttf \ - --with-gdbm=shared \ - --with-gettext=shared \ - --with-gmp=shared \ - --with-iconv=shared \ - --with-icu-dir=/usr \ - --with-imap=shared \ - --with-imap-ssl=shared \ - --enable-intl=shared \ - --with-jpeg-dir=shared,/usr \ - --enable-json=shared \ - --with-ldap=shared \ - --enable-libxml=shared \ - --enable-mbregex \ - --enable-mbstring=all \ - --with-mcrypt=shared \ - --with-mysql=shared,mysqlnd \ - --with-mysql-sock=/var/run/mysqld/mysqld.sock \ - --with-mysqli=shared,mysqlnd \ - --with-openssl=shared \ - --with-pcre-regex=/usr \ - --enable-pcntl=shared \ - --enable-pdo=shared \ - --with-pdo-mysql=shared,mysqlnd \ - --with-pdo-odbc=shared,unixODBC,/usr \ - --with-pdo-pgsql=shared \ - --with-pdo-sqlite=shared,/usr \ - --with-pgsql=shared \ - --enable-phar=shared \ - --with-png-dir=shared,/usr \ - --enable-posix=shared \ - --with-pspell=shared \ - --with-regex=php \ - --enable-session \ - --enable-shmop=shared \ - --with-snmp=shared \ - --enable-soap=shared \ - --enable-sockets=shared \ - --with-sqlite3=shared,/usr \ - --enable-sysvmsg=shared \ - --enable-sysvsem=shared \ - --enable-sysvshm=shared \ - --with-unixODBC=shared,/usr \ - --enable-xml=shared \ - --enable-xmlreader=shared \ - --with-xmlrpc=shared \ - --with-xsl=shared \ - --enable-wddx=shared \ - --enable-zip=shared \ - --with-zlib \ - --without-db1 \ - --without-db2 \ - --without-db3 \ - --without-qdbm \ - --with-mssql=shared \ - --with-pdo-dblib=shared \ - --enable-opcache \ - " - - # cgi, fcgi, cli, pear and extensions - _do_build cgi \ - ${_phpconfig} \ - --disable-cli \ - --enable-cgi \ - --enable-cli \ - --with-pear \ - --with-readline \ - --enable-phpdbg \ - ${_phpextensions} \ - || return 1 - - # fpm - cp -a "$srcdir"/build-cgi "$srcdir"/build-fpm - _do_build fpm \ - ${_phpconfig} \ - --disable-cli \ - --enable-fpm \ - ${_phpextensions} \ - || return 1 - - # apache2 - cp -a "$srcdir"/build-cgi "$srcdir"/build-apache2 - _do_build apache2 \ - ${_phpconfig} \ - --disable-cli \ - --with-apxs2 \ - ${_phpextensions} \ - || return 1 - - # embed - cp -a "$srcdir"/build-cgi "$srcdir"/build-embed - _do_build embed \ - ${_phpconfig} \ - --disable-cli \ - --enable-embed=shared \ - ${_phpextensions} \ - || return 1 -} - -package() { - cd "$srcdir"/build-cgi - # install php-cgi, cli, pear and modules - make -j1 install install-pear INSTALL_ROOT="$pkgdir" || return 1 - - # cleanup after pear - find "$pkgdir" -name '.*' | xargs rm -rf || return 1 - - # install embed - install -D -m755 "$srcdir"/build-embed/libs/libphp5.so \ - "$pkgdir"/usr/lib/libphp5.so || return 1 - install -D -m644 "$_srcdir"/sapi/embed/php_embed.h \ - "$pkgdir"/usr/include/php/sapi/embed/php_embed.h || return 1 -} - -dev() { - default_dev || return 1 - - mkdir -p "$subpkgdir"/usr/lib/php "$subpkgdir"/usr/bin - mv "$pkgdir"/usr/lib/php/build \ - "$subpkgdir"/usr/lib/php/ || return 1 - mv "$pkgdir"/usr/bin/php-config5 "$subpkgdir"/usr/bin/ -} - -doc() { - # man pages - default_doc || return 1 - cd "$srcdir"/php-$pkgver - - # doc files - _docs="CODING_STANDARDS CREDITS EXTENSIONS INSTALL LICENSE NEWS \ - UPGRADING UPGRADING.INTERNALS" - for _doc in $_docs README.*; do - install -Dm644 "$srcdir"/php-$pkgver/$_doc \ - "$subpkgdir"/usr/share/doc/$pkgname/$_doc || return 1 - done -} - -common() { - pkgdesc="PHP Common Files" - provides="php-common $pkgname-zlib php-zlib" # for backward compatibility - depends="" - - cd "$srcdir"/php-$pkgver - - install -D -m644 php.ini-production "$subpkgdir"$_confdir/php.ini - sed -ri -e "s:^; extension_dir = \"./\":extension_dir = \"$_extdir\":" \ - -e 's/;(date.timezone =)/\1 UTC/' \ - -e "s~^([;]*cgi\.rfc2616_headers.*)$~\1\n\n\; If this is enabled, the PHP CGI binary can safely be placed outside of the\n; web tree and people will not be able to circumvent .htaccess security.\ncgi\.discard_path = 1~" \ - "$subpkgdir"$_confdir/php.ini -} - -cgi() { - pkgdesc="PHP Common Gateway Interface (CGI)" - depends="$pkgname-common" - provides="php-cgi" - mkdir -p "$subpkgdir"/usr/bin - mv "$pkgdir"/usr/bin/php-cgi* "$subpkgdir"/usr/bin/ -} - -cli() { - pkgdesc="PHP Command Line Interface (CLI)" - depends="$pkgname-common" - provides="php-cli" - mkdir -p "$subpkgdir"/usr/bin - mv "$pkgdir"/usr/bin/php5 "$subpkgdir"/usr/bin/ || return 1 - # provide phpize here instead of -dev due to pecl command - mv "$pkgdir"/usr/bin/phpize* "$subpkgdir"/usr/bin/ || return 1 -} - -fpm() { - pkgdesc="PHP FastCGI Process Manager (FPM)" - depends="$pkgname-common" - provides="php-fpm" - mkdir -p "$subpkgdir"$_confdir/fpm.d - install -D -m755 "$srcdir"/build-fpm/sapi/fpm/php-fpm \ - "$subpkgdir"/usr/bin/php-fpm5 || return 1 - install -D -m644 "$srcdir"/build-fpm/sapi/fpm/php-fpm.conf \ - "$subpkgdir"$_confdir/php-fpm.conf || return 1 - install -D -m755 "$srcdir"/php-fpm.initd "$subpkgdir"/etc/init.d/php-fpm - # enable some default options - sed -ri -e "s~^;(error_log)(.*)~\1 = /var/log/php-fpm.log~" \ - -e "s~^;(include)(.*)~\1 = $_confdir/fpm.d/*.conf~" \ - -e "s/^;(pm.start_servers)/\1/" \ - -e "s/^;(pm.min_spare_servers)/\1/" \ - -e "s/^;(pm.max_spare_servers)/\1/" \ - "$subpkgdir"$_confdir/php-fpm.conf || return 1 -} - -apache2() { - pkgdesc="PHP Module for Apache2" - depends="$pkgname-common apache2" - provides="php-apache2" - install -D -m755 "$srcdir"/build-apache2/libs/libphp5.so \ - "$subpkgdir"/usr/lib/apache2/libphp5.so || return 1 - install -D -m644 "$srcdir"/php5-module.conf \ - "$subpkgdir"/etc/apache2/conf.d/php5-module.conf || return 1 -} - -embed() { - pkgdesc="PHP Embed Library" - depends="$pkgname-common" - provides="php-embed" - mkdir -p "$subpkgdir"/usr/lib - mv "$pkgdir"/usr/lib/libphp5.so "$subpkgdir"/usr/lib/ -} - -pear() { - pkgdesc="PHP Extension and Application Repository (PEAR)" - depends="$pkgname-cli $pkgname-xml" - provides="php-pear" - mkdir -p "$subpkgdir"/usr/share "$subpkgdir"$_confdir \ - "$subpkgdir"/usr/bin - mv "$pkgdir"/usr/bin/pecl \ - "$pkgdir"/usr/bin/pear \ - "$pkgdir"/usr/bin/peardev \ - "$subpkgdir"/usr/bin/ || return 1 - mv "$pkgdir"$_confdir/pear.conf \ - "$subpkgdir"$_confdir/ || return 1 - mv "$pkgdir"${_peardir} \ - "$subpkgdir"/usr/share/ || return 1 -} - -phpdbg() { - pkgdesc="Interactive PHP debugger" - depends="$pkgname-common" - provides="php-phpdbg" - mkdir -p "$subpkgdir"/usr/bin - mv "$pkgdir"/usr/bin/phpdbg* "$subpkgdir"/usr/bin/ -} - -_mv_ext() { - local ext=$1 - local ini=$ext.ini - pkgdesc="${ext} extension for PHP" - provides="php-$extname" - depends="${pkgname}-common" - - # extension dependencies - if [ -n "${2-}" ]; then - depends="${depends} ${2-}" - fi - - # work around dependency issue - # https://bugs.alpinelinux.org/issues/1848 - if [ "$ext" = "wddx" ]; then - ini=xml_$ext.ini - fi - - mkdir -p "$subpkgdir"/$_extdir - mv "$pkgdir"/$_extdir/${ext}.so "$subpkgdir"/$_extdir/ || return 1 - mkdir -p "$subpkgdir"$_confdir/conf.d - case "$1" in - opcache) - echo "zend_extension=${ext}.so" > "$subpkgdir"$_confdir/conf.d/$ini - ;; - *) - echo "extension=${ext}.so" > "$subpkgdir"$_confdir/conf.d/$ini - ;; - esac -} - -bcmath() { _mv_ext bcmath; } -bz2() { _mv_ext bz2; } -calendar() { _mv_ext calendar; } -ctype() { _mv_ext ctype; } -_curl() { _mv_ext curl; } -dba() { _mv_ext dba; } -dom() { _mv_ext dom; } -enchant() { _mv_ext enchant; } -exif() { _mv_ext exif; } -ftp() { _mv_ext ftp; } -gd() { _mv_ext gd; } -gettext() { _mv_ext gettext; } -gmp() { _mv_ext gmp; } -iconv() { _mv_ext iconv; } -imap() { _mv_ext imap; } -intl() { _mv_ext intl; } -json() { _mv_ext json; } -ldap() { _mv_ext ldap; } -mcrypt() { _mv_ext mcrypt; } -mysql() { _mv_ext mysql; } -mysqli() { _mv_ext mysqli; } -odbc() { _mv_ext odbc unixodbc; } -openssl() { _mv_ext openssl; } -pcntl() { _mv_ext pcntl; } -pdo() { _mv_ext pdo; } -pdo_mysql() { _mv_ext pdo_mysql $pkgname-pdo; } -pdo_odbc() { _mv_ext pdo_odbc $pkgname-pdo; } -pdo_pgsql() { _mv_ext pdo_pgsql $pkgname-pdo; } -pdo_sqlite() { _mv_ext pdo_sqlite $pkgname-pdo; } -pgsql() { _mv_ext pgsql; } -phar() { - _mv_ext phar - mkdir -p "$subpkgdir"/usr/bin - mv "$pkgdir"/usr/bin/phar* "$subpkgdir"/usr/bin/ - } -posix() { _mv_ext posix; } -pspell() { _mv_ext pspell; } -shmop() { _mv_ext shmop; } -snmp() { _mv_ext snmp; } -soap() { _mv_ext soap; } -sockets() { _mv_ext sockets; } -sqlite3() { _mv_ext sqlite3; } -sysvmsg() { _mv_ext sysvmsg; } -sysvsem() { _mv_ext sysvsem; } -sysvshm() { _mv_ext sysvshm; } -xml() { _mv_ext xml; } -xmlreader() { _mv_ext xmlreader $pkgname-dom; } -xmlrpc() { _mv_ext xmlrpc $pkgname-xml; } -xsl() { _mv_ext xsl $pkgname-dom; } -zip() { _mv_ext zip; } -mssql() { _mv_ext mssql; } -pdo_dblib() { _mv_ext pdo_dblib "$pkgname-pdo freetds"; } -wddx() { _mv_ext wddx; } -opcache() { _mv_ext opcache; } - -sha512sums="362388882f813f9e56e22cd58505e44becdfef87b031b117c957a05aca881b70a30283e462a3c3e50c9935cb055b9994183b7d2555765f876a30266540765753 php-5.6.39.tar.bz2 -f7d922cab98617ef910b4c14974e768c85e60424cd1b216f688b34b2d823b642a5b896463008c134ce47c150f9407f5c438823b7e7bc89b3fb440cd3e97b9d7e php-fpm.initd -d1dd6a5764e18414476aaaa109efcc568696ac17a61a1afdf7d0621d3e38c5be717a81ee4d11d28963f11e76879af7d3806970e651061f8c4abffb03c4bd5af4 php5-module.conf -f1177cbf6b1f44402f421c3d317aab1a2a40d0b1209c11519c1158df337c8945f3a313d689c939768584f3e4edbe52e8bd6103fb6777462326a9d94e8ab1f505 php-install-pear-xml.patch -6ecd0be2da1dc5b1d7512e46a2a5cd107a8b2a8c364efc9c624a7d6b2ab081685a329c94c22c970dc14c5c1115f702c512e97ae858da1bc69c6423323dbeeba2 gd-iconv.patch -bbe39ad27a5a82c705692c921b214c5630227ed9852f0432340f74533b5e618d9bea01bff75a4b7a1f1b72876b6d092d2db4533758d9a927f274cff7361f3eb4 openssl-1.1.patch" diff --git a/community/php5/gd-iconv.patch b/community/php5/gd-iconv.patch deleted file mode 100644 index 7f7bd0e196..0000000000 --- a/community/php5/gd-iconv.patch +++ /dev/null @@ -1,45 +0,0 @@ -diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 -index e643e52..fc41ab9 100644 ---- a/ext/gd/config.m4 -+++ b/ext/gd/config.m4 -@@ -6,6 +6,9 @@ dnl - dnl Configure options - dnl - -+PHP_ARG_WITH(iconv-dir, iconv dir for GD and XMLRPC-EPI, -+[ --with-iconv-dir=DIR GD/XMLRPC-EPI: iconv dir for GD/XMLRPC-EPI],no,no) -+ - PHP_ARG_WITH(gd, for GD support, - [ --with-gd[=DIR] Include GD support. DIR is the GD library base - install directory [BUNDLED]]) -@@ -329,6 +332,18 @@ dnl enable the support in bundled GD library - GDLIB_CFLAGS="$GDLIB_CFLAGS -DJISX0208" - fi - -+ dnl link to iconv if needed -+ if test "$PHP_ICONV_DIR" != "no"; then -+ PHP_ICONV=$PHP_ICONV_DIR -+ fi -+ -+ if test -z "$PHP_ICONV" || test "$PHP_ICONV" = "no"; then -+ PHP_ICONV=yes -+ fi -+ -+ PHP_SETUP_ICONV(GD_SHARED_LIBADD, [], [ -+ AC_MSG_ERROR([iconv not found, in order to build gd you need the iconv library]) -+ ]) - else - - if test "$PHP_GD" != "no"; then ---- a/ext/xmlrpc/config.m4 -+++ b/ext/xmlrpc/config.m4 -@@ -18,9 +18,6 @@ - PHP_ARG_WITH(libexpat-dir, libexpat dir for XMLRPC-EPI, - [ --with-libexpat-dir=DIR XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)],no,no) - --PHP_ARG_WITH(iconv-dir, iconv dir for XMLRPC-EPI, --[ --with-iconv-dir=DIR XMLRPC-EPI: iconv dir for XMLRPC-EPI],no,no) -- - if test "$PHP_XMLRPC" != "no"; then - - PHP_ADD_EXTENSION_DEP(xmlrpc, libxml) diff --git a/community/php5/openssl-1.1.patch b/community/php5/openssl-1.1.patch deleted file mode 100644 index 3809ca3c71..0000000000 --- a/community/php5/openssl-1.1.patch +++ /dev/null @@ -1,1309 +0,0 @@ -diff -rupN php-5.6.31.orig/ext/openssl/openssl.c php-5.6.31/ext/openssl/openssl.c ---- php-5.6.31.orig/ext/openssl/openssl.c 2017-07-06 00:25:00.000000000 +0200 -+++ php-5.6.31/ext/openssl/openssl.c 2017-08-01 10:55:28.108819344 +0200 -@@ -42,6 +42,12 @@ - - /* OpenSSL includes */ - #include <openssl/evp.h> -+#if OPENSSL_VERSION_NUMBER >= 0x10002000L -+#include <openssl/bn.h> -+#include <openssl/rsa.h> -+#include <openssl/dsa.h> -+#include <openssl/dh.h> -+#endif - #include <openssl/x509.h> - #include <openssl/x509v3.h> - #include <openssl/crypto.h> -@@ -531,6 +537,133 @@ zend_module_entry openssl_module_entry = - ZEND_GET_MODULE(openssl) - #endif - -+/* {{{ OpenSSL compatibility functions and macros */ -+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) -+#define EVP_PKEY_get0_RSA(_pkey) _pkey->pkey.rsa -+#define EVP_PKEY_get0_DH(_pkey) _pkey->pkey.dh -+#define EVP_PKEY_get0_DSA(_pkey) _pkey->pkey.dsa -+#define EVP_PKEY_get0_EC_KEY(_pkey) _pkey->pkey.ec -+ -+static int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) -+{ -+ r->n = n; -+ r->e = e; -+ r->d = d; -+ -+ return 1; -+} -+ -+static int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) -+{ -+ r->p = p; -+ r->q = q; -+ -+ return 1; -+} -+ -+static int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) -+{ -+ r->dmp1 = dmp1; -+ r->dmq1 = dmq1; -+ r->iqmp = iqmp; -+ -+ return 1; -+} -+ -+static void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) -+{ -+ *n = r->n; -+ *e = r->e; -+ *d = r->d; -+} -+ -+static void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) -+{ -+ *p = r->p; -+ *q = r->q; -+} -+ -+static void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp) -+{ -+ *dmp1 = r->dmp1; -+ *dmq1 = r->dmq1; -+ *iqmp = r->iqmp; -+} -+ -+static void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) -+{ -+ *p = dh->p; -+ *q = dh->q; -+ *g = dh->g; -+} -+ -+static int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) -+{ -+ dh->p = p; -+ dh->q = q; -+ dh->g = g; -+ -+ return 1; -+} -+ -+static void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) -+{ -+ *pub_key = dh->pub_key; -+ *priv_key = dh->priv_key; -+} -+ -+static int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) -+{ -+ dh->pub_key = pub_key; -+ dh->priv_key = priv_key; -+ -+ return 1; -+} -+ -+static void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) -+{ -+ *p = d->p; -+ *q = d->q; -+ *g = d->g; -+} -+ -+int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g) -+{ -+ d->p = p; -+ d->q = q; -+ d->g = g; -+ -+ return 1; -+} -+ -+static void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key) -+{ -+ *pub_key = d->pub_key; -+ *priv_key = d->priv_key; -+} -+ -+int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key) -+{ -+ d->pub_key = pub_key; -+ d->priv_key = priv_key; -+ -+ return 1; -+} -+ -+#if OPENSSL_VERSION_NUMBER < 0x10002000L || defined (LIBRESSL_VERSION_NUMBER) -+#define EVP_PKEY_id(_pkey) _pkey->type -+#define EVP_PKEY_base_id(_key) EVP_PKEY_type(_key->type) -+ -+static int X509_get_signature_nid(const X509 *x) -+{ -+ return OBJ_obj2nid(x->sig_alg->algorithm); -+} -+ -+#endif -+ -+#endif -+/* }}} */ -+ - static int le_key; - static int le_x509; - static int le_csr; -@@ -825,7 +958,7 @@ static int add_oid_section(struct php_x5 - } - for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { - cnf = sk_CONF_VALUE_value(sktmp, i); -- if (OBJ_create(cnf->value, cnf->name, cnf->name) == NID_undef) { -+ if (OBJ_sn2nid(cnf->name) == NID_undef && OBJ_ln2nid(cnf->name) == NID_undef && OBJ_create(cnf->value, cnf->name, cnf->name) == NID_undef) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "problem creating object %s=%s", cnf->name, cnf->value); - return FAILURE; - } -@@ -967,7 +1100,7 @@ static void php_openssl_dispose_config(s - } - /* }}} */ - --#ifdef PHP_WIN32 -+#if defined(PHP_WIN32) || (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)) - #define PHP_OPENSSL_RAND_ADD_TIME() ((void) 0) - #else - #define PHP_OPENSSL_RAND_ADD_TIME() php_openssl_rand_add_timeval() -@@ -1053,9 +1186,11 @@ static EVP_MD * php_openssl_get_evp_md_f - mdtype = (EVP_MD *) EVP_md2(); - break; - #endif -+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) - case OPENSSL_ALGO_DSS1: - mdtype = (EVP_MD *) EVP_dss1(); - break; -+#endif - #if OPENSSL_VERSION_NUMBER >= 0x0090708fL - case OPENSSL_ALGO_SHA224: - mdtype = (EVP_MD *) EVP_sha224(); -@@ -1146,6 +1281,12 @@ PHP_MINIT_FUNCTION(openssl) - OpenSSL_add_all_digests(); - OpenSSL_add_all_algorithms(); - -+#if !defined(OPENSSL_NO_AES) && defined(EVP_CIPH_CCM_MODE) && OPENSSL_VERSION_NUMBER < 0x100020000 -+ EVP_add_cipher(EVP_aes_128_ccm()); -+ EVP_add_cipher(EVP_aes_192_ccm()); -+ EVP_add_cipher(EVP_aes_256_ccm()); -+#endif -+ - SSL_load_error_strings(); - - /* register a resource id number with OpenSSL so that we can map SSL -> stream structures in -@@ -1173,7 +1314,9 @@ PHP_MINIT_FUNCTION(openssl) - #ifdef HAVE_OPENSSL_MD2_H - REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD2", OPENSSL_ALGO_MD2, CONST_CS|CONST_PERSISTENT); - #endif -+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) - REGISTER_LONG_CONSTANT("OPENSSL_ALGO_DSS1", OPENSSL_ALGO_DSS1, CONST_CS|CONST_PERSISTENT); -+#endif - #if OPENSSL_VERSION_NUMBER >= 0x0090708fL - REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA224", OPENSSL_ALGO_SHA224, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA256", OPENSSL_ALGO_SHA256, CONST_CS|CONST_PERSISTENT); -@@ -1251,7 +1394,9 @@ PHP_MINIT_FUNCTION(openssl) - } - - php_stream_xport_register("ssl", php_openssl_ssl_socket_factory TSRMLS_CC); -+#ifndef OPENSSL_NO_SSL3 - php_stream_xport_register("sslv3", php_openssl_ssl_socket_factory TSRMLS_CC); -+#endif - #ifndef OPENSSL_NO_SSL2 - php_stream_xport_register("sslv2", php_openssl_ssl_socket_factory TSRMLS_CC); - #endif -@@ -1308,7 +1453,9 @@ PHP_MSHUTDOWN_FUNCTION(openssl) - #ifndef OPENSSL_NO_SSL2 - php_stream_xport_unregister("sslv2" TSRMLS_CC); - #endif -+#ifndef OPENSSL_NO_SSL3 - php_stream_xport_unregister("sslv3" TSRMLS_CC); -+#endif - php_stream_xport_unregister("tls" TSRMLS_CC); - php_stream_xport_unregister("tlsv1.0" TSRMLS_CC); - #if OPENSSL_VERSION_NUMBER >= 0x10001001L -@@ -1893,6 +2040,7 @@ static int openssl_x509v3_subjectAltName - { - GENERAL_NAMES *names; - const X509V3_EXT_METHOD *method = NULL; -+ ASN1_OCTET_STRING *extension_data; - long i, length, num; - const unsigned char *p; - -@@ -1901,8 +2049,9 @@ static int openssl_x509v3_subjectAltName - return -1; - } - -- p = extension->value->data; -- length = extension->value->length; -+ extension_data = X509_EXTENSION_get_data(extension); -+ p = extension_data->data; -+ length = extension_data->length; - if (method->it) { - names = (GENERAL_NAMES*)(ASN1_item_d2i(NULL, &p, length, - ASN1_ITEM_ptr(method->it))); -@@ -1965,6 +2114,8 @@ PHP_FUNCTION(openssl_x509_parse) - char * tmpstr; - zval * subitem; - X509_EXTENSION *extension; -+ X509_NAME *subject_name; -+ char *cert_name; - char *extname; - BIO *bio_out; - BUF_MEM *bio_buf; -@@ -1979,10 +2130,10 @@ PHP_FUNCTION(openssl_x509_parse) - } - array_init(return_value); - -- if (cert->name) { -- add_assoc_string(return_value, "name", cert->name, 1); -- } --/* add_assoc_bool(return_value, "valid", cert->valid); */ -+ subject_name = X509_get_subject_name(cert); -+ cert_name = X509_NAME_oneline(subject_name, NULL, 0); -+ add_assoc_string(return_value, "name", cert_name, 1); -+ OPENSSL_free(cert_name); - - add_assoc_name_entry(return_value, "subject", X509_get_subject_name(cert), useshortnames TSRMLS_CC); - /* hash as used in CA directories to lookup cert by subject name */ -@@ -2008,7 +2159,7 @@ PHP_FUNCTION(openssl_x509_parse) - add_assoc_string(return_value, "alias", tmpstr, 1); - } - -- sig_nid = OBJ_obj2nid((cert)->sig_alg->algorithm); -+ sig_nid = X509_get_signature_nid(cert); - add_assoc_string(return_value, "signatureTypeSN", (char*)OBJ_nid2sn(sig_nid), 1); - add_assoc_string(return_value, "signatureTypeLN", (char*)OBJ_nid2ln(sig_nid), 1); - add_assoc_long(return_value, "signatureTypeNID", sig_nid); -@@ -3217,7 +3368,21 @@ PHP_FUNCTION(openssl_csr_get_public_key) - RETURN_FALSE; - } - -- tpubkey=X509_REQ_get_pubkey(csr); -+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) -+ /* Due to changes in OpenSSL 1.1 related to locking when decoding CSR, -+ * the pub key is not changed after assigning. It means if we pass -+ * a private key, it will be returned including the private part. -+ * If we duplicate it, then we get just the public part which is -+ * the same behavior as for OpenSSL 1.0 */ -+ csr = X509_REQ_dup(csr); -+#endif -+ /* Retrieve the public key from the CSR */ -+ tpubkey = X509_REQ_get_pubkey(csr); -+ -+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) -+ /* We need to free the CSR as it was duplicated */ -+ X509_REQ_free(csr); -+#endif - RETVAL_RESOURCE(zend_list_insert(tpubkey, le_key TSRMLS_CC)); - return; - } -@@ -3482,13 +3647,20 @@ static int php_openssl_is_private_key(EV - { - assert(pkey != NULL); - -- switch (pkey->type) { -+ switch (EVP_PKEY_id(pkey)) { - #ifndef NO_RSA - case EVP_PKEY_RSA: - case EVP_PKEY_RSA2: -- assert(pkey->pkey.rsa != NULL); -- if (pkey->pkey.rsa != NULL && (NULL == pkey->pkey.rsa->p || NULL == pkey->pkey.rsa->q)) { -- return 0; -+ { -+ RSA *rsa = EVP_PKEY_get0_RSA(pkey); -+ if (rsa != NULL) { -+ const BIGNUM *p, *q; -+ -+ RSA_get0_factors(rsa, &p, &q); -+ if (p == NULL || q == NULL) { -+ return 0; -+ } -+ } - } - break; - #endif -@@ -3498,28 +3670,51 @@ static int php_openssl_is_private_key(EV - case EVP_PKEY_DSA2: - case EVP_PKEY_DSA3: - case EVP_PKEY_DSA4: -- assert(pkey->pkey.dsa != NULL); -- -- if (NULL == pkey->pkey.dsa->p || NULL == pkey->pkey.dsa->q || NULL == pkey->pkey.dsa->priv_key){ -- return 0; -+ { -+ DSA *dsa = EVP_PKEY_get0_DSA(pkey); -+ if (dsa != NULL) { -+ const BIGNUM *p, *q, *g, *pub_key, *priv_key; -+ -+ DSA_get0_pqg(dsa, &p, &q, &g); -+ if (p == NULL || q == NULL) { -+ return 0; -+ } -+ -+ DSA_get0_key(dsa, &pub_key, &priv_key); -+ if (priv_key == NULL) { -+ return 0; -+ } -+ } - } - break; - #endif - #ifndef NO_DH - case EVP_PKEY_DH: -- assert(pkey->pkey.dh != NULL); -- -- if (NULL == pkey->pkey.dh->p || NULL == pkey->pkey.dh->priv_key) { -- return 0; -+ { -+ DH *dh = EVP_PKEY_get0_DH(pkey); -+ if (dh != NULL) { -+ const BIGNUM *p, *q, *g, *pub_key, *priv_key; -+ -+ DH_get0_pqg(dh, &p, &q, &g); -+ if (p == NULL) { -+ return 0; -+ } -+ -+ DH_get0_key(dh, &pub_key, &priv_key); -+ if (priv_key == NULL) { -+ return 0; -+ } -+ } - } - break; - #endif - #ifdef HAVE_EVP_PKEY_EC - case EVP_PKEY_EC: -- assert(pkey->pkey.ec != NULL); -- -- if ( NULL == EC_KEY_get0_private_key(pkey->pkey.ec)) { -- return 0; -+ { -+ EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); -+ if (ec != NULL && NULL == EC_KEY_get0_private_key(ec)) { -+ return 0; -+ } - } - break; - #endif -@@ -3531,34 +3726,80 @@ static int php_openssl_is_private_key(EV - } - /* }}} */ - --#define OPENSSL_PKEY_GET_BN(_type, _name) do { \ -- if (pkey->pkey._type->_name != NULL) { \ -- int len = BN_num_bytes(pkey->pkey._type->_name); \ -- char *str = emalloc(len + 1); \ -- BN_bn2bin(pkey->pkey._type->_name, (unsigned char*)str); \ -- str[len] = 0; \ -- add_assoc_stringl(_type, #_name, str, len, 0); \ -- } \ -- } while (0) -- --#define OPENSSL_PKEY_SET_BN(_ht, _type, _name) do { \ -- zval **bn; \ -- if (zend_hash_find(_ht, #_name, sizeof(#_name), (void**)&bn) == SUCCESS && \ -- Z_TYPE_PP(bn) == IS_STRING) { \ -- _type->_name = BN_bin2bn( \ -- (unsigned char*)Z_STRVAL_PP(bn), \ -- Z_STRLEN_PP(bn), NULL); \ -- } \ -+#define OPENSSL_GET_BN(_array, _bn, _name) do { \ -+ if (_bn != NULL) { \ -+ int len = BN_num_bytes(_bn); \ -+ char *str = emalloc(len + 1); \ -+ BN_bn2bin(_bn, (unsigned char*)str); \ -+ str[len] = 0; \ -+ add_assoc_stringl(_array, #_name, str, len, 0); \ -+ } \ - } while (0); - -+#define OPENSSL_PKEY_GET_BN(_type, _name) OPENSSL_GET_BN(_type, _name, _name) -+ -+#define OPENSSL_PKEY_SET_BN(_data, _name) do { \ -+ zval **bn; \ -+ if (zend_hash_find(Z_ARRVAL_P(_data), #_name, sizeof(#_name),(void**)&bn) == SUCCESS && \ -+ Z_TYPE_PP(bn) == IS_STRING) { \ -+ _name = BN_bin2bn( \ -+ (unsigned char*)Z_STRVAL_PP(bn), \ -+ Z_STRLEN_PP(bn), NULL); \ -+ } else { \ -+ _name = NULL; \ -+ } \ -+ } while (0); -+ -+/* {{{ php_openssl_pkey_init_rsa */ -+zend_bool php_openssl_pkey_init_and_assign_rsa(EVP_PKEY *pkey, RSA *rsa, zval *data) -+{ -+ BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp; -+ -+ OPENSSL_PKEY_SET_BN(data, n); -+ OPENSSL_PKEY_SET_BN(data, e); -+ OPENSSL_PKEY_SET_BN(data, d); -+ if (!n || !d || !RSA_set0_key(rsa, n, e, d)) { -+ return 0; -+ } -+ -+ OPENSSL_PKEY_SET_BN(data, p); -+ OPENSSL_PKEY_SET_BN(data, q); -+ if ((p || q) && !RSA_set0_factors(rsa, p, q)) { -+ return 0; -+ } -+ -+ OPENSSL_PKEY_SET_BN(data, dmp1); -+ OPENSSL_PKEY_SET_BN(data, dmq1); -+ OPENSSL_PKEY_SET_BN(data, iqmp); -+ if ((dmp1 || dmq1 || iqmp) && !RSA_set0_crt_params(rsa, dmp1, dmq1, iqmp)) { -+ return 0; -+ } -+ -+ if (!EVP_PKEY_assign_RSA(pkey, rsa)) { -+ return 0; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ - /* {{{ php_openssl_pkey_init_dsa */ --zend_bool php_openssl_pkey_init_dsa(DSA *dsa) -+zend_bool php_openssl_pkey_init_dsa(DSA *dsa, zval *data) - { -- if (!dsa->p || !dsa->q || !dsa->g) { -+ BIGNUM *p, *q, *g, *priv_key, *pub_key; -+ const BIGNUM *priv_key_const, *pub_key_const; -+ -+ OPENSSL_PKEY_SET_BN(data, p); -+ OPENSSL_PKEY_SET_BN(data, q); -+ OPENSSL_PKEY_SET_BN(data, g); -+ if (!p || !q || !g || !DSA_set0_pqg(dsa, p, q, g)) { - return 0; - } -- if (dsa->priv_key || dsa->pub_key) { -- return 1; -+ -+ OPENSSL_PKEY_SET_BN(data, pub_key); -+ OPENSSL_PKEY_SET_BN(data, priv_key); -+ if (pub_key) { -+ return DSA_set0_key(dsa, pub_key, priv_key); - } - PHP_OPENSSL_RAND_ADD_TIME(); - if (!DSA_generate_key(dsa)) { -@@ -3566,7 +3807,8 @@ zend_bool php_openssl_pkey_init_dsa(DSA - } - /* if BN_mod_exp return -1, then DSA_generate_key succeed for failed key - * so we need to double check that public key is created */ -- if (!dsa->pub_key || BN_is_zero(dsa->pub_key)) { -+ DSA_get0_key(dsa, &pub_key_const, &priv_key_const); -+ if (!pub_key_const || BN_is_zero(pub_key_const)) { - return 0; - } - /* all good */ -@@ -3574,14 +3816,66 @@ zend_bool php_openssl_pkey_init_dsa(DSA - } - /* }}} */ - -+/* {{{ php_openssl_dh_pub_from_priv */ -+static BIGNUM *php_openssl_dh_pub_from_priv(BIGNUM *priv_key, BIGNUM *g, BIGNUM *p) -+{ -+ BIGNUM *pub_key, *priv_key_const_time; -+ BN_CTX *ctx; -+ -+ pub_key = BN_new(); -+ if (pub_key == NULL) { -+ return NULL; -+ } -+ -+ priv_key_const_time = BN_new(); -+ if (priv_key_const_time == NULL) { -+ BN_free(pub_key); -+ return NULL; -+ } -+ ctx = BN_CTX_new(); -+ if (ctx == NULL) { -+ BN_free(pub_key); -+ BN_free(priv_key_const_time); -+ return NULL; -+ } -+ -+ BN_with_flags(priv_key_const_time, priv_key, BN_FLG_CONSTTIME); -+ -+ if (!BN_mod_exp_mont(pub_key, g, priv_key_const_time, p, ctx, NULL)) { -+ BN_free(pub_key); -+ pub_key = NULL; -+ } -+ -+ BN_free(priv_key_const_time); -+ BN_CTX_free(ctx); -+ -+ return pub_key; -+} -+/* }}} */ -+ - /* {{{ php_openssl_pkey_init_dh */ --zend_bool php_openssl_pkey_init_dh(DH *dh) -+zend_bool php_openssl_pkey_init_dh(DH *dh, zval *data) - { -- if (!dh->p || !dh->g) { -+ BIGNUM *p, *q, *g, *priv_key, *pub_key; -+ -+ OPENSSL_PKEY_SET_BN(data, p); -+ OPENSSL_PKEY_SET_BN(data, q); -+ OPENSSL_PKEY_SET_BN(data, g); -+ if (!p || !g || !DH_set0_pqg(dh, p, q, g)) { - return 0; - } -- if (dh->pub_key) { -- return 1; -+ -+ OPENSSL_PKEY_SET_BN(data, priv_key); -+ OPENSSL_PKEY_SET_BN(data, pub_key); -+ if (pub_key) { -+ return DH_set0_key(dh, pub_key, priv_key); -+ } -+ if (priv_key) { -+ pub_key = php_openssl_dh_pub_from_priv(priv_key, g, p); -+ if (pub_key == NULL) { -+ return 0; -+ } -+ return DH_set0_key(dh, pub_key, priv_key); - } - PHP_OPENSSL_RAND_ADD_TIME(); - if (!DH_generate_key(dh)) { -@@ -3614,18 +3908,8 @@ PHP_FUNCTION(openssl_pkey_new) - if (pkey) { - RSA *rsa = RSA_new(); - if (rsa) { -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, n); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, e); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, d); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, p); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, q); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, dmp1); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, dmq1); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, iqmp); -- if (rsa->n && rsa->d) { -- if (EVP_PKEY_assign_RSA(pkey, rsa)) { -- RETURN_RESOURCE(zend_list_insert(pkey, le_key TSRMLS_CC)); -- } -+ if (php_openssl_pkey_init_and_assign_rsa(pkey, rsa, *data)) { -+ RETURN_RESOURCE(zend_list_insert(pkey, le_key TSRMLS_CC)); - } - RSA_free(rsa); - } -@@ -3638,12 +3922,7 @@ PHP_FUNCTION(openssl_pkey_new) - if (pkey) { - DSA *dsa = DSA_new(); - if (dsa) { -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, p); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, q); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, g); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, priv_key); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, pub_key); -- if (php_openssl_pkey_init_dsa(dsa)) { -+ if (php_openssl_pkey_init_dsa(dsa, *data)) { - if (EVP_PKEY_assign_DSA(pkey, dsa)) { - RETURN_RESOURCE(zend_list_insert(pkey, le_key TSRMLS_CC)); - } -@@ -3659,11 +3938,7 @@ PHP_FUNCTION(openssl_pkey_new) - if (pkey) { - DH *dh = DH_new(); - if (dh) { -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, p); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, g); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, priv_key); -- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, pub_key); -- if (php_openssl_pkey_init_dh(dh)) { -+ if (php_openssl_pkey_init_dh(dh, *data)) { - if (EVP_PKEY_assign_DH(pkey, dh)) { - RETURN_RESOURCE(zend_list_insert(pkey, le_key TSRMLS_CC)); - } -@@ -3738,10 +4013,10 @@ PHP_FUNCTION(openssl_pkey_export_to_file - cipher = NULL; - } - -- switch (EVP_PKEY_type(key->type)) { -+ switch (EVP_PKEY_base_id(key)) { - #ifdef HAVE_EVP_PKEY_EC - case EVP_PKEY_EC: -- pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get1_EC_KEY(key), cipher, (unsigned char *)passphrase, passphrase_len, NULL, NULL); -+ pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get0_EC_KEY(key), cipher, (unsigned char *)passphrase, passphrase_len, NULL, NULL); - break; - #endif - default: -@@ -3807,7 +4082,7 @@ PHP_FUNCTION(openssl_pkey_export) - cipher = NULL; - } - -- switch (EVP_PKEY_type(key->type)) { -+ switch (EVP_PKEY_base_id(key)) { - #ifdef HAVE_EVP_PKEY_EC - case EVP_PKEY_EC: - pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get1_EC_KEY(key), cipher, (unsigned char *)passphrase, passphrase_len, NULL, NULL); -@@ -3928,25 +4203,33 @@ PHP_FUNCTION(openssl_pkey_get_details) - /*TODO: Use the real values once the openssl constants are used - * See the enum at the top of this file - */ -- switch (EVP_PKEY_type(pkey->type)) { -+ switch (EVP_PKEY_base_id(pkey)) { - case EVP_PKEY_RSA: - case EVP_PKEY_RSA2: -- ktype = OPENSSL_KEYTYPE_RSA; -- -- if (pkey->pkey.rsa != NULL) { -- zval *rsa; -- -- ALLOC_INIT_ZVAL(rsa); -- array_init(rsa); -- OPENSSL_PKEY_GET_BN(rsa, n); -- OPENSSL_PKEY_GET_BN(rsa, e); -- OPENSSL_PKEY_GET_BN(rsa, d); -- OPENSSL_PKEY_GET_BN(rsa, p); -- OPENSSL_PKEY_GET_BN(rsa, q); -- OPENSSL_PKEY_GET_BN(rsa, dmp1); -- OPENSSL_PKEY_GET_BN(rsa, dmq1); -- OPENSSL_PKEY_GET_BN(rsa, iqmp); -- add_assoc_zval(return_value, "rsa", rsa); -+ { -+ RSA *rsa = EVP_PKEY_get0_RSA(pkey); -+ ktype = OPENSSL_KEYTYPE_RSA; -+ -+ if (rsa != NULL) { -+ zval *z_rsa; -+ const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp; -+ -+ RSA_get0_key(rsa, &n, &e, &d); -+ RSA_get0_factors(rsa, &p, &q); -+ RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp); -+ -+ ALLOC_INIT_ZVAL(z_rsa); -+ array_init(z_rsa); -+ OPENSSL_PKEY_GET_BN(z_rsa, n); -+ OPENSSL_PKEY_GET_BN(z_rsa, e); -+ OPENSSL_PKEY_GET_BN(z_rsa, d); -+ OPENSSL_PKEY_GET_BN(z_rsa, p); -+ OPENSSL_PKEY_GET_BN(z_rsa, q); -+ OPENSSL_PKEY_GET_BN(z_rsa, dmp1); -+ OPENSSL_PKEY_GET_BN(z_rsa, dmq1); -+ OPENSSL_PKEY_GET_BN(z_rsa, iqmp); -+ add_assoc_zval(return_value, "rsa", z_rsa); -+ } - } - - break; -@@ -3954,42 +4237,55 @@ PHP_FUNCTION(openssl_pkey_get_details) - case EVP_PKEY_DSA2: - case EVP_PKEY_DSA3: - case EVP_PKEY_DSA4: -- ktype = OPENSSL_KEYTYPE_DSA; -- -- if (pkey->pkey.dsa != NULL) { -- zval *dsa; -- -- ALLOC_INIT_ZVAL(dsa); -- array_init(dsa); -- OPENSSL_PKEY_GET_BN(dsa, p); -- OPENSSL_PKEY_GET_BN(dsa, q); -- OPENSSL_PKEY_GET_BN(dsa, g); -- OPENSSL_PKEY_GET_BN(dsa, priv_key); -- OPENSSL_PKEY_GET_BN(dsa, pub_key); -- add_assoc_zval(return_value, "dsa", dsa); -+ { -+ DSA *dsa = EVP_PKEY_get0_DSA(pkey); -+ ktype = OPENSSL_KEYTYPE_DSA; -+ -+ if (dsa != NULL) { -+ zval *z_dsa; -+ const BIGNUM *p, *q, *g, *priv_key, *pub_key; -+ -+ DSA_get0_pqg(dsa, &p, &q, &g); -+ DSA_get0_key(dsa, &pub_key, &priv_key); -+ -+ ALLOC_INIT_ZVAL(z_dsa); -+ array_init(z_dsa); -+ OPENSSL_PKEY_GET_BN(z_dsa, p); -+ OPENSSL_PKEY_GET_BN(z_dsa, q); -+ OPENSSL_PKEY_GET_BN(z_dsa, g); -+ OPENSSL_PKEY_GET_BN(z_dsa, priv_key); -+ OPENSSL_PKEY_GET_BN(z_dsa, pub_key); -+ add_assoc_zval(return_value, "dsa", z_dsa); -+ } - } - break; - case EVP_PKEY_DH: -- -- ktype = OPENSSL_KEYTYPE_DH; -- -- if (pkey->pkey.dh != NULL) { -- zval *dh; -- -- ALLOC_INIT_ZVAL(dh); -- array_init(dh); -- OPENSSL_PKEY_GET_BN(dh, p); -- OPENSSL_PKEY_GET_BN(dh, g); -- OPENSSL_PKEY_GET_BN(dh, priv_key); -- OPENSSL_PKEY_GET_BN(dh, pub_key); -- add_assoc_zval(return_value, "dh", dh); -+ { -+ DH *dh = EVP_PKEY_get0_DH(pkey); -+ ktype = OPENSSL_KEYTYPE_DH; -+ -+ if (dh != NULL) { -+ zval *z_dh; -+ const BIGNUM *p, *q, *g, *priv_key, *pub_key; -+ -+ DH_get0_pqg(dh, &p, &q, &g); -+ DH_get0_key(dh, &pub_key, &priv_key); -+ -+ ALLOC_INIT_ZVAL(z_dh); -+ array_init(z_dh); -+ OPENSSL_PKEY_GET_BN(z_dh, p); -+ OPENSSL_PKEY_GET_BN(z_dh, g); -+ OPENSSL_PKEY_GET_BN(z_dh, priv_key); -+ OPENSSL_PKEY_GET_BN(z_dh, pub_key); -+ add_assoc_zval(return_value, "dh", z_dh); -+ } - } - - break; - #ifdef HAVE_EVP_PKEY_EC - case EVP_PKEY_EC: - ktype = OPENSSL_KEYTYPE_EC; -- if (pkey->pkey.ec != NULL) { -+ if (EVP_PKEY_get0_EC_KEY(pkey) != NULL) { - zval *ec; - const EC_GROUP *ec_group; - int nid; -@@ -4546,13 +4842,13 @@ PHP_FUNCTION(openssl_private_encrypt) - cryptedlen = EVP_PKEY_size(pkey); - cryptedbuf = emalloc(cryptedlen + 1); - -- switch (pkey->type) { -+ switch (EVP_PKEY_id(pkey)) { - case EVP_PKEY_RSA: - case EVP_PKEY_RSA2: - successful = (RSA_private_encrypt(data_len, - (unsigned char *)data, - cryptedbuf, -- pkey->pkey.rsa, -+ EVP_PKEY_get0_RSA(pkey), - padding) == cryptedlen); - break; - default: -@@ -4604,13 +4900,13 @@ PHP_FUNCTION(openssl_private_decrypt) - cryptedlen = EVP_PKEY_size(pkey); - crypttemp = emalloc(cryptedlen + 1); - -- switch (pkey->type) { -+ switch (EVP_PKEY_id(pkey)) { - case EVP_PKEY_RSA: - case EVP_PKEY_RSA2: - cryptedlen = RSA_private_decrypt(data_len, - (unsigned char *)data, - crypttemp, -- pkey->pkey.rsa, -+ EVP_PKEY_get0_RSA(pkey), - padding); - if (cryptedlen != -1) { - cryptedbuf = emalloc(cryptedlen + 1); -@@ -4669,13 +4965,13 @@ PHP_FUNCTION(openssl_public_encrypt) - cryptedlen = EVP_PKEY_size(pkey); - cryptedbuf = emalloc(cryptedlen + 1); - -- switch (pkey->type) { -+ switch (EVP_PKEY_id(pkey)) { - case EVP_PKEY_RSA: - case EVP_PKEY_RSA2: - successful = (RSA_public_encrypt(data_len, - (unsigned char *)data, - cryptedbuf, -- pkey->pkey.rsa, -+ EVP_PKEY_get0_RSA(pkey), - padding) == cryptedlen); - break; - default: -@@ -4728,13 +5024,13 @@ PHP_FUNCTION(openssl_public_decrypt) - cryptedlen = EVP_PKEY_size(pkey); - crypttemp = emalloc(cryptedlen + 1); - -- switch (pkey->type) { -+ switch (EVP_PKEY_id(pkey)) { - case EVP_PKEY_RSA: - case EVP_PKEY_RSA2: - cryptedlen = RSA_public_decrypt(data_len, - (unsigned char *)data, - crypttemp, -- pkey->pkey.rsa, -+ EVP_PKEY_get0_RSA(pkey), - padding); - if (cryptedlen != -1) { - cryptedbuf = emalloc(cryptedlen + 1); -@@ -4798,7 +5094,7 @@ PHP_FUNCTION(openssl_sign) - long keyresource = -1; - char * data; - int data_len; -- EVP_MD_CTX md_ctx; -+ EVP_MD_CTX *md_ctx; - zval *method = NULL; - long signature_algo = OPENSSL_ALGO_SHA1; - const EVP_MD *mdtype; -@@ -4831,9 +5127,10 @@ PHP_FUNCTION(openssl_sign) - siglen = EVP_PKEY_size(pkey); - sigbuf = emalloc(siglen + 1); - -- EVP_SignInit(&md_ctx, mdtype); -- EVP_SignUpdate(&md_ctx, data, data_len); -- if (EVP_SignFinal (&md_ctx, sigbuf,(unsigned int *)&siglen, pkey)) { -+ md_ctx = EVP_MD_CTX_create(); -+ EVP_SignInit(md_ctx, mdtype); -+ EVP_SignUpdate(md_ctx, data, data_len); -+ if (EVP_SignFinal (md_ctx, sigbuf,(unsigned int *)&siglen, pkey)) { - zval_dtor(signature); - sigbuf[siglen] = '\0'; - ZVAL_STRINGL(signature, (char *)sigbuf, siglen, 0); -@@ -4842,7 +5139,7 @@ PHP_FUNCTION(openssl_sign) - efree(sigbuf); - RETVAL_FALSE; - } -- EVP_MD_CTX_cleanup(&md_ctx); -+ EVP_MD_CTX_destroy(md_ctx); - if (keyresource == -1) { - EVP_PKEY_free(pkey); - } -@@ -4856,7 +5153,7 @@ PHP_FUNCTION(openssl_verify) - zval **key; - EVP_PKEY *pkey; - int err; -- EVP_MD_CTX md_ctx; -+ EVP_MD_CTX *md_ctx; - const EVP_MD *mdtype; - long keyresource = -1; - char * data; int data_len; -@@ -4890,10 +5187,11 @@ PHP_FUNCTION(openssl_verify) - RETURN_FALSE; - } - -- EVP_VerifyInit (&md_ctx, mdtype); -- EVP_VerifyUpdate (&md_ctx, data, data_len); -- err = EVP_VerifyFinal (&md_ctx, (unsigned char *)signature, signature_len, pkey); -- EVP_MD_CTX_cleanup(&md_ctx); -+ md_ctx = EVP_MD_CTX_create(); -+ EVP_VerifyInit (md_ctx, mdtype); -+ EVP_VerifyUpdate (md_ctx, data, data_len); -+ err = EVP_VerifyFinal (md_ctx, (unsigned char *)signature, signature_len, pkey); -+ EVP_MD_CTX_destroy(md_ctx); - - if (keyresource == -1) { - EVP_PKEY_free(pkey); -@@ -4917,7 +5215,7 @@ PHP_FUNCTION(openssl_seal) - char *method =NULL; - int method_len = 0; - const EVP_CIPHER *cipher; -- EVP_CIPHER_CTX ctx; -+ EVP_CIPHER_CTX *ctx; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szza/|s", &data, &data_len, &sealdata, &ekeys, &pubkeys, &method, &method_len) == FAILURE) { - return; -@@ -4950,6 +5248,7 @@ PHP_FUNCTION(openssl_seal) - memset(eks, 0, sizeof(*eks) * nkeys); - key_resources = safe_emalloc(nkeys, sizeof(long), 0); - memset(key_resources, 0, sizeof(*key_resources) * nkeys); -+ memset(pkeys, 0, sizeof(*pkeys) * nkeys); - - /* get the public keys we are using to seal this data */ - zend_hash_internal_pointer_reset_ex(pubkeysht, &pos); -@@ -4967,27 +5266,28 @@ PHP_FUNCTION(openssl_seal) - i++; - } - -- if (!EVP_EncryptInit(&ctx,cipher,NULL,NULL)) { -+ ctx = EVP_CIPHER_CTX_new(); -+ if (ctx == NULL || !EVP_EncryptInit(ctx,cipher,NULL,NULL)) { - RETVAL_FALSE; -- EVP_CIPHER_CTX_cleanup(&ctx); -+ EVP_CIPHER_CTX_free(ctx); - goto clean_exit; - } - - #if 0 - /* Need this if allow ciphers that require initialization vector */ -- ivlen = EVP_CIPHER_CTX_iv_length(&ctx); -+ ivlen = EVP_CIPHER_CTX_iv_length(ctx); - iv = ivlen ? emalloc(ivlen + 1) : NULL; - #endif - /* allocate one byte extra to make room for \0 */ -- buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(&ctx)); -- EVP_CIPHER_CTX_cleanup(&ctx); -+ buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(ctx)); -+ EVP_CIPHER_CTX_cleanup(ctx); - -- if (EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) <= 0 || -- !EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len) || -- !EVP_SealFinal(&ctx, buf + len1, &len2)) { -+ if (EVP_SealInit(ctx, cipher, eks, eksl, NULL, pkeys, nkeys) <= 0 || -+ !EVP_SealUpdate(ctx, buf, &len1, (unsigned char *)data, data_len) || -+ !EVP_SealFinal(ctx, buf + len1, &len2)) { - RETVAL_FALSE; - efree(buf); -- EVP_CIPHER_CTX_cleanup(&ctx); -+ EVP_CIPHER_CTX_free(ctx); - goto clean_exit; - } - -@@ -5018,7 +5318,7 @@ PHP_FUNCTION(openssl_seal) - efree(buf); - } - RETVAL_LONG(len1 + len2); -- EVP_CIPHER_CTX_cleanup(&ctx); -+ EVP_CIPHER_CTX_free(ctx); - - clean_exit: - for (i=0; i<nkeys; i++) { -@@ -5045,7 +5345,7 @@ PHP_FUNCTION(openssl_open) - int len1, len2; - unsigned char *buf; - long keyresource = -1; -- EVP_CIPHER_CTX ctx; -+ EVP_CIPHER_CTX *ctx; - char * data; int data_len; - char * ekey; int ekey_len; - char *method =NULL; -@@ -5074,8 +5374,9 @@ PHP_FUNCTION(openssl_open) - - buf = emalloc(data_len + 1); - -- if (EVP_OpenInit(&ctx, cipher, (unsigned char *)ekey, ekey_len, NULL, pkey) && EVP_OpenUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) { -- if (!EVP_OpenFinal(&ctx, buf + len1, &len2) || (len1 + len2 == 0)) { -+ ctx = EVP_CIPHER_CTX_new(); -+ if (EVP_OpenInit(ctx, cipher, (unsigned char *)ekey, ekey_len, NULL, pkey) && EVP_OpenUpdate(ctx, buf, &len1, (unsigned char *)data, data_len)) { -+ if (!EVP_OpenFinal(ctx, buf + len1, &len2) || (len1 + len2 == 0)) { - efree(buf); - RETVAL_FALSE; - } else { -@@ -5091,7 +5392,7 @@ PHP_FUNCTION(openssl_open) - if (keyresource == -1) { - EVP_PKEY_free(pkey); - } -- EVP_CIPHER_CTX_cleanup(&ctx); -+ EVP_CIPHER_CTX_free(ctx); - } - /* }}} */ - -@@ -5151,7 +5452,7 @@ PHP_FUNCTION(openssl_digest) - char *data, *method; - int data_len, method_len; - const EVP_MD *mdtype; -- EVP_MD_CTX md_ctx; -+ EVP_MD_CTX *md_ctx; - int siglen; - unsigned char *sigbuf; - -@@ -5167,9 +5468,10 @@ PHP_FUNCTION(openssl_digest) - siglen = EVP_MD_size(mdtype); - sigbuf = emalloc(siglen + 1); - -- EVP_DigestInit(&md_ctx, mdtype); -- EVP_DigestUpdate(&md_ctx, (unsigned char *)data, data_len); -- if (EVP_DigestFinal (&md_ctx, (unsigned char *)sigbuf, (unsigned int *)&siglen)) { -+ md_ctx = EVP_MD_CTX_create(); -+ EVP_DigestInit(md_ctx, mdtype); -+ EVP_DigestUpdate(md_ctx, (unsigned char *)data, data_len); -+ if (EVP_DigestFinal (md_ctx, (unsigned char *)sigbuf, (unsigned int *)&siglen)) { - if (raw_output) { - sigbuf[siglen] = '\0'; - RETVAL_STRINGL((char *)sigbuf, siglen, 0); -@@ -5185,6 +5487,8 @@ PHP_FUNCTION(openssl_digest) - efree(sigbuf); - RETVAL_FALSE; - } -+ -+ EVP_MD_CTX_destroy(md_ctx); - } - /* }}} */ - -@@ -5230,7 +5534,7 @@ PHP_FUNCTION(openssl_encrypt) - char *data, *method, *password, *iv = ""; - int data_len, method_len, password_len, iv_len = 0, max_iv_len; - const EVP_CIPHER *cipher_type; -- EVP_CIPHER_CTX cipher_ctx; -+ EVP_CIPHER_CTX *cipher_ctx; - int i=0, outlen, keylen; - unsigned char *outbuf, *key; - zend_bool free_iv; -@@ -5262,19 +5566,24 @@ PHP_FUNCTION(openssl_encrypt) - outlen = data_len + EVP_CIPHER_block_size(cipher_type); - outbuf = safe_emalloc(outlen, 1, 1); - -- EVP_EncryptInit(&cipher_ctx, cipher_type, NULL, NULL); -+ cipher_ctx = EVP_CIPHER_CTX_new(); -+ if (!cipher_ctx) { -+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to create cipher context"); -+ RETURN_FALSE; -+ } -+ EVP_EncryptInit(cipher_ctx, cipher_type, NULL, NULL); - if (password_len > keylen) { -- EVP_CIPHER_CTX_set_key_length(&cipher_ctx, password_len); -+ EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len); - } -- EVP_EncryptInit_ex(&cipher_ctx, NULL, NULL, key, (unsigned char *)iv); -+ EVP_EncryptInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)iv); - if (options & OPENSSL_ZERO_PADDING) { -- EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0); -+ EVP_CIPHER_CTX_set_padding(cipher_ctx, 0); - } - if (data_len > 0) { -- EVP_EncryptUpdate(&cipher_ctx, outbuf, &i, (unsigned char *)data, data_len); -+ EVP_EncryptUpdate(cipher_ctx, outbuf, &i, (unsigned char *)data, data_len); - } - outlen = i; -- if (EVP_EncryptFinal(&cipher_ctx, (unsigned char *)outbuf + i, &i)) { -+ if (EVP_EncryptFinal(cipher_ctx, (unsigned char *)outbuf + i, &i)) { - outlen += i; - if (options & OPENSSL_RAW_DATA) { - outbuf[outlen] = '\0'; -@@ -5301,7 +5610,8 @@ PHP_FUNCTION(openssl_encrypt) - if (free_iv) { - efree(iv); - } -- EVP_CIPHER_CTX_cleanup(&cipher_ctx); -+ EVP_CIPHER_CTX_cleanup(cipher_ctx); -+ EVP_CIPHER_CTX_free(cipher_ctx); - } - /* }}} */ - -@@ -5313,7 +5623,7 @@ PHP_FUNCTION(openssl_decrypt) - char *data, *method, *password, *iv = ""; - int data_len, method_len, password_len, iv_len = 0; - const EVP_CIPHER *cipher_type; -- EVP_CIPHER_CTX cipher_ctx; -+ EVP_CIPHER_CTX *cipher_ctx; - int i, outlen, keylen; - unsigned char *outbuf, *key; - int base64_str_len; -@@ -5359,17 +5669,23 @@ PHP_FUNCTION(openssl_decrypt) - outlen = data_len + EVP_CIPHER_block_size(cipher_type); - outbuf = emalloc(outlen + 1); - -- EVP_DecryptInit(&cipher_ctx, cipher_type, NULL, NULL); -+ cipher_ctx = EVP_CIPHER_CTX_new(); -+ if (!cipher_ctx) { -+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to create cipher context"); -+ RETURN_FALSE; -+ } -+ -+ EVP_DecryptInit(cipher_ctx, cipher_type, NULL, NULL); - if (password_len > keylen) { -- EVP_CIPHER_CTX_set_key_length(&cipher_ctx, password_len); -+ EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len); - } -- EVP_DecryptInit_ex(&cipher_ctx, NULL, NULL, key, (unsigned char *)iv); -+ EVP_DecryptInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)iv); - if (options & OPENSSL_ZERO_PADDING) { -- EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0); -+ EVP_CIPHER_CTX_set_padding(cipher_ctx, 0); - } -- EVP_DecryptUpdate(&cipher_ctx, outbuf, &i, (unsigned char *)data, data_len); -+ EVP_DecryptUpdate(cipher_ctx, outbuf, &i, (unsigned char *)data, data_len); - outlen = i; -- if (EVP_DecryptFinal(&cipher_ctx, (unsigned char *)outbuf + i, &i)) { -+ if (EVP_DecryptFinal(cipher_ctx, (unsigned char *)outbuf + i, &i)) { - outlen += i; - outbuf[outlen] = '\0'; - RETVAL_STRINGL((char *)outbuf, outlen, 0); -@@ -5386,7 +5702,8 @@ PHP_FUNCTION(openssl_decrypt) - if (base64_str) { - efree(base64_str); - } -- EVP_CIPHER_CTX_cleanup(&cipher_ctx); -+ EVP_CIPHER_CTX_cleanup(cipher_ctx); -+ EVP_CIPHER_CTX_free(cipher_ctx); - } - /* }}} */ - -@@ -5424,6 +5741,7 @@ PHP_FUNCTION(openssl_dh_compute_key) - zval *key; - char *pub_str; - int pub_len; -+ DH *dh; - EVP_PKEY *pkey; - BIGNUM *pub; - char *data; -@@ -5433,14 +5751,21 @@ PHP_FUNCTION(openssl_dh_compute_key) - return; - } - ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, &key, -1, "OpenSSL key", le_key); -- if (!pkey || EVP_PKEY_type(pkey->type) != EVP_PKEY_DH || !pkey->pkey.dh) { -+ if (pkey == NULL) { -+ RETURN_FALSE; -+ } -+ if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DH) { -+ RETURN_FALSE; -+ } -+ dh = EVP_PKEY_get0_DH(pkey); -+ if (dh == NULL) { - RETURN_FALSE; - } - - pub = BN_bin2bn((unsigned char*)pub_str, pub_len, NULL); - -- data = emalloc(DH_size(pkey->pkey.dh) + 1); -- len = DH_compute_key((unsigned char*)data, pub, pkey->pkey.dh); -+ data = emalloc(DH_size(dh) + 1); -+ len = DH_compute_key((unsigned char*)data, pub, dh); - - if (len >= 0) { - data[len] = 0; -diff -rupN php-5.6.31.orig/ext/openssl/tests/bug41033.phpt php-5.6.31/ext/openssl/tests/bug41033.phpt ---- php-5.6.31.orig/ext/openssl/tests/bug41033.phpt 2017-07-06 00:25:00.000000000 +0200 -+++ php-5.6.31/ext/openssl/tests/bug41033.phpt 2017-08-01 10:49:25.008823468 +0200 -@@ -13,11 +13,11 @@ $pub = 'file://' . dirname(__FILE__) . ' - - $prkeyid = openssl_get_privatekey($prv, "1234"); - $ct = "Hello I am some text!"; --openssl_sign($ct, $signature, $prkeyid, OPENSSL_ALGO_DSS1); -+openssl_sign($ct, $signature, $prkeyid, OPENSSL_VERSION_NUMBER < 0x10100000 ? OPENSSL_ALGO_DSS1 : OPENSSL_ALGO_SHA1); - echo "Signature: ".base64_encode($signature) . "\n"; - - $pukeyid = openssl_get_publickey($pub); --$valid = openssl_verify($ct, $signature, $pukeyid, OPENSSL_ALGO_DSS1); -+$valid = openssl_verify($ct, $signature, $pukeyid, OPENSSL_VERSION_NUMBER < 0x10100000 ? OPENSSL_ALGO_DSS1 : OPENSSL_ALGO_SHA1); - echo "Signature validity: " . $valid . "\n"; - - -diff -rupN php-5.6.31.orig/ext/openssl/tests/bug66501.phpt php-5.6.31/ext/openssl/tests/bug66501.phpt ---- php-5.6.31.orig/ext/openssl/tests/bug66501.phpt 2017-07-06 00:25:00.000000000 +0200 -+++ php-5.6.31/ext/openssl/tests/bug66501.phpt 2017-08-01 10:49:25.008823468 +0200 -@@ -16,7 +16,7 @@ AwEHoUQDQgAEPq4hbIWHvB51rdWr8ejrjWo4qVNW - sqOTOnMoezkbSmVVMuwz9flvnqHGmQvmug==
- -----END EC PRIVATE KEY-----';
- $key = openssl_pkey_get_private($pkey);
--$res = openssl_sign($data ='alpha', $sign, $key, 'ecdsa-with-SHA1');
-+$res = openssl_sign($data ='alpha', $sign, $key, OPENSSL_VERSION_NUMBER < 0x10100000 ? 'ecdsa-with-SHA1' : 'SHA1');
- var_dump($res);
- --EXPECTF--
- bool(true)
-diff -rupN php-5.6.31.orig/ext/openssl/tests/openssl_error_string_basic.phpt php-5.6.31/ext/openssl/tests/openssl_error_string_basic.phpt ---- php-5.6.31.orig/ext/openssl/tests/openssl_error_string_basic.phpt 2017-07-06 00:25:00.000000000 +0200 -+++ php-5.6.31/ext/openssl/tests/openssl_error_string_basic.phpt 2017-08-01 10:49:25.008823468 +0200 -@@ -105,7 +105,7 @@ expect_openssl_errors('openssl_private_d - // public encrypt and decrypt with failed padding check and padding - @openssl_public_encrypt("data", $crypted, $public_key_file, 1000); - @openssl_public_decrypt("data", $crypted, $public_key_file); --expect_openssl_errors('openssl_private_(en|de)crypt padding', ['0906D06C', '04068076', '0407006A', '04067072']); -+expect_openssl_errors('openssl_private_(en|de)crypt padding', OPENSSL_VERSION_NUMBER < 0x10100000 ? ['0906D06C', '04068076', '0407006A', '04067072'] : ['0906D06C', '04068076', '04067072']); - - // X509 - echo "X509 errors\n"; -diff -rupN php-5.6.31.orig/ext/openssl/tests/sni_server.phpt php-5.6.31/ext/openssl/tests/sni_server.phpt ---- php-5.6.31.orig/ext/openssl/tests/sni_server.phpt 2017-07-06 00:25:00.000000000 +0200 -+++ php-5.6.31/ext/openssl/tests/sni_server.phpt 2017-08-01 10:49:25.012823468 +0200 -@@ -27,6 +27,9 @@ CODE; - $clientCode = <<<'CODE' - $flags = STREAM_CLIENT_CONNECT; - $ctxArr = [ -+ 'verify_peer' => false, -+ 'verify_peer_name' => false, -+ 'allow_self_signed' => true, - 'cafile' => __DIR__ . '/sni_server_ca.pem', - 'capture_peer_cert' => true - ]; -diff -rupN php-5.6.31.orig/ext/openssl/xp_ssl.c php-5.6.31/ext/openssl/xp_ssl.c ---- php-5.6.31.orig/ext/openssl/xp_ssl.c 2017-07-06 00:25:00.000000000 +0200 -+++ php-5.6.31/ext/openssl/xp_ssl.c 2017-08-01 10:49:25.012823468 +0200 -@@ -935,7 +935,7 @@ static int set_local_cert(SSL_CTX *ctx, - static const SSL_METHOD *php_select_crypto_method(long method_value, int is_client TSRMLS_DC) /* {{{ */ - { - if (method_value == STREAM_CRYPTO_METHOD_SSLv2) { --#ifndef OPENSSL_NO_SSL2 -+#if !defined(OPENSSL_NO_SSL2) && OPENSSL_VERSION_NUMBER < 0x10100000L - return is_client ? SSLv2_client_method() : SSLv2_server_method(); - #else - php_error_docref(NULL TSRMLS_CC, E_WARNING, -@@ -1588,12 +1588,26 @@ int php_openssl_setup_crypto(php_stream - } - /* }}} */ - -+#define PHP_SSL_MAX_VERSION_LEN 32 -+ -+static char *php_ssl_cipher_get_version(const SSL_CIPHER *c, char *buffer, size_t max_len) /* {{{ */ -+{ -+ const char *version = SSL_CIPHER_get_version(c); -+ strncpy(buffer, version, max_len); -+ if (max_len <= strlen(version)) { -+ buffer[max_len - 1] = 0; -+ } -+ return buffer; -+} -+/* }}} */ -+ - static zval *capture_session_meta(SSL *ssl_handle) /* {{{ */ - { - zval *meta_arr; - char *proto_str; - long proto = SSL_version(ssl_handle); - const SSL_CIPHER *cipher = SSL_get_current_cipher(ssl_handle); -+ char version_str[PHP_SSL_MAX_VERSION_LEN]; - - switch (proto) { - #if OPENSSL_VERSION_NUMBER >= 0x10001001L -@@ -1611,7 +1625,7 @@ static zval *capture_session_meta(SSL *s - add_assoc_string(meta_arr, "protocol", proto_str, 1); - add_assoc_string(meta_arr, "cipher_name", (char *) SSL_CIPHER_get_name(cipher), 1); - add_assoc_long(meta_arr, "cipher_bits", SSL_CIPHER_get_bits(cipher, NULL)); -- add_assoc_string(meta_arr, "cipher_version", SSL_CIPHER_get_version(cipher), 1); -+ add_assoc_string(meta_arr, "cipher_version", php_ssl_cipher_get_version(cipher, version_str, PHP_SSL_MAX_VERSION_LEN), 1); - - return meta_arr; - } -diff -rupN php-5.6.31.orig/ext/phar/util.c php-5.6.31/ext/phar/util.c ---- php-5.6.31.orig/ext/phar/util.c 2017-07-06 00:25:00.000000000 +0200 -+++ php-5.6.31/ext/phar/util.c 2017-08-01 10:49:25.020823468 +0200 -@@ -1531,7 +1531,7 @@ int phar_verify_signature(php_stream *fp - BIO *in; - EVP_PKEY *key; - EVP_MD *mdtype = (EVP_MD *) EVP_sha1(); -- EVP_MD_CTX md_ctx; -+ EVP_MD_CTX *md_ctx; - #else - int tempsig; - #endif -@@ -1608,7 +1608,8 @@ int phar_verify_signature(php_stream *fp - return FAILURE; - } - -- EVP_VerifyInit(&md_ctx, mdtype); -+ md_ctx = EVP_MD_CTX_create(); -+ EVP_VerifyInit(md_ctx, mdtype); - read_len = end_of_phar; - - if (read_len > sizeof(buf)) { -@@ -1620,7 +1621,7 @@ int phar_verify_signature(php_stream *fp - php_stream_seek(fp, 0, SEEK_SET); - - while (read_size && (len = php_stream_read(fp, (char*)buf, read_size)) > 0) { -- EVP_VerifyUpdate (&md_ctx, buf, len); -+ EVP_VerifyUpdate (md_ctx, buf, len); - read_len -= (off_t)len; - - if (read_len < read_size) { -@@ -1628,9 +1629,9 @@ int phar_verify_signature(php_stream *fp - } - } - -- if (EVP_VerifyFinal(&md_ctx, (unsigned char *)sig, sig_len, key) != 1) { -+ if (EVP_VerifyFinal(md_ctx, (unsigned char *)sig, sig_len, key) != 1) { - /* 1: signature verified, 0: signature does not match, -1: failed signature operation */ -- EVP_MD_CTX_cleanup(&md_ctx); -+ EVP_MD_CTX_destroy(md_ctx); - - if (error) { - spprintf(error, 0, "broken openssl signature"); -@@ -1639,7 +1640,7 @@ int phar_verify_signature(php_stream *fp - return FAILURE; - } - -- EVP_MD_CTX_cleanup(&md_ctx); -+ EVP_MD_CTX_destroy(md_ctx); - #endif - - *signature_len = phar_hex_str((const char*)sig, sig_len, signature TSRMLS_CC); diff --git a/community/php5/php-fpm.initd b/community/php5/php-fpm.initd deleted file mode 100644 index a9c74b9bc7..0000000000 --- a/community/php5/php-fpm.initd +++ /dev/null @@ -1,93 +0,0 @@ -#!/sbin/openrc-run - -# If you want to run separate master process per pool, then create a symlink -# to this runscript for each pool. In that mode, the php-fpm daemon is started -# as nobody by default. You can override the user (and group) by declaring -# variable "user" and optionally "group" in conf.d file, or in the $fpm_config -# file (the former has precedence). - -: ${name:="PHP FastCGI Process Manager"} - -command="/usr/bin/php-fpm5" -command_background="yes" -start_stop_daemon_args="--quiet" -pidfile="/run/$RC_SVCNAME/php-fpm.pid" -retry="SIGTERM/20" - -# configtest is here only for backward compatibility -extra_commands="checkconfig configtest" -extra_started_commands="reload reopen" -description_checkconfig="Run php-fpm config check" -description_reload="Gracefully reload workers and config" -description_reopen="Reopen log files" - -required_files="$fpm_config" - -depend() { - need net - use apache2 lighttpd nginx -} - -init_vars() { - # Defaults for single master process with multiple pools - if [ "$RC_SVCNAME" = "php-fpm" ]; then - : ${fpm_config:="/etc/php5/php-fpm.conf"} - : ${user:="root"} - # Defaults for master process per pool - else - : ${fpm_config="/etc/php5/fpm.d/${RC_SVCNAME#php-fpm.}.conf"} - : ${user:="$(conf_get user)"} - : ${user:="nobody"} - : ${group:="$(conf_get group)"} - fi - command_args="--nodaemonize --fpm-config $fpm_config" - start_stop_daemon_args="$start_stop_daemon_args - --user $user ${group:+"--group $group"}" -} - -start_pre() { - checkconfig || return 1 - - # If unix socket is used (instead of TCP/IP), then ensure that the - # directory exists and has correct privileges. - local listen="$(conf_get listen)" - if [ "${listen:0:1}" = "/" ]; then - checkpath -d -o $user:$group "$(dirname "$listen")" - fi - - checkpath -d "$(dirname "$pidfile")" -} - -reload() { - ebegin "Reloading $name" - start-stop-daemon --signal USR2 --pidfile "$pidfile" - eend $? -} - -reopen() { - ebegin "Reopening $name log files" - start-stop-daemon --signal USR1 --pidfile "$pidfile" - eend $? -} - -checkconfig() { - init_vars - ebegin "Checking $fpm_config" - - local out - out="$(su -s /bin/sh -c "$command --test --fpm-config $fpm_config" $user 2>&1)" || { - printf "%s\n" "$out" - eend 1 "failed, please correct errors above" - return 1 - } -} - -configtest() { - ewarn "configtest is deprecated, use checkconfig instead" - checkconfig -} - -conf_get() { - local key="$1" - sed -nE "s/^${key}\s*=\s*\"?([^\";]+).*/\1/p" "$fpm_config" | head -n 1 -} diff --git a/community/php5/php-install-pear-xml.patch b/community/php5/php-install-pear-xml.patch deleted file mode 100644 index 18747be94b..0000000000 --- a/community/php5/php-install-pear-xml.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- ./pear/Makefile.frag.orig 2013-04-12 07:02:27.041602514 +0000 -+++ ./pear/Makefile.frag 2013-04-12 07:04:09.065836822 +0000 -@@ -2,8 +2,11 @@ - - peardir=$(PEAR_INSTALLDIR) - -+# help the built php to find xml extension so we can install pear -+PEAR_INSTALL_XML_FLAGS = -d extension_dir="$(top_builddir)/modules" -d extension=xml.so -+ - # Skip all php.ini files altogether --PEAR_INSTALL_FLAGS = -n -dshort_open_tag=0 -dopen_basedir= -derror_reporting=1803 -dmemory_limit=-1 -ddetect_unicode=0 -+PEAR_INSTALL_FLAGS = -n -dshort_open_tag=0 -dopen_basedir= -derror_reporting=1803 -dmemory_limit=-1 -ddetect_unicode=0 $(PEAR_INSTALL_XML_FLAGS) - - WGET = `which wget 2>/dev/null` - FETCH = `which fetch 2>/dev/null` diff --git a/community/php5/php5-module.conf b/community/php5/php5-module.conf deleted file mode 100644 index 32a88145a5..0000000000 --- a/community/php5/php5-module.conf +++ /dev/null @@ -1,13 +0,0 @@ -LoadModule php5_module modules/libphp5.so - -DirectoryIndex index.php index.html - -<FilesMatch \.php$> - SetHandler application/x-httpd-php -</FilesMatch> - -# Uncomment the following to allow .phps files to be handled by the php source filter, -# and displayed as syntax-highlighted source code -#<FilesMatch "\.phps$"> -# SetHandler application/x-httpd-php-source -#</FilesMatch> diff --git a/community/php5/php5.post-upgrade b/community/php5/php5.post-upgrade deleted file mode 100644 index 98c959958c..0000000000 --- a/community/php5/php5.post-upgrade +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -new=$1 -old=$2 - -if [ "$(apk version -t $old 5.3)" = "<" ]; then - echo "*" - echo "* Please see migration notes here: http://php.net/migration53" - echo "*" -fi - |