]> granicus.if.org Git - php/commitdiff
Implemented RFC "Always available hash extension"
authorKalle Sommer Nielsen <kalle@php.net>
Wed, 3 Oct 2018 06:47:07 +0000 (08:47 +0200)
committerKalle Sommer Nielsen <kalle@php.net>
Wed, 3 Oct 2018 06:47:07 +0000 (08:47 +0200)
NEWS
UPGRADING
UPGRADING.INTERNALS
ext/hash/config.m4
ext/hash/config.w32

diff --git a/NEWS b/NEWS
index a5ad9a000bffede1b1640a5743b5245c23002666..78334fab08120e073c2e5dab039f800fdb34247d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP                                                                        NEWS
   . Fixed bug #76480 (Use curl_multi_wait() so that timeouts are respected).
     (Pierrick)
 
+- Hash:
+  . The hash extension is now an integral part of PHP and cannot be disabled
+    as per RFC: https://wiki.php.net/rfc/permanent_hash_ext. (Kalle)
+
 - Intl:
   . Lifted requirements to ICU ≥ 50.1. (cmb)
   . Changed default of $variant parameter of idn_to_ascii() and idn_to_utf8().
index 12b83975a4dca91435dd002b0cdfc074064f81bb..6118ef5eadd95189df24c6b742a2f69faef30fb7 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -75,6 +75,10 @@ PHP 7.4 UPGRADE NOTES
 9. Other Changes to Extensions
 ========================================
 
+- Hash:
+  . The hash extension cannot be disabled anymore and is always an integral 
+    part of any PHP build, similar to the date extension.
+
 - Intl:
   . The Intl extension now requires at least ICU 50.1.
 
index a38ac6af69e4c58342797d2ba7739bd98ae8b291..2d2df715d1b835e73e92e2afc6262afe1032e4fe 100644 (file)
@@ -7,11 +7,13 @@ PHP 7.4 INTERNALS UPGRADE NOTES
   d. Removed zend_check_private()
 
 2. Build system changes
-  a. Unix build system changes
-  b. Windows build system changes
+  a. Abstract
+  b. Unix build system changes
+  c. Windows build system changes
 
 3. Module changes
   a. ext/xml
+  b. ext/hash
 
 ========================
 1. Internal API changes
@@ -52,14 +54,18 @@ PHP 7.4 INTERNALS UPGRADE NOTES
 2. Build system changes
 ========================
 
-  a. Unix build system changes
+  a. Abstract
+    - The hash extension is now always available, meaning the --enable-hash 
+         configure argument has been removed.
+
+  b. Unix build system changes
     - configure --help now also outputs --program-suffix and --program-prefix
       information by using the Autoconf AC_ARG_PROGRAM macro.
     - Obsolescent macros AC_FUNC_VPRINTF and AC_FUNC_UTIME_NULL have been
       removed. Symbols HAVE_VPRINTF and HAVE_UTIME_NULL are no longer defined
       since they are not needed on the current systems.
 
-  b. Windows build system changes
+  c. Windows build system changes
 
 ========================
 3. Module changes
@@ -68,3 +74,7 @@ PHP 7.4 INTERNALS UPGRADE NOTES
   a. ext/xml
     - The public (internal) API of the ext/xml extension has been removed. All
       functions and structures are private to the extension now.
+
+  b. ext/hash
+    - The hash extension is now always available, allowing extensions to rely 
+         on its functionality to be available without compile time checks.
index 070a78102a7e7a759e18b1af01b00394f1db0048..947031a0d57b5683db2695d586050d424bdd4a19 100644 (file)
@@ -3,9 +3,6 @@ dnl config.m4 for extension hash
 PHP_ARG_WITH(mhash, for mhash support,
 [  --with-mhash[=DIR]        Include mhash support])
 
-PHP_ARG_ENABLE(hash, whether to enable hash support,
-[  --disable-hash          Disable hash support], yes)
-
 if test "$PHP_MHASH" != "no"; then
   if test "$PHP_HASH" = "no"; then
     PHP_HASH="yes"
@@ -14,44 +11,42 @@ if test "$PHP_MHASH" != "no"; then
   AC_DEFINE(PHP_MHASH_BC, 1, [ ])
 fi
 
-if test "$PHP_HASH" != "no"; then
-  AC_DEFINE(HAVE_HASH_EXT,1,[Have HASH Extension])
-
-  PHP_C_BIGENDIAN
-
-  AC_CHECK_SIZEOF(short, 2)
-  AC_CHECK_SIZEOF(int, 4)
-  AC_CHECK_SIZEOF(long, 4)
-  AC_CHECK_SIZEOF(long long, 8)
-
-  if test $ac_cv_c_bigendian_php = yes; then
-    EXT_HASH_SHA3_SOURCES="hash_sha3.c"
-    AC_DEFINE(HAVE_SLOW_HASH3, 1, [Define is hash3 algo is available])
-    AC_MSG_WARN("Use SHA3 slow implementation on bigendian")
-  else
-    PHP_CHECK_64BIT([
-      SHA3_DIR="sha3/generic32lc"
-      SHA3_OPT_SRC="$SHA3_DIR/KeccakP-1600-inplace32BI.c"
-    ],[
-      SHA3_DIR="sha3/generic64lc"
-      SHA3_OPT_SRC="$SHA3_DIR/KeccakP-1600-opt64.c"
-    ])
-    EXT_HASH_SHA3_SOURCES="$SHA3_OPT_SRC $SHA3_DIR/KeccakHash.c $SHA3_DIR/KeccakSponge.c hash_sha3.c"
-    PHP_HASH_CFLAGS="-I@ext_srcdir@/$SHA3_DIR -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded"
-
-    PHP_ADD_BUILD_DIR(ext/hash/$SHA3_DIR, 1)
-  fi
-
-  EXT_HASH_SOURCES="hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c \
-    hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c hash_adler32.c \
-    hash_crc32.c hash_fnv.c hash_joaat.c $EXT_HASH_SHA3_SOURCES"
-  EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \
-    php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \
-    php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h \
-    php_hash_fnv.h php_hash_joaat.h php_hash_sha3.h"
-
-  PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, $ext_shared,,$PHP_HASH_CFLAGS)
-  ifdef([PHP_INSTALL_HEADERS], [
-       PHP_INSTALL_HEADERS(ext/hash, $EXT_HASH_HEADERS)
+AC_DEFINE(HAVE_HASH_EXT,1,[Have HASH Extension])
+
+PHP_C_BIGENDIAN
+
+AC_CHECK_SIZEOF(short, 2)
+AC_CHECK_SIZEOF(int, 4)
+AC_CHECK_SIZEOF(long, 4)
+AC_CHECK_SIZEOF(long long, 8)
+
+if test $ac_cv_c_bigendian_php = yes; then
+  EXT_HASH_SHA3_SOURCES="hash_sha3.c"
+  AC_DEFINE(HAVE_SLOW_HASH3, 1, [Define is hash3 algo is available])
+  AC_MSG_WARN("Use SHA3 slow implementation on bigendian")
+else
+  PHP_CHECK_64BIT([
+    SHA3_DIR="sha3/generic32lc"
+    SHA3_OPT_SRC="$SHA3_DIR/KeccakP-1600-inplace32BI.c"
+  ],[
+    SHA3_DIR="sha3/generic64lc"
+    SHA3_OPT_SRC="$SHA3_DIR/KeccakP-1600-opt64.c"
   ])
+  EXT_HASH_SHA3_SOURCES="$SHA3_OPT_SRC $SHA3_DIR/KeccakHash.c $SHA3_DIR/KeccakSponge.c hash_sha3.c"
+  PHP_HASH_CFLAGS="-I@ext_srcdir@/$SHA3_DIR -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded"
+
+  PHP_ADD_BUILD_DIR(ext/hash/$SHA3_DIR, 1)
 fi
+
+EXT_HASH_SOURCES="hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c \
+  hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c hash_adler32.c \
+  hash_crc32.c hash_fnv.c hash_joaat.c $EXT_HASH_SHA3_SOURCES"
+EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \
+  php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \
+  php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h \
+  php_hash_fnv.h php_hash_joaat.h php_hash_sha3.h"
+
+PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, $ext_shared,,$PHP_HASH_CFLAGS)
+ifdef([PHP_INSTALL_HEADERS], [
+       PHP_INSTALL_HEADERS(ext/hash, $EXT_HASH_HEADERS)
+])
index 545c8673ff58e4a9f713ad5fd3f889af41e8fb2a..db7d3b58e823f8e9b1738960380e3abde62c064b 100644 (file)
@@ -1,34 +1,36 @@
 // vim:ft=javascript
 
-ARG_ENABLE("hash", "enable hash support", "yes");
-ARG_WITH("mhash", "mhash support", "no"); 
+ARG_WITH('mhash', 'mhash support (BC via hash)', 'no');
 
-if (PHP_MHASH != "no") {
-       if (PHP_HASH == "no") {
-               PHP_HASH = "yes";
-       }
+if (PHP_MHASH != 'no') {
        AC_DEFINE('PHP_MHASH_BC', 1);
 }
 
-if (PHP_HASH != "no") {
-       var sha3_arch_dir = "sha3/" + (X64 ? "generic64lc" : "generic32lc");
-       var sha3_dir = "ext/hash/" + sha3_arch_dir;
-       if (CHECK_HEADER_ADD_INCLUDE("KeccakHash.h", "CFLAGS_HASH", PHP_HASH + ";" + sha3_dir)) {
-               AC_DEFINE('HAVE_HASH_EXT', 1);
-               EXTENSION("hash", "hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c "
-                       + "hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c "
-                       + "hash_adler32.c hash_crc32.c hash_joaat.c hash_fnv.c hash_sha3.c");
-
-               ADD_SOURCES(sha3_dir, "KeccakHash.c KeccakSponge.c " + (X64 ? "KeccakP-1600-opt64.c" : "KeccakP-1600-inplace32BI.c"),
-                       "hash");
-               ADD_FLAG("CFLAGS_HASH", "/DKeccakP200_excluded /DKeccakP400_excluded /DKeccakP800_excluded");
-
-
-               PHP_INSTALL_HEADERS("ext/hash/", "php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h " +
-               "php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h " + 
-               "php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h php_hash_sha3.h ");
-       } else {
-               WARNING("hash not enabled; libraries and headers not found");
-       }
+AC_DEFINE('HAVE_HASH_EXT', 1);
+
+PHP_HASH = 'yes';
+
+EXTENSION('hash',      'hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c ' + 
+                                       'hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c ' +
+                                       'hash_adler32.c hash_crc32.c hash_joaat.c hash_fnv.c ' +
+                                       'hash_sha3.c', false);
+
+var hash_sha3_dir = 'ext/hash/sha3/generic' + (X64 ? '64' : '32') + 'lc';
+
+if(X64) {
+       ADD_SOURCES(hash_sha3_dir, 'KeccakHash.c KeccakSponge.c KeccakP-1600-opt64.c', 'hash');
+} else {
+       ADD_SOURCES(hash_sha3_dir, 'KeccakHash.c KeccakSponge.c KeccakP-1600-inplace32BI.c', 'hash');
 }
 
+if (!CHECK_HEADER_ADD_INCLUDE('KeccakHash.h', 'CFLAGS_HASH', hash_sha3_dir)) {
+       // Should NEVER happen
+       ERROR('Unable to locate SHA3 headers');
+}
+
+ADD_FLAG('CFLAGS_HASH', '/DKeccakP200_excluded /DKeccakP400_excluded /DKeccakP800_excluded');
+
+PHP_INSTALL_HEADERS('ext/hash/',       'php_hash.h php_hash_md.h php_hash_sha.h ' +
+                                                                       'php_hash_ripemd.h php_hash_haval.h php_hash_tiger.h ' +
+                                                                       'php_hash_gost.h php_hash_snefru.h php_hash_whirlpool.h ' +
+                                                                       'php_hash_adler32.h php_hash_crc32.h php_hash_sha3.h');