Skip to content

Instantly share code, notes, and snippets.

@sgolemon
Created September 29, 2017 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgolemon/c79bb083b26b142867a09363458f5506 to your computer and use it in GitHub Desktop.
Save sgolemon/c79bb083b26b142867a09363458f5506 to your computer and use it in GitHub Desktop.
Fallback on 32bit implementation when on BigEndian hardware.
diff --git a/ext/hash/config.m4 b/ext/hash/config.m4
index 66cc7ca810..1f3fd576ab 100644
--- a/ext/hash/config.m4
+++ b/ext/hash/config.m4
@@ -29,8 +29,15 @@ if test "$PHP_HASH" != "no"; then
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"
+ if test $ac_cv_c_bigendian_php = yes; then
+ dnl Keccak library does not yet support BE-64
+ SHA3_DIR="sha3/generic32lc"
+ SHA3_OPT_SRC="$SHA3_DIR/KeccakP-1600-inplace32BI.c"
+ AC_MSG_NOTICE([Falling back on 32bit SHA3 for BigEndian platform])
+ else
+ SHA3_DIR="sha3/generic64lc"
+ SHA3_OPT_SRC="$SHA3_DIR/KeccakP-1600-opt64.c"
+ fi
])
EXT_HASH_SHA3_SOURCES="$SHA3_OPT_SRC $SHA3_DIR/KeccakHash.c $SHA3_DIR/KeccakSponge.c"
PHP_HASH_CFLAGS="-I@ext_srcdir@/$SHA3_DIR -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment